forked from jcoglan/canopy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
82 lines (53 loc) · 1.95 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
SHELL := /bin/bash
.PHONY: bootstrap compile test examples clean clean-test clean-examples
src_files := $(shell find src -type f)
templates := $(shell find templates -type f)
lib_files := $(src_files:src/%=lib/%) node_modules $(templates)
bootstrap: test $(lib_files)
compile:
./bin/canopy src/meta_grammar.peg
test: node_modules test-js
clean: clean-examples clean-test
lib/%: src/%
@mkdir -p $(@D)
cp $< $@
node_modules:
npm install --no-save
examples/%.js: examples/%.peg $(lib_files)
./bin/canopy --lang js $<
test/%.js: test/%.peg $(lib_files)
./bin/canopy --lang js $<
%/Grammar.java: %.peg $(lib_files)
./bin/canopy --lang java $<
%.py: %.peg $(lib_files)
./bin/canopy --lang python $<
%.rb: %.peg $(lib_files)
./bin/canopy --lang ruby $<
test_grammars := $(wildcard test/grammars/*.peg)
test/javascript/node_modules:
cd test/javascript && npm install --no-save
test-all: test-java test-js test-python test-ruby
test-java: $(test_grammars:%.peg=%/Grammar.java)
cd test/java && mvn clean test
test-js: test/javascript/node_modules $(test_grammars:%.peg=%.js)
cd test/javascript && npm test
test-python: $(test_grammars:%.peg=%.py)
cd test && python -m unittest discover --pattern '*_test.py'
test-ruby: $(test_grammars:%.peg=%.rb)
cd test/ruby && rake
clean-test:
find test/grammars -type f -a ! -name '*.peg' -a ! -name __init__.py -exec rm {} \;
example_grammars := $(wildcard examples/canopy/*.peg)
example_grammars_js := $(example_grammars:%.peg=%.js)
example_grammars_java := $(example_grammars:%.peg=%/Grammar.java)
example_grammars_python := $(example_grammars:%.peg=%.py)
example_grammars_ruby := $(example_grammars:%.peg=%.rb)
examples: $(example_grammars_js) \
$(example_grammars_java) \
$(example_grammars_python) \
$(example_grammars_ruby) \
examples/pegjs
examples/pegjs:
find examples/pegjs -name '*.peg' -exec pegjs --cache {} \;
clean-examples:
find examples -name '*.class' -o -name '*.pyc' -exec rm {} \;