This repository has been archived by the owner on Jul 17, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 72
/
Makefile
213 lines (170 loc) · 7.26 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
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
# Include definition of variables that configure
# build and deploy
-include mk/config.mk
# Include the help target (what's printed when you type just
# make on command line)
-include mk/help.mk
.PHONY: all
all: showVariables lint debug release dist apache fixrights
.PHONY: ci
ci: showVariables lint debug release dist
.PHONY: build
build: guard-STAGING env .build-artefacts/requirements.timestamp appconfig
source $(RUNTIME_CONFIGURATION_FILE) && $(MAKE) src/config.$(STAGING).mako all
.PHONY: .build-artefacts/nvm-version
.build-artefacts/nvm-version: .build-artefacts/last-nvm-version
ifneq ($(LAST_NVM_VERSION),$(NVM_VERSION))
curl -o- https://raw.githubusercontent.com/creationix/nvm/$(NVM_VERSION)/install.sh | bash
endif
.PHONY: .build-artefacts/node-version
.build-artefacts/node-version: .build-artefacts/last-node-version
ifneq ($(LAST_NODE_VERSION),$(NODE_VERSION))
source $(HOME)/.bashrc && source $(NVM_DIR)/nvm.sh && nvm install $(NODE_VERSION)
endif
.PHONY: env
env: .build-artefacts/nvm-version .build-artefacts/node-version
source $(HOME)/.bashrc && source ${NVM_DIR}/nvm.sh && nvm use $(NODE_VERSION)
.PHONY: user
user:
$(MAKE) build STAGING=dev RUNTIME_CONFIGURATION_FILE=rc_user
.PHONY: dev
dev:
$(MAKE) build STAGING=dev RUNTIME_CONFIGURATION_FILE=rc_dev
.PHONY: int
int:
$(MAKE) build STAGING=int RUNTIME_CONFIGURATION_FILE=rc_int
.PHONY: prod
prod:
$(MAKE) build STAGING=prod RUNTIME_CONFIGURATION_FILE=rc_prod
# Include the handling of last values for specific variables
# (everything like .build-artefacts/last-VARNAME
-include mk/last.mk
# Include targets to create configuration files of the
# backend services (aka layerConfig)
-include mk/serviceconfig.mk
# Include targets used to get a working application in
# src/
-include mk/debug.mk
# Include targets that create a compiled and minified
# build of the application, ready to deploy
-include mk/release.mk
# Include the targets that bundle prd/ and src/ to dist/...
# in way that can be copy-pasted to and moved around in s3
# without requiring to modify files
-include mk/dist.mk
# Include targets that handle deploying (i.e. copying to
# and moving around stuff in s3, with the help of s3manage.py)
-include mk/deploy.mk
# Everything concerning installation and update of
# external libraries
-include mk/libs.mk
# Include the cleanup stuff
-include mk/clean.mk
.PHONY: lint
lint: .build-artefacts/devlibs .build-artefacts/requirements.timestamp $(SRC_JS_FILES) linttest lintpy
${ES_LINT} $(SRC_JS_FILES) --fix
linttest: .build-artefacts/devlibs .build-artefacts/requirements.timestamp
${ES_LINT} test/specs/ --fix
lintpy: .build-artefacts/requirements.timestamp ${FLAKE8_CMD} ${PYTHON_FILES}
${AUTOPEP8_CMD} --in-place --aggressive --aggressive --verbose --max-line-lengt=110 $(PYTHON_FILES)
.PHONY: testdebug
testdebug: .build-artefacts/app-whitespace.js test/karma-conf-debug.js
PHANTOMJS_BIN="$(subst ",\",${PHANTOMJS})" ${KARMA} start test/karma-conf-debug.js;
cat .build-artefacts/coverage/coverage.txt; echo;
echo "A complete report is available at ${E2E_TARGETURL}${APACHE_BASE_PATH}/src/coverage/index.html"
.PHONY: testrelease
testrelease: prd/lib/build.js test/karma-conf-release.js .build-artefacts/devlibs
PHANTOMJS_BIN="$(subst ",\",${PHANTOMJS})" ${KARMA} start test/karma-conf-release.js;
.PHONY: teste2e
teste2e: saucelabs
.PHONY: saucelabs
saucelabs: guard-SAUCELABS_USER guard-SAUCELABS_KEY .build-artefacts/requirements.timestamp lintpy
${PYTHON_CMD} test/saucelabs/test.py --url ${E2E_TARGETURL} \
--tests ${E2E_TESTS} \
--browser ${E2E_BROWSER} \
--single ${E2E_SINGLE}
.PHONY: saucelabssingle
saucelabssingle:
make saucelabs E2E_SINGLE=true E2E_TESTS=${E2E_TESTS}
.PHONY: apache
apache: apache/app.conf
.PHONY: fixrights
fixrights:
@ if grep 'geodata' /etc/group; then \
chgrp -f -R geodata . || : ; \
fi; \
chmod -f -R g+rw . || :
guard-%:
@ if test "${${*}}" = ""; then \
echo "Environment variable $* not set. Add it to your command."; \
exit 1; \
fi
define compilejs
java -jar ${CLOSURE_COMPILER} \
src/lib/$1.js \
--compilation_level SIMPLE_OPTIMIZATIONS \
--js_output_file src/lib/$1.min.js;
endef
$(CI_CONF_TIMESTAMP): $(CI_CONF_TIMESTAMP)
rm -f $(CI_CONF_FILE_TEMPLATE)*
touch $(CI_CONF_TIMESTAMP)
test/karma-conf-debug.js: test/karma-conf.mako.js ${MAKO_CMD} $(CI_CONF_TIMESTAMP)
${PYTHON_CMD} ${MAKO_CMD} --var "mode=debug" --var "ci=${CI}" $< > $@
test/karma-conf-release.js: test/karma-conf.mako.js ${MAKO_CMD} $(CI_CONF_TIMESTAMP)
${PYTHON_CMD} ${MAKO_CMD} --var "mode=release" --var "ci=${CI}" $< > $@
test/lib/angular-mocks.js test/lib/expect.js test/lib/sinon.js externs/angular.js externs/jquery.js: package.json
npm install;
cp -f node_modules/angular-mocks/angular-mocks.js test/lib/;
cp -f node_modules/expect.js/index.js test/lib/expect.js;
cp -f node_modules/sinon/pkg/sinon.js test/lib/;
cp -f node_modules/google-closure-compiler/contrib/externs/angular-1.4.js externs/angular.js;
cp -f node_modules/google-closure-compiler/contrib/externs/jquery-1.9.js externs/jquery.js;
.build-artefacts/devlibs: test/lib/angular-mocks.js \
test/lib/expect.js \
test/lib/sinon.js \
externs/angular.js \
externs/jquery.js
mkdir -p $(dir $@)
touch $@
.build-artefacts/app.js: .build-artefacts/js-files
mkdir -p $(dir $@)
java -jar ${CLOSURE_COMPILER} $(SRC_JS_FILES_FOR_COMPILER) \
--compilation_level SIMPLE_OPTIMIZATIONS \
--jscomp_error checkVars \
--externs externs/ol.js \
--externs externs/olcesium.js \
--externs externs/Cesium.externs.js \
--externs externs/slip.js \
--externs externs/angular.js \
--externs externs/jquery.js \
--js_output_file $@
$(addprefix .build-artefacts/annotated/, $(SRC_JS_FILES) src/TemplateCacheModule.js): \
.build-artefacts/annotated/%.js: %.js .build-artefacts/devlibs
mkdir -p $(dir $@)
${NG_ANNOTATE} -a $< > $@
.build-artefacts/app-whitespace.js: .build-artefacts/js-files
java -jar ${CLOSURE_COMPILER} $(SRC_JS_FILES_FOR_COMPILER) \
--compilation_level WHITESPACE_ONLY \
--formatting PRETTY_PRINT \
--js_output_file tmp
cat node_modules/google-closure-library/closure/goog/base.js tmp > $@
rm -f tmp
# closurebuilder.py complains if it cannot find a Closure base.js script, so we
# add lib/closure as a root. When compiling we remove base.js from the js files
# passed to the Closure compiler.
.build-artefacts/js-files: $(addprefix .build-artefacts/annotated/, $(SRC_JS_FILES) src/TemplateCacheModule.js) \
${PYTHON_VENV} \
node_modules/google-closure-library
${PYTHON_CMD} node_modules/google-closure-library/closure/bin/build/closurebuilder.py \
--root=.build-artefacts/annotated \
--root=node_modules/google-closure-library \
--namespace="geoadmin" \
--namespace="__ga_template_cache__" \
--output_mode=list > $@
.build-artefacts/requirements.timestamp: .build-artefacts/last-pypi-url ${PYTHON_VENV} requirements.txt
${PIP_CMD} install --index-url ${PYPI_URL} -r requirements.txt
@if [ ! -e ${PYTHON_VENV}/local ]; then \
ln -s . ${PYTHON_VENV}/local; \
fi
cp scripts/cmd.py ${PYTHON_VENV}/local/lib/python2.7/site-packages/mako/cmd.py
touch $@