-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
150 lines (121 loc) · 4.21 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
# Use this flag to get a debug version of the output library.
DEBUG=0
# Files that need to be part of the resulting library.
SHARED_FILES= \
src/utils.js \
src/ast.js \
src/tedir.js \
src/myjs.js \
src/fragments/control.js \
src/fragments/core.js \
src/fragments/declaration.js \
src/fragments/exceptions.js \
src/fragments/expression.js \
src/fragments/iteration.js \
src/fragments/lefthand.js \
src/fragments/operators.js \
src/fragments/program.js \
src/fragments/statement.js \
src/fragments/with.js \
src/extensions/quote.js
EXTRA_DEPS=Makefile
NODE_LIB_FILES= \
$(SHARED_FILES) \
src/node-module.js
WEB_LIB_FILES= \
$(SHARED_FILES) \
src/mimetype.js
# Files that we should lint but that aren't part of the library.
MISC_FILES= \
test/framework.js \
test/test.js
CLOSURE_DEPS= \
goog/base.js
# Current version.
VERSION=0.2
OUTDIR=out
# Output library files.
WEB_LIB=$(OUTDIR)/myjs-web.js
NODE_LIB=$(OUTDIR)/myjs-node.js
ifeq ($(DEBUG), 0)
COMPILATION_LEVEL=ADVANCED_OPTIMIZATIONS
else
COMPILATION_LEVEL=WHITESPACE_ONLY
endif
# Extra closure flags.
CLOSURE_FLAGS= \
--compilation_level=$(COMPILATION_LEVEL) \
--warning_level=VERBOSE \
--language_in=ECMASCRIPT5 \
--externs src/externs.js \
--output_wrapper="(function() { %output% })();"
# Patch to the command-line tool.
TOOL=tools/main.js
# Builds the library, tests it, benchmarks it, lints it.
all: $(WEB_LIB) test bench lint
# Runs the tests and lints all files.
presubmit: all
$(WEB_LIB): $(WEB_LIB_FILES) download/compiler download/library $(OUTDIR) $(EXTRA_DEPS)
java -jar download/compiler/compiler.jar \
$(CLOSURE_DEPS:%=--js=download/library/closure/%) \
$(WEB_LIB_FILES:%=--js=%) \
$(CLOSURE_FLAGS) \
--js_output_file $(WEB_LIB)
$(NODE_LIB): $(NODE_LIB_FILES) download/compiler download/library $(OUTDIR) $(EXTRA_DEPS)
java -jar download/compiler/compiler.jar \
$(CLOSURE_DEPS:%=--js=download/library/closure/%) \
$(NODE_LIB_FILES:%=--js=%) \
$(CLOSURE_FLAGS) \
--js_output_file $(NODE_LIB)
arch: $(WEB_LIB) $(NODE_LIB) test bench
cp $(WEB_LIB) archive/myjs-web-$(VERSION).js
cp $(NODE_LIB) archive/myjs-node-$(VERSION).js
# Runs the tests using closure.
test: $(NODE_LIB)
$(TOOL) test
# Runs the benchmarks.
bench: $(NODE_LIB) download/library
$(TOOL) bench
# Lints all files
lint:
gjslint $(SHARED_FILES) $(MISC_FILES)
JSDOC_ROOT=download/jsdoc/jsdoc_toolkit-2.4.0/jsdoc-toolkit/
JSDOC_FLAGS=-t=$(JSDOC_ROOT)/templates/jsdoc
docs: $(SHARED_FILES) download/jsdoc $(OUTDIR) $(EXTRA_DEPS)
java -jar $(JSDOC_ROOT)/jsrun.jar $(JSDOC_ROOT)/app/run.js \
$(JSDOC_FLAGS) \
-d=$(OUTDIR)/doc \
$(SHARED_FILES)
private-docs: $(SHARED_FILES) download/jsdoc $(OUTDIR) $(EXTRA_DEPS)
java -jar $(JSDOC_ROOT)/jsrun.jar $(JSDOC_ROOT)/app/run.js \
$(JSDOC_FLAGS) \
-p -a \
-d=$(OUTDIR)/private-doc \
$(SHARED_FILES)
# Cleans up any files we've built.
clean:
rm -rf $(OUTDIR)
# Cleans up any file we've built and downloaded.
very-clean: clean
rm -rf download
COMPILER_ZIP=http://closure-compiler.googlecode.com/files/compiler-latest.zip
# Download and unpack the closure compiler.
download/compiler:
curl -o compiler.zip $(COMPILER_ZIP)
mkdir -p download/compiler
unzip -d download/compiler compiler.zip
rm compiler.zip
CLOSURE_LIBRARY=http://closure-library.googlecode.com/svn/trunk/
# Check out the closure library.
download/library:
svn checkout $(CLOSURE_LIBRARY) download/library
$(OUTDIR):
mkdir -p $(OUTDIR)
JSDOC_ZIP=http://jsdoc-toolkit.googlecode.com/files/jsdoc_toolkit-2.4.0.zip
# Download and unpack the jsdoc generator
download/jsdoc:
curl -o jsdoc.zip $(JSDOC_ZIP)
mkdir -p download/jsdoc
unzip -d download/jsdoc jsdoc.zip
rm jsdoc.zip
.PHONY: test lint clean docs bench all arch