Skip to content
This repository
Fetching contributors…

Cannot retrieve contributors at this time

file 86 lines (65 sloc) 2.419 kb
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
default: all

SRC = $(shell find src -name "*.coffee" -type f | sort)
LIB = $(SRC:src/%.coffee=lib/coffee-script/%.js) lib/coffee-script/parser.js
BOOTSTRAPS = $(SRC:src/%.coffee=lib/coffee-script/bootstrap/%.js) lib/coffee-script/bootstrap/parser.js
LIBMIN = $(LIB:lib/coffee-script/%.js=lib/coffee-script/%.min.js)
TEST = $(shell echo test/*.coffee | sort)
ROOT = $(shell pwd)

COFFEE = bin/coffee --js --bare
PEGJS = node_modules/.bin/pegjs --cache --export-var 'module.exports'
MOCHA = node_modules/.bin/mocha --compilers coffee:. -u tdd
BROWSERIFY = node_modules/.bin/browserify
MINIFIER = node_modules/.bin/esmangle

all: $(LIB)
build: all
parser: lib/coffee-script/parser.js
browser: build dist/coffee-script-redux.min.js
min: minify
minify: $(LIBMIN)
# TODO: test-browser
# TODO: doc
# TODO: bench


lib:
mkdir lib/
lib/coffee-script: lib
mkdir -p lib/coffee-script/
lib/coffee-script/bootstrap: lib/coffee-script
mkdir -p lib/coffee-script/bootstrap


lib/coffee-script/parser.js: src/grammar.pegjs bootstraps lib/coffee-script
$(PEGJS) <"$<" >"$(@:%=%.tmp)" && mv "$(@:%=%.tmp)" "$@"
lib/coffee-script/bootstrap/parser.js: src/grammar.pegjs lib/coffee-script/bootstrap
$(PEGJS) <"$<" >"$@"
lib/coffee-script/bootstrap/%.js: src/%.coffee lib/coffee-script/bootstrap
$(COFFEE) -i "$<" >"$@"
bootstraps: $(BOOTSTRAPS) lib/coffee-script/bootstrap
mv lib/coffee-script/bootstrap/* lib/coffee-script
rmdir lib/coffee-script/bootstrap
lib/coffee-script/%.js: src/%.coffee lib/coffee-script/bootstrap/%.js bootstraps lib/coffee-script
$(COFFEE) -i "$<" >"$(@:%=%.tmp)" && mv "$(@:%=%.tmp)" "$@"


dist:
mkdir dist/

dist/coffee-script-redux.js: dist
$(BROWSERIFY) lib/coffee-script/browser.js > dist/coffee-script-redux.js

dist/coffee-script-redux.min.js: dist/coffee-script-redux.js
$(MINIFIER) < dist/coffee-script-redux.js > dist/coffee-script-redux.min.js



lib/coffee-script/%.min.js: lib/coffee-script/%.js lib/coffee-script
$(MINIFIER) <"$<" >"$@"


.PHONY: test coverage install loc clean

test:
$(MOCHA) -R dot

coverage:
@which jscoverage || (echo "install node-jscoverage"; exit 1)
rm -rf instrumented
jscoverage -v lib instrumented
$(MOCHA) -R dot
$(MOCHA) -r instrumented/coffee-script/compiler -R html-cov > coverage.html
@xdg-open coverage.html &> /dev/null

install:
npm install -g .

loc:
wc -l src/*

clean:
rm -rf instrumented
rm -f coverage.html
rm -rf lib
rm -rf dist
Something went wrong with that request. Please try again.