forked from WebThingsIO/webthing-node
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
256 lines (189 loc) · 5.25 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
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
#!/bin/make -f
# -*- makefile -*-
# SPDX-License-Identifier: MPL-2.0
#{
# Copyright 2018-present Samsung Electronics France SAS, and other contributors
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.*
#}
default: all
tmp_dir ?= tmp
runtime ?= iotjs
export runtime
eslint ?= node_modules/eslint/bin/eslint.js
babel ?= ./node_modules/.bin/babel
babelrc ?= ${CURDIR}/extra/${runtime}/.babelrc
babel_stamp_file += ${CURDIR}/extra/${runtime}/babel.txt
babel_out_dir ?= tmp/babel/runtime/${runtime}/dist
srcs_dir ?= lib example
srcs ?= $(wildcard *.js lib/*.js | sort | uniq)
run_args ?=
run_timeout ?= 10
main_src ?= example/multiple-things.js
NODE_PATH := .:${NODE_PATH}
export NODE_PATH
help:
@echo "## Usage: "
@echo "# make retranspile"
all: build
setup/%:
${@F}
node_modules: package.json
npm install
package-lock.json: package.json
rm -fv "$@"
npm install
ls "$@"
setup/node: node_modules
@echo "NODE_PATH=$${NODE_PATH}"
node --version
npm --version
setup: setup/${runtime}
build/%: setup
@echo "log: $@: $^"
build/node: setup node_modules eslint
build: build/${runtime}
run/%: ${main_src} build
${@F} $< ${run_args}
run/npm: ${main_src} setup
npm start
run: run/${runtime}
clean:
rm -rf ${tmp_dir}
cleanall: clean
rm -f *~
distclean: cleanall
rm -rf node_modules
${tmp_dir}/rule/test/pid/%: ${main_src} build
@mkdir -p "${@D}"
${@F} $< & echo $$! > "$@"
sleep ${run_timeout}
cat $@
test/%: ${tmp_dir}/rule/test/pid/%
cat $<
curl http://localhost:8888 \
|| curl -I http://localhost:8888 \
kill $$(cat $<) ||:
kill -9 $$(cat $<) ||:
test/npm: package.json
npm test
test: test/${runtime}
start: run
start/board/%: example/platform/Makefile example/platform/board/%.js
${MAKE} -C ${<D} board/${@F}
check/%: ${srcs}
${MAKE} setup
@echo "log: SHELL=$${SHELL}"
status=0 ; \
for src in $^; do \
echo "log: check: $${src}: ($@)" ; \
${@F} $${src} \
&& echo "log: check: $${src}: OK" \
|| status=1 ; \
done ; \
exit $${status}
check/npm:
npm run lint
check: check/${runtime}
git/commit/%:
-git commit -sam "${runtime}: WIP: About to do something (${@})"
eslint: .eslintrc.js ${eslint}
@rm -rf tmp/dist
${eslint} --no-color --fix . ||:
${eslint} --no-color .
git diff --exit-code
eslint/setup: node_modules
ls ${eslint} || npm install eslint-plugin-node eslint
${eslint} --version
${eslint}:
ls $@ || make eslint/setup
touch $@
.eslintrc.js: ${eslint}
ls $@ || $< --init
lint/%: eslint
lint: lint/${runtime}
### Babel
#
babel/setup: Makefile
ls node_modules || ${MAKE} node_modules
-git commit -sam "WIP: babel: About to setup"
npm install @babel/cli
npm install @babel/core
npm install @babel/plugin-transform-arrow-functions
npm install @babel/plugin-transform-block-scoping
npm install @babel/plugin-transform-template-literals
@echo "TODO: npm install @babel/plugin-transform-for-of"
@echo "TODO: npm install @babel/plugin-transform-classes"
npm install @babel/preset-env
-git commit -sam "WIP: babel: Installed tools"
${babel}:
ls $@ || ${MAKE} babel/setup
${babelrc}: ${babel}
ls $@ || echo '{ "ignore": [ "node_modules/**.js" ] }' > $@
cat $@
${babel_out_dir}: ${babelrc} ${babel}
${babel} \
--no-babelrc \
--config-file "$<" \
--delete-dir-on-start \
--ignore 'node_modules/**,dist/**' \
-d "${CURDIR}/$@/" \
--verbose \
.
ls ${babel_out_dir}
babel/run: ${babel_out_dir}
ls $<
babel/build: babel/run
rsync -avx ${babel_out_dir}/ ./
@rm -rf ${babel_out_dir}
${babel_stamp_file}: ${srcs_dir}
${MAKE} babel/build
${babel} --version | tee ${babel_stamp_file}
babel/runtime/%: ${babel_stamp_file}
ls $<
babel/runtime: babel/runtime/${runtime}
babel/commit/%: git/commit/babel/build/${runtime}
${MAKE} babel/runtime/${runtime}
-git commit -sm "${runtime}: babel: Transpiled (${@})" ${srcs_dir} ${srcs}
-git add "${babel_stamp_file}"
-git commit -sm "${runtime}: babel: Add stamp file" "${babel_stamp_file}"
babel/commit: babel/commit/${runtime}
babel: babel/runtime
sync
babel/done:
ls ${babel_stamp_file} && exit 0 || echo "log: Assuming it is not transpiled yet"
ls ${babel_stamp_file} || ${MAKE} ${@D}/commit
ls ${babel_stamp_file}
babel/clean:
rm -rf ${babel_out_dir}
babel/rebuild: babel/clean babel/build
transpile/revert:
@echo "TODO: move $@ (babel) patches (2) for ${runtime} at end of list"
-git commit -sam "WIP: babel: About to $@"
git rebase -i remotes/upstream/master
git revert HEAD
git revert HEAD~2
transpile: git/commit/transpile/${runtime} lint/${runtime} babel/commit
retranspile: babel/done transpile/revert
${MAKE} transpile
git rebase -i remotes/upstream/master
### IoT.js related rules:
setup/iotjs/devel: ${eslint} ${babel}
setup/iotjs:
iotjs \
|| echo "log: Should have printed iotjs's usage..."
-which iotjs
build/iotjs/devel: setup lint ${babel_stamp_file}
echo "log: $@: $^"
build/iotjs: setup babel/done
lint/iotjs/eslint:
if [ ! -e ${babel_stamp_file} ] ; then make eslint ; fi
lint/iotjs/babel:
if [ -e ${babel_stamp_file} ] ; then make babel/run ; fi
lint/iotjs: lint/iotjs/eslint lint/iotjs/babel
#babel/runtime/iotjs:
# ${MAKE} babel/runtime/node
# ${MAKE} babel/runtime/iotjs
babel/runtimes: babel/runtime/iotjs babel/runtime/node