1 | default: all
|
2 |
|
3 | SRC = $(shell find src -name "*.coffee" -type f | sort)
|
4 | LIB = $(SRC:src/%.coffee=lib/coffee-script/%.js) lib/coffee-script/parser.js
|
5 | BOOTSTRAPS = $(SRC:src/%.coffee=lib/coffee-script/bootstrap/%.js) lib/coffee-script/bootstrap/parser.js
|
6 | LIBMIN = $(LIB:lib/coffee-script/%.js=lib/coffee-script/%.min.js)
|
7 | TEST = $(shell echo test/*.coffee | sort)
|
8 | ROOT = $(shell pwd)
|
9 |
|
10 | COFFEE = bin/coffee --js --bare
|
11 | PEGJS = node_modules/.bin/pegjs --cache --export-var 'module.exports'
|
12 | MOCHA = node_modules/.bin/mocha --compilers coffee:. -u tdd
|
13 | BROWSERIFY = node_modules/.bin/browserify
|
14 | MINIFIER = node_modules/.bin/esmangle
|
15 |
|
16 | all: $(LIB)
|
17 | build: all
|
18 | parser: lib/coffee-script/parser.js
|
19 | browser: build dist/coffee-script-redux.min.js
|
20 | min: minify
|
21 | minify: $(LIBMIN)
|
22 | # TODO: test-browser
|
23 | # TODO: doc
|
24 | # TODO: bench
|
25 |
|
26 |
|
27 | lib:
|
28 | mkdir lib/
|
29 | lib/coffee-script: lib
|
30 | mkdir -p lib/coffee-script/
|
31 | lib/coffee-script/bootstrap: lib/coffee-script
|
32 | mkdir -p lib/coffee-script/bootstrap
|
33 |
|
34 |
|
35 | lib/coffee-script/parser.js: src/grammar.pegjs bootstraps lib/coffee-script
|
36 | $(PEGJS) <"$<" >"$(@:%=%.tmp)" && mv "$(@:%=%.tmp)" "$@"
|
37 | lib/coffee-script/bootstrap/parser.js: src/grammar.pegjs lib/coffee-script/bootstrap
|
38 | $(PEGJS) <"$<" >"$@"
|
39 | lib/coffee-script/bootstrap/%.js: src/%.coffee lib/coffee-script/bootstrap
|
40 | $(COFFEE) -i "$<" >"$@"
|
41 | bootstraps: $(BOOTSTRAPS) lib/coffee-script/bootstrap
|
42 | mv lib/coffee-script/bootstrap/* lib/coffee-script
|
43 | rmdir lib/coffee-script/bootstrap
|
44 | lib/coffee-script/%.js: src/%.coffee lib/coffee-script/bootstrap/%.js bootstraps lib/coffee-script
|
45 | $(COFFEE) -i "$<" >"$(@:%=%.tmp)" && mv "$(@:%=%.tmp)" "$@"
|
46 |
|
47 |
|
48 | dist:
|
49 | mkdir dist/
|
50 |
|
51 | dist/coffee-script-redux.js: dist
|
52 | $(BROWSERIFY) lib/coffee-script/browser.js > dist/coffee-script-redux.js
|
53 |
|
54 | dist/coffee-script-redux.min.js: dist/coffee-script-redux.js
|
55 | $(MINIFIER) < dist/coffee-script-redux.js > dist/coffee-script-redux.min.js
|
56 |
|
57 |
|
58 |
|
59 | lib/coffee-script/%.min.js: lib/coffee-script/%.js lib/coffee-script
|
60 | $(MINIFIER) <"$<" >"$@"
|
61 |
|
62 |
|
63 | .PHONY: test coverage install loc clean
|
64 |
|
65 | test:
|
66 | $(MOCHA) -R dot $(TEST)
|
67 |
|
68 | coverage:
|
69 | @which jscoverage || (echo "install node-jscoverage"; exit 1)
|
70 | rm -rf instrumented
|
71 | jscoverage -v lib instrumented
|
72 | $(MOCHA) -R dot
|
73 | $(MOCHA) -r instrumented/coffee-script/compiler -R html-cov > coverage.html
|
74 | @xdg-open coverage.html &> /dev/null
|
75 |
|
76 | install:
|
77 | npm install -g .
|
78 |
|
79 | loc:
|
80 | wc -l src/*
|
81 |
|
82 | clean:
|
83 | rm -rf instrumented
|
84 | rm -f coverage.html
|
85 | rm -rf lib
|
86 | rm -rf dist
|