1 | OS := $(shell uname)
|
2 | BRANCH := $(shell git rev-parse --abbrev-ref HEAD)
|
3 |
|
4 | SRC_GLSL := $(shell find src -type f -name '*.glsl')
|
5 | SRC_SHADER_JS := $(patsubst %shader.glsl,%shader.js,$(SRC_GLSL))
|
6 | SRC_JS := $(filter-out $(SRC_SHADER_JS),$(shell find src -name '*.js'))
|
7 | SRC_JSDOC = $(shell find src -type f -name '*.jsdoc')
|
8 |
|
9 | SPEC_JS := $(shell find test/spec -type f -name '*.js')
|
10 | SPEC_RENDERING_JS := $(shell find test_rendering/spec -name '*.js')
|
11 |
|
12 | EXAMPLES := $(shell find examples -type f)
|
13 | EXAMPLES_HTML := $(filter-out examples/index.html,$(shell find examples -maxdepth 1 -type f -name '*.html'))
|
14 | EXAMPLES_JS := $(patsubst %.html,%.js,$(EXAMPLES_HTML))
|
15 |
|
16 | BUILD_EXAMPLES := $(subst examples,build/examples,$(EXAMPLES)) build/examples/index.js
|
17 |
|
18 | BUILD_HOSTED := build/hosted/$(BRANCH)
|
19 | BUILD_HOSTED_EXAMPLES := $(addprefix $(BUILD_HOSTED)/,$(EXAMPLES))
|
20 | BUILD_HOSTED_EXAMPLES_JS := $(addprefix $(BUILD_HOSTED)/,$(EXAMPLES_JS))
|
21 |
|
22 | UNPHANTOMABLE_EXAMPLES = examples/shaded-relief.html examples/raster.html examples/region-growing.html examples/color-manipulation.html
|
23 | CHECK_EXAMPLE_TIMESTAMPS = $(patsubst examples/%.html,build/timestamps/check-%-timestamp,$(filter-out $(UNPHANTOMABLE_EXAMPLES),$(EXAMPLES_HTML)))
|
24 |
|
25 | TASKS_JS := $(shell find tasks -name '*.js')
|
26 |
|
27 | ifeq (CYGWIN,$(findstring CYGWIN,$(OS)))
|
28 | CLOSURE_LIB = $(shell cygpath -u $(shell node -e 'process.stdout.write(require("closure-util").getLibraryPath())'))
|
29 | else
|
30 | CLOSURE_LIB = $(shell node -e 'process.stdout.write(require("closure-util").getLibraryPath())')
|
31 | endif
|
32 |
|
33 | ifeq ($(OS),Darwin)
|
34 | STAT_COMPRESSED = stat -f ' compressed: %z bytes'
|
35 | STAT_UNCOMPRESSED = stat -f 'uncompressed: %z bytes'
|
36 | else
|
37 | STAT_COMPRESSED = stat -c ' compressed: %s bytes'
|
38 | STAT_UNCOMPRESSED = stat -c 'uncompressed: %s bytes'
|
39 | endif
|
40 |
|
41 | .PHONY: default
|
42 | default: help
|
43 |
|
44 | .PHONY: help
|
45 | help:
|
46 | @echo
|
47 | @echo "The most common targets are:"
|
48 | @echo
|
49 | @echo "- install Install node dependencies"
|
50 | @echo "- serve Start dev server for running examples and tests"
|
51 | @echo "- test Run unit tests in the console"
|
52 | @echo "- check Perform a number of checks on the code"
|
53 | @echo "- clean Remove generated files"
|
54 | @echo "- help Display this help message"
|
55 | @echo
|
56 | @echo "Other less frequently used targets are:"
|
57 | @echo
|
58 | @echo "- build Build ol.js, ol-debug.js, ol.js.map and ol.css"
|
59 | @echo "- lint Check the code with the linter"
|
60 | @echo "- ci Run the full continuous integration process"
|
61 | @echo "- apidoc Build the API documentation using JSDoc"
|
62 | @echo "- cleanall Remove all the build artefacts"
|
63 | @echo "- check-deps Check if the required dependencies are installed"
|
64 | @echo
|
65 |
|
66 | .PHONY: apidoc
|
67 | apidoc: build/timestamps/jsdoc-$(BRANCH)-timestamp
|
68 |
|
69 | .PHONY: build
|
70 | build: build/ol.css build/ol.js build/ol-debug.js build/ol.js.map
|
71 |
|
72 | .PHONY: check
|
73 | check: lint build/ol.js test
|
74 |
|
75 | .PHONY: check-examples
|
76 | check-examples: $(CHECK_EXAMPLE_TIMESTAMPS)
|
77 |
|
78 | .PHONY: check-deps
|
79 | check-deps: EXECUTABLES = git node python java
|
80 | check-deps:
|
81 | @for exe in $(EXECUTABLES) ;\
|
82 | do \
|
83 | which $${exe} > /dev/null && \
|
84 | echo "Program $${exe} OK" || \
|
85 | echo "Program $${exe} MISSING!" ;\
|
86 | done ;\
|
87 |
|
88 | .PHONY: ci
|
89 | ci: lint build test test-rendering package compile-examples check-examples apidoc
|
90 |
|
91 | .PHONY: compile-examples
|
92 | compile-examples: build/compiled-examples/all.combined.js
|
93 |
|
94 | .PHONY: clean
|
95 | clean:
|
96 | rm -f build/timestamps/eslint-timestamp
|
97 | rm -f build/timestamps/check-*-timestamp
|
98 | rm -f build/ol.css
|
99 | rm -f build/ol.js
|
100 | rm -f build/ol.js.map
|
101 | rm -f build/ol-debug.js
|
102 | rm -f build/test_requires.js
|
103 | rm -f build/test_rendering_requires.js
|
104 | rm -rf build/examples
|
105 | rm -rf build/compiled-examples
|
106 | rm -rf build/package
|
107 | rm -rf $(BUILD_HOSTED)
|
108 |
|
109 | .PHONY: cleanall
|
110 | cleanall:
|
111 | rm -rf build
|
112 |
|
113 | .PHONY: css
|
114 | css: build/ol.css
|
115 |
|
116 | .PHONY: examples
|
117 | examples: $(BUILD_EXAMPLES)
|
118 |
|
119 | .PHONY: install
|
120 | install: build/timestamps/node-modules-timestamp
|
121 |
|
122 | .PHONY: lint
|
123 | lint: build/timestamps/eslint-timestamp
|
124 |
|
125 | .PHONY: npm-install
|
126 | npm-install: build/timestamps/node-modules-timestamp
|
127 |
|
128 | .PHONY: shaders
|
129 | shaders: $(SRC_SHADER_JS)
|
130 |
|
131 | .PHONY: serve
|
132 | serve: build/test_requires.js build/test_rendering_requires.js
|
133 | node tasks/serve.js
|
134 |
|
135 | .PHONY: test
|
136 | test: build/timestamps/node-modules-timestamp build/test_requires.js
|
137 | node tasks/test.js
|
138 |
|
139 | .PHONY: test-coverage
|
140 | test-coverage: build/timestamps/node-modules-timestamp
|
141 | node tasks/test-coverage.js
|
142 |
|
143 | .PHONY: test-rendering
|
144 | test-rendering: build/timestamps/node-modules-timestamp \
|
145 | build/test_rendering_requires.js
|
146 | @rm -rf build/slimerjs-profile
|
147 | @mkdir -p build/slimerjs-profile
|
148 | @cp -r test_rendering/slimerjs-profile/* build/slimerjs-profile/
|
149 | node tasks/test-rendering.js
|
150 |
|
151 | .PHONY: host-examples
|
152 | host-examples: $(BUILD_HOSTED_EXAMPLES) \
|
153 | $(BUILD_HOSTED)/build/ol.js \
|
154 | $(BUILD_HOSTED)/build/ol-debug.js \
|
155 | $(BUILD_HOSTED)/css/ol.css \
|
156 | $(BUILD_HOSTED)/examples/loader.js \
|
157 | $(BUILD_HOSTED)/examples/index.js \
|
158 | $(BUILD_HOSTED)/build/ol-deps.js
|
159 |
|
160 | .PHONY: host-libraries
|
161 | host-libraries: build/timestamps/node-modules-timestamp
|
162 | @rm -rf $(BUILD_HOSTED)/closure-library
|
163 | @mkdir -p $(BUILD_HOSTED)/closure-library
|
164 | @cp -r $(CLOSURE_LIB)/* $(BUILD_HOSTED)/closure-library/
|
165 | @rm -rf $(BUILD_HOSTED)/ol/ol
|
166 | @mkdir -p $(BUILD_HOSTED)/ol/ol
|
167 | @cp -r src/ol/* $(BUILD_HOSTED)/ol/ol/
|
168 | @rm -rf $(BUILD_HOSTED)/ol.ext
|
169 | @mkdir -p $(BUILD_HOSTED)/ol.ext
|
170 | @cp -r build/ol.ext/* $(BUILD_HOSTED)/ol.ext/
|
171 |
|
172 | $(BUILD_EXAMPLES): $(EXAMPLES) package.json
|
173 | @mkdir -p $(@D)
|
174 | @node tasks/build-examples.js
|
175 |
|
176 | build/timestamps/check-%-timestamp: $(BUILD_HOSTED)/examples/%.html \
|
177 | $(BUILD_HOSTED)/examples/%.js \
|
178 | $(filter $(BUILD_HOSTED)/examples/resources/%,$(BUILD_HOSTED_EXAMPLES)) \
|
179 | $(filter $(BUILD_HOSTED)/examples/data/%,$(BUILD_HOSTED_EXAMPLES)) \
|
180 | $(BUILD_HOSTED)/examples/loader.js \
|
181 | $(BUILD_HOSTED)/build/ol.js \
|
182 | $(BUILD_HOSTED)/css/ol.css
|
183 | @mkdir -p $(@D)
|
184 | node tasks/check-example.js $<
|
185 | @touch $@
|
186 |
|
187 | build/compiled-examples/all.js: $(EXAMPLES_JS)
|
188 | @mkdir -p $(@D)
|
189 | @python bin/combine-examples.py $^ > $@
|
190 |
|
191 | build/compiled-examples/all.combined.js: config/examples-all.json build/compiled-examples/all.js \
|
192 | $(SRC_JS) $(SRC_SHADER_JS) \
|
193 | build/timestamps/node-modules-timestamp
|
194 | @mkdir -p $(@D)
|
195 | node tasks/build.js $< $@
|
196 |
|
197 | build/compiled-examples/%.json: config/example.json build/examples/%.js \
|
198 | build/timestamps/node-modules-timestamp
|
199 | @mkdir -p $(@D)
|
200 | @sed -e 's|{{id}}|$*|' $< > $@
|
201 |
|
202 | build/compiled-examples/%.combined.js: build/compiled-examples/%.json \
|
203 | $(SRC_JS) $(SRC_SHADER_JS) \
|
204 | build/timestamps/node-modules-timestamp
|
205 | @mkdir -p $(@D)
|
206 | node tasks/build.js $< $@
|
207 |
|
208 | build/timestamps/jsdoc-$(BRANCH)-timestamp: config/jsdoc/api/index.md \
|
209 | config/jsdoc/api/conf.json $(SRC_JS) \
|
210 | $(SRC_SHADER_JS) \
|
211 | $(shell find config/jsdoc/api/template -type f) \
|
212 | build/timestamps/node-modules-timestamp
|
213 | @mkdir -p $(@D)
|
214 | @rm -rf $(BUILD_HOSTED)/apidoc
|
215 | ./node_modules/.bin/jsdoc config/jsdoc/api/index.md -c config/jsdoc/api/conf.json --package package.json -d $(BUILD_HOSTED)/apidoc
|
216 | @touch $@
|
217 |
|
218 | $(BUILD_HOSTED_EXAMPLES_JS): $(BUILD_HOSTED)/examples/%.js: build/examples/%.js
|
219 | @mkdir -p $(@D)
|
220 | @python bin/split-example.py $< $(@D)
|
221 |
|
222 | $(BUILD_HOSTED)/examples/loader.js: bin/loader_hosted_examples.js
|
223 | @mkdir -p $(@D)
|
224 | @cp $< $@
|
225 |
|
226 | $(BUILD_HOSTED)/examples/%: build/examples/%
|
227 | @mkdir -p $(@D)
|
228 | @cp $< $@
|
229 |
|
230 | $(BUILD_HOSTED)/build/ol.js: build/ol.js
|
231 | @mkdir -p $(@D)
|
232 | @cp $< $@
|
233 |
|
234 | $(BUILD_HOSTED)/build/ol-debug.js: build/ol-debug.js
|
235 | @mkdir -p $(@D)
|
236 | @cp $< $@
|
237 |
|
238 | $(BUILD_HOSTED)/css/ol.css: build/ol.css
|
239 | @mkdir -p $(@D)
|
240 | @cp $< $@
|
241 |
|
242 | $(BUILD_HOSTED)/build/ol-deps.js: host-libraries
|
243 | @mkdir -p $(@D)
|
244 | @python $(CLOSURE_LIB)/closure/bin/build/depswriter.py \
|
245 | --root_with_prefix "src ../../../ol" \
|
246 | --root_with_prefix "build/ol.ext ../../../ol.ext" \
|
247 | --root $(BUILD_HOSTED)/closure-library/closure/goog \
|
248 | --root_with_prefix "$(BUILD_HOSTED)/closure-library/third_party ../../third_party" \
|
249 | --output_file $@
|
250 |
|
251 | build/timestamps/eslint-timestamp: $(SRC_JS) $(SPEC_JS) $(SPEC_RENDERING_JS) \
|
252 | $(TASKS_JS) $(EXAMPLES_JS) \
|
253 | build/timestamps/node-modules-timestamp
|
254 | @mkdir -p $(@D)
|
255 | @echo "Running eslint..."
|
256 | @./node_modules/.bin/eslint tasks test test_rendering src examples
|
257 | @touch $@
|
258 |
|
259 | build/timestamps/node-modules-timestamp: package.json
|
260 | @mkdir -p $(@D)
|
261 | npm install
|
262 | @touch $@
|
263 |
|
264 | build/ol.css: css/ol.css build/timestamps/node-modules-timestamp
|
265 | @mkdir -p $(@D)
|
266 | @echo "Running cleancss..."
|
267 | @./node_modules/.bin/cleancss $< > $@
|
268 |
|
269 | build/ol.js: config/ol.json $(SRC_JS) $(SRC_SHADER_JS) \
|
270 | build/timestamps/node-modules-timestamp
|
271 | @mkdir -p $(@D)
|
272 | node tasks/build.js $< $@
|
273 | @$(STAT_UNCOMPRESSED) $@
|
274 | @cp $@ /tmp/
|
275 | @gzip /tmp/ol.js
|
276 | @$(STAT_COMPRESSED) /tmp/ol.js.gz
|
277 | @rm /tmp/ol.js.gz
|
278 |
|
279 | build/ol.js.map: config/ol.json $(SRC_JS) $(SRC_SHADER_JS) \
|
280 | build/timestamps/node-modules-timestamp
|
281 | @mkdir -p $(@D)
|
282 | node tasks/build.js $< $@
|
283 |
|
284 | build/ol-debug.js: config/ol-debug.json $(SRC_JS) $(SRC_SHADER_JS) \
|
285 | build/timestamps/node-modules-timestamp
|
286 | @mkdir -p $(@D)
|
287 | node tasks/build.js $< $@
|
288 | @$(STAT_UNCOMPRESSED) $@
|
289 | @cp $@ /tmp/
|
290 | @gzip /tmp/ol-debug.js
|
291 | @$(STAT_COMPRESSED) /tmp/ol-debug.js.gz
|
292 | @rm /tmp/ol-debug.js.gz
|
293 |
|
294 | build/test_requires.js: $(SPEC_JS) $(SRC_JS)
|
295 | @mkdir -p $(@D)
|
296 | @node tasks/generate-requires.js $^ > $@
|
297 |
|
298 | build/test_rendering_requires.js: $(SPEC_RENDERING_JS)
|
299 | @mkdir -p $(@D)
|
300 | @node tasks/generate-requires.js $^ > $@
|
301 |
|
302 | %shader.js: %shader.glsl src/ol/webgl/shader.mustache bin/pyglslunit.py build/timestamps/node-modules-timestamp
|
303 | @python bin/pyglslunit.py --input $< | ./node_modules/.bin/mustache - src/ol/webgl/shader.mustache > $@
|
304 |
|
305 | .PHONY: package
|
306 | package:
|
307 | @rm -rf build/package
|
308 | @cp -r package build
|
309 | @cd ./src && cp -r ol/* ../build/package
|
310 | @rm build/package/typedefs.js
|
311 | @cp css/ol.css build/package
|
312 | ./node_modules/.bin/jscodeshift --transform transforms/module.js build/package
|
313 | npm run lint-package
|