forked from processing-js/processing-js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
180 lines (141 loc) · 6.31 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
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
#############################################################################################
# NOTES:
#
# This Makefile assumes that you have the following installed, setup:
#
# python
# java
# Unixy shell (use msys on Windows)
# $JSSHELL environment variable in .profile or .bashrc pointing to a SpiderMonkey binary
#############################################################################################
JSSHELL ?= $(error Specify a valid path to a js shell binary in ~/.profile: export JSSHELL=C:\path\js.exe or /path/js)
# If you want to test just one file or dir, use |make check-one TEST=<file or dir>|
TEST ?= $(error Specify a test filename/dir in TEST when using check-test)
# Version number used in naming release files. Defaults to DEV_VERSION
VERSION ?= DEV_VERSION
# TODO: get a Windows solution ... > /dev/null 2>&1
QUIET :=
EMPTY :=
SRC_DIR :=.
P5 :=processing
PJS :=$(P5).js
PJS_SRC :=$(SRC_DIR)/$(PJS)
PJS_VERSION :=$(P5)-$(VERSION)
PJS_VERSION_FULL :=$(P5)-js-$(VERSION)
RELEASE_DIR :=$(SRC_DIR)/release
PJS_RELEASE_PREFIX :=$(RELEASE_DIR)/$(PJS_VERSION)
PJS_RELEASE_SRC :=$(PJS_RELEASE_PREFIX).js
PJS_RELEASE_MIN :=$(PJS_RELEASE_PREFIX).min.js
EXAMPLE_HTML :=$(RELEASE_DIR)/example.html
EXAMPLES_DIR :=$(PJS_RELEASE_PREFIX)-examples
TOOLS_DIR :=$(SRC_DIR)/tools
FAKE_DOM :=$(TOOLS_DIR)/fake-dom.js
CLOSUREJAR :=$(TOOLS_DIR)/closure/compiler.jar
RUNTESTS :=@@$(TOOLS_DIR)/runtests.py $(JSSHELL)
RUNJS :=@@$(JSSHELL) -f $(FAKE_DOM) -f
SKETCHRUN :=runSketch
SKETCHINPUT ?=$(error Specify an input filename in SKETCHINPUT when using package-sketch)
SKETCHOUTPUTSRC ?=$(SKETCHINPUT).src
SKETCHOUTPUT ?=$(SKETCHINPUT).js
preprocess =@@$(JSSHELL) -f $(TOOLS_DIR)/jspreprocess.js -e "PARSER=false;preprocess();" < $(PJS_SRC) >> $(1)
compile =@@java -jar $(CLOSUREJAR) --js="$(1)" --js_output_file="$(2)" $(3) --jscomp_off=nonStandardJsDocs
copydir = @@cp -R "$(1)" "$(2)" $(QUIET) && find $(RELEASE_DIR) -type f \( -iname '*.DS_Store' -o \
-iname 'desktop.ini' -o \
-iname 'Thumbs.db' \) -delete
# Rule for making pure JS code from a .pde (runs through parser + beautify)
%.js : %.pde
@@$(TOOLS_DIR)/pde2js.py $(JSSHELL) $?
release: release-files zipped examples
@@echo "Release Created, see $(RELEASE_DIR)"
check: check-lint check-closure check-globals check-summary
release-dir: clean
@@mkdir $(RELEASE_DIR)
all: release
release-files: $(PJS_RELEASE_SRC) closure api-only example release-docs extensions
zipped: release-files
@@echo "Creating zipped archives..."
@@gzip -9 -c $(PJS_RELEASE_MIN) > $(PJS_RELEASE_MIN).gz
@@cd $(RELEASE_DIR); find . -print | zip $(PJS_VERSION_FULL).zip -@ $(QUIET)
release-docs: release-dir
@@echo "Copying project release docs..."
@@cp $(SRC_DIR)/AUTHORS $(RELEASE_DIR)
@@cat $(SRC_DIR)/README | sed -e 's/@VERSION@/$(VERSION)/' > $(RELEASE_DIR)/README
@@cp $(SRC_DIR)/LICENSE $(RELEASE_DIR) $(QUIET)
@@cp $(SRC_DIR)/CHANGELOG $(RELEASE_DIR) $(QUIET)
example: $(PJS_RELEASE_SRC)
@@echo "Creating example.html..."
@@echo "<script src=\"$(PJS_VERSION).js\"></script>" > $(EXAMPLE_HTML)
@@echo "<canvas datasrc=\"example.pjs\" width=\"200\" height=\"200\"></canvas>" >> $(EXAMPLE_HTML)
@@cp $(SRC_DIR)/example.pjs $(RELEASE_DIR)
examples: $(PJS_RELEASE_SRC)
@@echo "Copying examples..."
@@mkdir $(EXAMPLES_DIR)
@@cp $(PJS_RELEASE_SRC) $(EXAMPLES_DIR)/$(PJS)
@@$(call copydir,$(SRC_DIR)/examples,$(EXAMPLES_DIR))
@@cd $(RELEASE_DIR); zip -r $(PJS_VERSION_FULL)-examples.zip $(PJS_VERSION)-examples $(QUIET)
@@rm -fr $(EXAMPLES_DIR)
pretty: $(PJS_RELEASE_SRC)
@@echo "Creating beautified processing.js..."
@@$(TOOLS_DIR)/jsbeautify.py $(JSSHELL) $(PJS_RELEASE_SRC) > $(PJS_RELEASE_SRC).tmp
@@$(JSSHELL) -f $(FAKE_DOM) -f $(PJS_RELEASE_SRC).tmp
@@mv $(PJS_RELEASE_SRC).tmp $(PJS_RELEASE_SRC)
extensions: release-dir
@@echo "Copying extensions..."
@@$(call copydir,$(SRC_DIR)/extensions,$(RELEASE_DIR))
$(PJS_RELEASE_SRC): release-dir
@@echo "Creating processing.js..."
@@cp $(PJS_SRC) $(PJS_RELEASE_SRC).tmp
@@$(RUNJS) $(PJS_RELEASE_SRC).tmp
@@cat $(PJS_RELEASE_SRC).tmp | sed -e 's/@VERSION@/$(VERSION)/' > $(PJS_RELEASE_SRC)
@@rm -f $(PJS_RELEASE_SRC).tmp
check-tests:
$(RUNTESTS)
check-release: closure
$(RUNTESTS) -s -l $(PJS_RELEASE_MIN)
check-summary:
$(RUNTESTS) -s
check-lint:
@@echo "\nRunning jslint on processing.js:"
@@$(TOOLS_DIR)/jslint.py $(JSSHELL) $(PJS_SRC)
check-closure:
@@echo "\nRunning closure compiler on processing.js:"
@@$(call compile,$(PJS_SRC),$(RELEASE_DIR)/closurecompile.out,$(EMPTY))
@@rm -f $(RELEASE_DIR)/closurecompile.out
check-parser:
$(RUNTESTS) -p
check-unit:
$(RUNTESTS) -u
add-coverage: release-dir
@@cat $(PJS_SRC) | $(JSSHELL) -f $(TOOLS_DIR)/jscoverage.js > $(RELEASE_DIR)/$(P5)-cv.js
check-one:
$(RUNTESTS) -t $(TEST)
check-coverage: add-coverage
@@echo "Creating codecoverate.txt..."
@@$(RUNTESTS) -l $(RELEASE_DIR)/$(P5)-cv.js -c $(RELEASE_DIR)/codecoverage.txt
check-globals:
@@echo "\nRunning jsglobals on processing.js:"
@@$(RUNJS) $(TOOLS_DIR)/jsglobals.js -e "findDifference()" < $(PJS_SRC)
print-globals:
@@$(RUNJS) $(TOOLS_DIR)/jsglobals.js -e "printNames()" < $(PJS_SRC)
closure: release-dir
@@$(call compile,$(PJS_SRC),$(PJS_RELEASE_MIN),$(EMPTY))
compile-sketch:
@@$(RUNJS) $(PJS_SRC) -f $(TOOLS_DIR)/jscompile.js < $(SKETCHINPUT) > $(SKETCHOUTPUT)
@@echo "Created $(SKETCHOUTPUT)"
package-sketch:
@@echo "function $(SKETCHRUN)(canvas) {" > $(SKETCHOUTPUTSRC)
@@$(call preprocess,$(SKETCHOUTPUTSRC))
@@echo "return new Processing(canvas," >> $(SKETCHOUTPUTSRC)
@@$(RUNJS) $(PJS_SRC) -f $(TOOLS_DIR)/jscompile.js < $(SKETCHINPUT) >> $(SKETCHOUTPUTSRC)
@@echo "); } window['$(SKETCHRUN)']=$(SKETCHRUN);" >> $(SKETCHOUTPUTSRC)
@@$(call compile,$(SKETCHOUTPUTSRC),$(SKETCHOUTPUT),--compilation_level ADVANCED_OPTIMIZATIONS)
@@rm -f $(SKETCHOUTPUTSRC)
@@echo "Created $(SKETCHOUTPUT)"
api-only: release-dir
@@echo "Creating processing.js API version..."
@@$(call preprocess,$(PJS_RELEASE_PREFIX)-api.js)
@@cat $(PJS_RELEASE_PREFIX)-api.js | sed -e 's/@VERSION@/$(VERSION)/' > $(PJS_RELEASE_PREFIX)-api.js.tmp
@@mv $(PJS_RELEASE_PREFIX)-api.js.tmp $(PJS_RELEASE_PREFIX)-api.js
@@$(call compile,$(PJS_RELEASE_PREFIX)-api.js,$(PJS_RELEASE_PREFIX)-api.min.js,$(EMPTY))
clean:
@@rm -fr $(RELEASE_DIR)