-
Notifications
You must be signed in to change notification settings - Fork 581
/
Makefile
335 lines (259 loc) · 10.4 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
RUNTIME_SRC = \
src/runtime/runtime.js \
src/runtime/url.js \
src/loader/ModuleStoreImpl.js \
# end files that must be script.
POLYFILL_SRC = \
src/runtime/polyfills/Map.js \
src/runtime/polyfills/Set.js \
src/runtime/polyfills/Promise.js \
src/runtime/polyfills/String.js \
src/runtime/polyfills/Array.js \
src/runtime/polyfills/Object.js \
src/runtime/polyfills/Number.js \
src/runtime/polyfills/Math.js \
src/runtime/polyfills/WeakMap.js \
src/runtime/polyfills/WeakSet.js \
src/runtime/polyfills/polyfills.js
RUNTIME_MODULES = src/runtime/runtime-modules.js
INDIVIDUAL_RUNTIME_MODULES = \
src/runtime/exportStar.js \
src/runtime/properTailCalls.js \
src/runtime/relativeRequire.js \
src/runtime/spread.js \
src/runtime/destructuring.js \
src/runtime/classes.js \
src/runtime/generators.js \
src/runtime/async.js \
src/runtime/spawn.js \
src/runtime/template.js \
src/runtime/jsx.js \
#end runtime modules
SRC = \
$(RUNTIME_MODULES) \
$(POLYFILL_SRC) \
src/traceur-import.js
TPL_GENSRC = \
src/outputgeneration/regexpuRewritePattern.js \
src/outputgeneration/SourceMapIntegration.js
GENSRC = \
$(TPL_GENSRC) \
src/codegeneration/ParseTreeTransformer.js \
src/syntax/trees/ParseTreeType.js \
src/syntax/trees/ParseTrees.js \
src/syntax/ParseTreeVisitor.js
PREV_NODE = $(wildcard node_modules/traceur/src/node/*.js)
SRC_NODE = $(wildcard src/node/*.js)
SRC_ALL = $(shell find src/ -type f -name "*.js")
RUNTIME_SCRIPTS = $(foreach src, $(RUNTIME_SRC), --script $(src))
TFLAGS = --symbols=false --
UNIT_TESTS = \
test/unit/util/ \
test/unit/node/ \
test/unit/syntax/ \
test/unit/codegeneration/ \
test/unit/semantics/ \
test/unit/ \
test/unit/runtime \
#END UNIT_TESTS
FEATURE_TESTS = \
test/feature/*/*.js
TESTS = \
test/node-commonjs-test.js \
test/node-amd-test.js \
test/node-closure-test.js \
test/node-instantiate-test.js \
test/node-api-test.js \
# End Node tests.
MOCHA_OPTIONS = \
--ignore-leaks --ui tdd --reporter dot
ifdef ONLY
MOCHA_OPTIONS := $(MOCHA_OPTIONS) --grep $(ONLY)
endif
GIT_BRANCH = $(shell git rev-parse --abbrev-ref HEAD)
PACKAGE_VERSION=$(shell node build/versionInfo.js -v)
build: bin/traceur.js wiki
min: bin/traceur.min.js
# Uses uglifyjs to compress. Make sure you have it installed
# npm install uglify-js -g
ugly: bin/traceur.ugly.js
test-runtime: bin/traceur-runtime.js $(RUNTIME_TESTS)
@echo 'Open test/runtime.html to test runtime only'
test: bin/traceur.js \
bin/BrowserSystem.js \
test/unit \
test/unit/runtime/traceur-runtime \
wiki \
test/amd-compiled \
test/commonjs-compiled \
test-interpret \
test-interpret-absolute \
test-inline-module-error \
test-version \
test/features \
test/module-compiled \
test-experimental
node_modules/.bin/mocha $(MOCHA_OPTIONS) $(TESTS)
$(MAKE) test-interpret-throw
test/unit: bin/traceur.js bin/traceur-runtime.js $(UNIT_TESTS)
./tval test/runUnitTests.js
test/features: bin/traceur.js bin/traceur-runtime.js $(FEATURE_TESTS)
./tval test/runFeatureTests.js
test/%-run: test/% bin/traceur.js
node_modules/.bin/mocha $(MOCHA_OPTIONS) $<
test/module-compiled: bin/traceur.js
node_modules/.bin/mocha $(MOCHA_OPTIONS) \
--compilers js:test/register-cjs-test-wrapper.js --reporter dot test/feature/**/
test/commonjs: test/commonjs-compiled
node_modules/.bin/mocha $(MOCHA_OPTIONS) test/node-commonjs-test.js
test/amd: test/amd-compiled
node_modules/.bin/mocha $(MOCHA_OPTIONS) test/node-amd-test.js
test/closure:
node_modules/.bin/mocha $(MOCHA_OPTIONS) test/node-closure-test.js
test-interpret: test/unit/node/traceur-interpreter.js
./traceur $^
test-interpret-throw: test/unit/runtime/resources/throwsError.js
./traceur $^ 2>&1 | grep 'ModuleEvaluationError' | wc -l | grep '1'
test-interpret-absolute: $(CURDIR)/test/unit/node/traceur-interpreter.js
./traceur $^
test-inline-module-error:
./traceur --out not-written.js \
test/feature/Modules/Error_ImportDefault.js 2>&1 | sed '1d' > /dev/null
test/commonjs-compiled: force
rm -f -r test.commonjs-compiled/*
node src/node/to-commonjs-compiler.js test/commonjs test/commonjs-compiled
test/amd-compiled: force
rm -f -r test/amd-compiled/*
node src/node/to-amd-compiler.js test/amd test/amd-compiled
test/unit/runtime/traceur-runtime: \
test/unit/runtime/resources/traceur-runtime.js bin/traceur-runtime.js
node $<
test-version:
./traceur -v | grep '[0-9]*\.[0-9]*\.[0-9]*'
# Skip sloppy tests because the Promise polyfill is defined in a module
# and module context in ES6 is strict by default
test-promise:
node_modules/promises-aplus-tests/lib/cli.js \
test/node-promise-adapter.js --grep "2.2.5" --grep "sloppy" --invert
test-compat-table: node_modules/es5-compat-table/data-es6.js bin/traceur.js
npm install git+https://github.com/kangax/compat-table.git#gh-pages
./traceur --source-maps='memory' test/verify-compat.js
test-experimental: bin/traceur.js
./traceur --experimental -- ./test/unit/node/resources/let-x.js
boot: clean build
clean: wikiclean
@rm -f build/compiled-by-previous-traceur.js
@rm -f src/loader/version.js
@rm -rf build/currentSemVer.mk
@rm -f build/es6-no-modules/*
@rm -f $(GENSRC)
@rm -f $(COMPILE_BEFORE_TEST)
@rm -f test/test-list.js
@rm -rf test/commonjs-compiled/*
@rm -rf test/commonjs-compiled-maps/*
@rm -rf test/amd-compiled/*
@rm -f bin/*
$(NPM_INSTALL)
initbench:
rm -rf test/bench/esprima
git clone https://github.com/ariya/esprima.git test/bench/esprima
cd test/bench/esprima; git reset --hard 1ddd7e0524d09475
git apply test/bench/esprima-compare.patch
bin/%.min.js: bin/%.js
node build/minifier.js $^ $@
# Do not change the location of this file if at all possible, see
# https://github.com/google/traceur-compiler/issues/828
bin/traceur-runtime.js: $(RUNTIME_SRC) $(RUNTIME_MODULES) $(POLYFILL_SRC) bin/traceur.js
./traceur --out $@ --referrer='traceur-runtime@$(PACKAGE_VERSION)/bin/' \
$(RUNTIME_SCRIPTS) $(TFLAGS) $(RUNTIME_MODULES) $(POLYFILL_SRC)
bin/traceur-bare.js: src/traceur-import.js build/compiled-by-previous-traceur.js
./traceur --out $@ $(TFLAGS) $<
concat: bin/traceur-runtime.js bin/traceur-bare.js
cat $^ > bin/traceur.js
bin/traceur.js: build/compiled-by-previous-traceur.js $(SRC_NODE)
@cp $< $@; touch -t 197001010000.00 bin/traceur.js
./traceur --source-maps=file --out bin/traceur.js --referrer='traceur@$(PACKAGE_VERSION)/bin/' \
$(RUNTIME_SCRIPTS) $(TFLAGS) $(SRC)
# Use last-known-good compiler to compile current source
build/compiled-by-previous-traceur.js: src/loader/version.js \
$(PREV_NODE) \
$(SRC) \
node_modules/traceur/bin/traceur.js $(SRC_ALL) $(GENSRC) node_modules
@mkdir -p bin/
node_modules/traceur/traceur --out $@ --referrer='[email protected]/build/' \
$(RUNTIME_SCRIPTS) $(TFLAGS) $(SRC)
debug: build/compiled-by-previous-traceur.js $(SRC)
./traceur --debug --out bin/traceur.js --sourcemap $(RUNTIME_SCRIPTS) $(TFLAGS) $(SRC)
# Stand-alone browser support, incl. runtime, polyfills, compiler, and System
bin/BrowserSystem.js: src/browser/System.js src/WebPageTranscoder.js $(SRC_ALL)
node_modules/traceur/traceur --source-maps=file --out $@ --referrer='traceur@$(PACKAGE_VERSION)/bin/' \
$(RUNTIME_SCRIPTS) $(TFLAGS) $(SRC) src/browser/System.js
#
# Rules to test traceur.js compiled through path that first compiles out modules then es6.
# The regular compiler must be built before running these rules.
#
build/es6-no-modules/compiler.js: $(SRC_NODE) src/traceur-import.js
node_modules/traceur/traceur --out $@ --modules=inline --referrer='[email protected]/build/es6-no-modules/' \
--outputLanguage=es6 $(TFLAGS) src/traceur-import.js
build/es6-no-modules/global-imports.js: $(RUNTIME_MODULES) $(POLYFILL_SRC) src/runtime/runtime-modules.js src/runtime/polyfills-imports.js
./traceur --out build/es6-no-modules/global-imports.js --modules=inline --outputLanguage=es6 -- src/runtime/global-imports.js
build/es6-no-modules/runtime.js: $(RUNTIME_SRC) build/es6-no-modules/global-imports.js
./traceur --out $@ $(RUNTIME_SCRIPTS) $(TFLAGS)
cat build/es6-no-modules/global-imports.js >> $@
# The complete traceur compiler in es6 but with modules compiled away.
bin/traceur-es6-no-modules.js: build/es6-no-modules/runtime.js build/es6-no-modules/compiler.js
cat $^ > $@
bin/traceur-from-no-modules.js: bin/traceur-es6-no-modules.js
./traceur --out $@ --referrer='traceur@$(PACKAGE_VERSION)/bin/' --script bin/traceur-es6-no-modules.js $(TFLAGS)
test-no-modules: bin/traceur-from-no-modules.js bin/traceur-runtime.js bin/traceur.js
cp bin/traceur.js bin/gold-traceur.js # bin/traceur.js is called by test rules, so temp override it.
cp bin/traceur-from-no-modules.js bin/traceur.js
touch bin/traceur-runtime.js # our temp bin/traceur.js has a new timestamp, don't trigger rebuild.
-$(MAKE) -r test
cp -p bin/gold-traceur.js bin/traceur.js # preserve timestamp to avoid make triggers.
rm bin/gold-traceur.js
#
#
src/syntax/trees/ParseTrees.js: \
build/build-parse-trees.js src/syntax/trees/trees.json
node $^ > $@
src/syntax/trees/ParseTreeType.js: \
build/build-parse-tree-type.js src/syntax/trees/trees.json
node $^ > $@
src/syntax/ParseTreeVisitor.js: \
build/build-parse-tree-visitor.js src/syntax/trees/trees.json
node $^ > $@
src/codegeneration/ParseTreeTransformer.js: \
build/build-parse-tree-transformer.js src/syntax/trees/trees.json
node $^ > $@
src/loader/version.js: package.json build/versionInfo.js
node ./build/versionInfo.js -m > $@
unicode-tables: \
build/build-unicode-tables.js
node $^ > src/syntax/unicode-tables.js
%.js: %.js-template
node build/expand-js-template.js $< $@
# set NO_PREPUBLISH=1 to prevent endless loop of makes and npm installs.
NPM_INSTALL = NO_PREPUBLISH=1 npm install --local && touch node_modules
node_modules/%:
$(NPM_INSTALL)
node_modules: package.json
$(NPM_INSTALL)
bin/traceur.ugly.js: bin/traceur.js
uglifyjs bin/traceur.js --compress -m -o $@
updateSemver: # unless the package.json has been manually edited.
node build/versionInfo.js -v > build/npm-version-number
git diff --quiet -- package.json && node build/incrementSemver.js
dist/commonjs: bin/traceur.js
./traceur --dir src/ dist/commonjs/ --modules=commonjs --import-runtime \
--symbols=false
prepublish: bin/traceur.js bin/traceur-runtime.js dist/commonjs/
WIKI_OUT = \
test/wiki/CompilingOffline/out/greeter.js
wiki: $(WIKI_OUT)
wikiclean:
@rm -rf test/wiki/CompilingOffline/out
test/wiki/CompilingOffline/out/greeter.js: test/wiki/CompilingOffline/greeter.js
./traceur --out $@ $^
.PHONY: build min test test-list force boot clean distclean unicode-tables prepublish dist/commonjs
.SUFFIXES: