-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathMakefile
139 lines (110 loc) · 4.28 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
VERSION = 0.0.9
NODEJS = $(if $(shell test -f /usr/bin/nodejs && echo "true"),nodejs,node)
ifeq ($(V), 1)
define doit
@echo " * "$(strip $(1));
$(strip $(2))
endef
else
define doit
@echo -n " * "$(strip $(1))"...";
@$(strip $(2)) && echo " done" || ((rm -f $(strip $(3)) && echo " failed"))
endef
endif
SOURCES = \
src/API_compiling.js \
src/API_debugging.js \
src/API_support.js \
build/parsePEG.js \
src/re.js \
deps/lists.js \
deps/util.js \
deps/assert.js \
src/codegen_6_attr.js \
src/codegen_6.js \
src/codegen_6_tree_attribution.js \
src/codegen_6_dfa_generation.js \
src/codegen_6_dfa_output.js \
src/codegen_6_character_equivalence_classes.js \
src/codegen_6_run_length_encoding.js \
src/codegen_6_expression_flags.js
SOURCES_UTIL = \
src/API_support.js
JS_AST_SOURCES = deps/util.js \
js_pp/src/js_ast.js
JS_PP_SOURCES = deps/util.js \
deps/lists.js \
js_pp/src/js_compose.js \
js_pp/src/js_generate_sub_contexts.js \
js_pp/src/js_pp.js
CLOSURE_COMPILER = closure-compiler
BUILT_SOURCES = build/cset.js
PANPG = build/PanPG.js
PANPG_UTIL = build/PanPG_util.js
PANPG_UTIL_MIN = build/PanPG_util.min.js
PANPG_MIN = build/PanPG.min.js
GEN_PARSER = build/generate_parser_shell.js
GEN_BUILD = build/build_generic.js
# $(call build_generic, message, output, package name, description, requires, exports, includes)
define build_generic
$(call doit, $(1), $(NODEJS) $(GEN_BUILD) \
--output $(2) \
--version $(VERSION) \
--package $(3) \
--description $(4) \
$(foreach i, $(5), --require $(i)) \
$(foreach i, $(6), --export $(i)) \
$(foreach i, $(7), --include $(i)), $(2))
endef
# $(call build_parser, message, input, output, patches, commonjs?, fname, startrule)
define build_parser
$(call doit, $(1), $(NODEJS) $(GEN_PARSER) \
--input $(2) \
--output $(3) \
$(foreach i, $(4), --patch $(i)) \
$(if $(strip $(5)),--commonjs) \
--fname $(6) \
--startrule $(7), $(2))
endef
# some make stupidity
, := ,
space :=
space +=
$(space) :=
$(space) +=
all: panpg
panpg: $(PANPG)
min: $(PANPG_MIN) $(PANPG_UTIL_MIN)
support: $(PANPG_UTIL)
ast: build/parseJS.js support build/js_ast.js
js_pp: ast build/js_pp.js
test: js_pp
NODE_PATH=build nodeunit test
build/cset.js: src/cset.js \
src/UNIDATA/UnicodeData.txt \
build/build_cset.js \
build/cset_unicode_properties.js
$(call doit, "Building $@", $(NODEJS) build/build_cset.js $@, $@)
$(PANPG): $(SOURCES) $(BUILT_SOURCES)
$(call build_generic,"Bootstrapping (not yet actually)", $@, PanPG, "PEG → JavaScript parser generator$(,) with its dependencies" ,,generateParser explain,$^)
$(call build_parser, "Generating parser ($@)", grammars/PEG.peg, $@, , true, parsePEG, RuleSet)
$(call build_generic,"Building $@", $@, PanPG, "PEG → JavaScript parser generator$(,) with its dependencies" ,,generateParser explain,$^)
$(PANPG_UTIL): $(SOURCES_UTIL)
$(call build_generic,"Building $@",$@,PanPG_util,"Utility functions on PanPG parse trees",,showTree treeWalker,$^)
$(PANPG_UTIL_MIN): $(PANPG_UTIL)
$(call doit, "Minifying $^", $(CLOSURE_COMPILER) --js $^ --js_output_file $@, $@)
$(PANPG_MIN): $(PANPG)
$(call doit, "Minifying $^", $(CLOSURE_COMPILER) --js $^ --js_output_file $@, $@)
build/parseES5.js: $(PANPG) grammars/ECMAScript_5.peg
# $(call build_parser, message, input, output, patches, commonjs?, fname, startrule)
$(call build_parser, "Generating parser ($@)", grammars/ECMAScript_5.peg, $@, , true, parseES5, Program)
build/parseJS.js: $(PANPG) grammars/ECMAScript_5.peg grammars/ECMAScript_web_compat.peg grammars/ECMAScript_5_streamable.peg
$(call build_parser, "Generating parser ($@)", grammars/ECMAScript_5.peg, $@,grammars/ECMAScript_web_compat.peg grammars/ECMAScript_5_streamable.peg, true, parseJS, Program)
build/js_ast.js: $(JS_AST_SOURCES)
$(call build_generic,"Building $@",$@,js_ast,"Javascript AST",parseJS:JSParser PanPG_util,js_ast:create_ast,$(JS_AST_SOURCES))
build/js_pp.js: $(JS_PP_SOURCES)
$(call build_generic,"Building $@",$@,js_pp,"Javascript PP",,format,$(JS_PP_SOURCES))
@sed -i "s/js_ast(s)/require('js_ast').create_ast(s)/" $@
clean:
rm -f $(BUILT_SOURCES) $(PANPG) $(PANPG_MIN) $(PANPG_UTIL_MIN) $(PANPG_UTIL) build/js_ast.js build/js_pp.js build/parseES5.js build/parseJS.js
.PHONY: panpg all clean min install support ast js_pp test