Refactor build system
This rather large commit refactors the build system to solve a number of problems: - Object literal types are now declared in just one place - There are no more circular dependencies - There is no need for concealed subclasses in build-standalone mode When building in standalone mode, you need to include the source in build/src/external. This declares object literal types as externs so that their properties are not renamed. When building with the application, you need to include the source in build/src/internal. This declares object literal types as typedefs so that their properties can be renamed and removed. Note also that ol.MapOptions has been merged into ol.Map, with some renaming.
This commit is contained in:
@@ -3,6 +3,7 @@ PHANTOMJS = phantomjs
|
||||
PLOVR_JAR = bin/plovr-b254c26318c5.jar
|
||||
SPEC = $(shell find test/spec -name \*.js)
|
||||
SRC = $(shell find exports externs src/ol -name \*.js)
|
||||
INTERNAL_SRC = build/src/internal/src/requireall.js build/src/internal/src/types.js
|
||||
EXAMPLES = $(shell find examples -maxdepth 1 -name \*.html)
|
||||
comma := ,
|
||||
empty :=
|
||||
@@ -20,7 +21,7 @@ build: build/ol.css build/ol.js
|
||||
build/ol.css: build/ol.js
|
||||
touch $@
|
||||
|
||||
build/ol.js: $(PLOVR_JAR) $(SRC) base.json build/ol.json build/src/externs.js build/src/literals.js
|
||||
build/ol.js: $(PLOVR_JAR) $(SRC) base.json build/ol.json build/src/external/externs/types.js
|
||||
java -jar $(PLOVR_JAR) build build/ol.json >$@
|
||||
@echo $@ "uncompressed:" $$(wc -c <$@) bytes
|
||||
@echo $@ " compressed:" $$(gzip -9 -c <$@ | wc -c) bytes
|
||||
@@ -28,25 +29,26 @@ build/ol.js: $(PLOVR_JAR) $(SRC) base.json build/ol.json build/src/externs.js bu
|
||||
.PHONY: build-all
|
||||
build-all: build/ol-all.js
|
||||
|
||||
build/ol-all.js: $(PLOVR_JAR) $(SRC) base.json build/ol-all.json build/require-all.js build/src/externs.js build/src/literals.js
|
||||
build/ol-all.js: $(PLOVR_JAR) $(SRC) $(INTERNAL_SRC) base.json build/ol-all.json
|
||||
java -jar $(PLOVR_JAR) build build/ol-all.json >$@ || ( rm -f $@ ; false )
|
||||
|
||||
build/require-all.js: $(SRC)
|
||||
build/src/external/externs/types.js: bin/generate-src src/ol/literals.txt
|
||||
mkdir -p $(dir $@)
|
||||
bin/generate-src --externs src/ol/literals.txt >$@
|
||||
|
||||
build/src/internal/src/requireall.js: $(SRC)
|
||||
mkdir -p $(dir $@)
|
||||
( echo "goog.require('goog.dom');" ; find src/ol -name \*.js | xargs grep -rh ^goog.provide | sort | uniq | sed -e 's/provide/require/g' ) >$@
|
||||
|
||||
build/src/externs.js: bin/generate-externs src/ol/literals.txt
|
||||
build/src/internal/src/types.js: bin/generate-src src/ol/literals.txt
|
||||
mkdir -p $(dir $@)
|
||||
bin/generate-externs --externs src/ol/literals.txt >$@
|
||||
|
||||
build/src/literals.js: bin/generate-externs src/ol/literals.txt
|
||||
mkdir -p $(dir $@)
|
||||
bin/generate-externs --typedef src/ol/literals.txt >$@
|
||||
bin/generate-src --typedef src/ol/literals.txt >$@
|
||||
|
||||
.PHONY: examples
|
||||
examples: $(subst .html,.json,$(EXAMPLES))
|
||||
|
||||
examples/%.json: base.json
|
||||
@echo "{\"id\": \"$(basename $(notdir $@))\", \"inherits\": \"../base.json\", \"inputs\": \"$(subst .json,.js,$@)\"}" > $@
|
||||
examples/%.json: Makefile base.json
|
||||
echo "{\"id\": \"$(basename $(notdir $@))\", \"inherits\": \"../base.json\", \"inputs\": [\"$(subst .json,.js,$@)\", \"build/src/internal/src/types.js\"]}" > $@
|
||||
|
||||
examples/%.combined.js: $(PLOVR_JAR) base.json examples/%.js
|
||||
java -jar $(PLOVR_JAR) build $(subst .combined.js,.json,$@) >$@
|
||||
@@ -54,18 +56,18 @@ examples/%.combined.js: $(PLOVR_JAR) base.json examples/%.js
|
||||
@echo $@ " compressed:" $$(gzip -9 -c <$@ | wc -c) bytes
|
||||
|
||||
.PHONY: serve
|
||||
serve: $(PLOVR_JAR) build/require-all.js examples
|
||||
serve: $(PLOVR_JAR) $(INTERNAL_SRC) examples
|
||||
java -jar $(PLOVR_JAR) serve build/*.json examples/*.json
|
||||
|
||||
.PHONY: serve-precommit
|
||||
serve-precommit: $(PLOVR_JAR)
|
||||
serve-precommit: $(PLOVR_JAR) $(INTERNAL_SRC)
|
||||
java -jar $(PLOVR_JAR) serve build/ol.json
|
||||
|
||||
.PHONY: lint
|
||||
lint: build/lint-src-timestamp build/lint-spec-timestamp
|
||||
|
||||
build/lint-src-timestamp: $(SRC)
|
||||
gjslint --strict --limited_doc_files=$(subst $(space),$(comma),$(shell find externs -name \*.js)) $(SRC) $(filter-out $(shell find examples -name \*.combined.js),$(shell find examples -name \*.js)) && touch $@
|
||||
build/lint-src-timestamp: $(SRC) $(INTERNAL_SRC)
|
||||
gjslint --strict --limited_doc_files=$(subst $(space),$(comma),$(shell find externs -name \*.js)) $(SRC) $(INTERNAL_SRC) $(filter-out $(shell find examples -name \*.combined.js),$(shell find examples -name \*.js)) && touch $@
|
||||
|
||||
build/lint-spec-timestamp: $(SPEC)
|
||||
gjslint $(SPEC) && touch $@
|
||||
@@ -86,7 +88,7 @@ doc:
|
||||
$(JSDOC) -t doc/template -r src -d build/gh-pages/$(shell git rev-parse --abbrev-ref HEAD)/apidoc
|
||||
|
||||
.PHONY: test
|
||||
test:
|
||||
test: $(INTERNAL_SRC)
|
||||
$(PHANTOMJS) test/phantom-jasmine/run_jasmine_test.coffee test/ol.html
|
||||
|
||||
clean:
|
||||
@@ -95,8 +97,7 @@ clean:
|
||||
rm -f build/ol.css
|
||||
rm -f build/ol.js
|
||||
rm -f build/ol-all.js
|
||||
rm -f build/require-all.js
|
||||
rm -f build/src/*
|
||||
rm -rf build/src
|
||||
rm -f examples/*.json
|
||||
rm -f examples/*.combined.js
|
||||
rm -rf build/apidoc
|
||||
|
||||
Reference in New Issue
Block a user