Skip to content

Commit 944174b

Browse files
bnoordhuisrvagg
authored andcommitted
build: make ci test addons in test/addons
Make `make test-addons` part of the `make test-ci` target. Use order-only prerequisites to make generating and building the add-ons concurrency-safe when $JOBS > 1 and fudge the dependency on $(NODE_EXE) so that add-ons are only rebuilt when needed instead of all the time. PR-URL: #2428 Reviewed-By: Johan Bergström <[email protected]> Reviewed-By: Rod Vagg <[email protected]>
1 parent 3f453b2 commit 944174b

File tree

2 files changed

+33
-10
lines changed

2 files changed

+33
-10
lines changed

Makefile

+31-10
Original file line numberDiff line numberDiff line change
@@ -99,28 +99,49 @@ test/gc/node_modules/weak/build/Release/weakref.node: $(NODE_EXE)
9999
--directory="$(shell pwd)/test/gc/node_modules/weak" \
100100
--nodedir="$(shell pwd)"
101101

102-
build-addons: $(NODE_EXE)
103-
rm -rf test/addons/doc-*/
102+
# Implicitly depends on $(NODE_EXE), see the build-addons rule for rationale.
103+
test/addons/.docbuildstamp: doc/api/addons.markdown
104+
$(RM) -r test/addons/doc-*/
104105
$(NODE) tools/doc/addon-verify.js
105-
$(foreach dir, \
106-
$(sort $(dir $(wildcard test/addons/*/*.gyp))), \
107-
$(NODE) deps/npm/node_modules/node-gyp/bin/node-gyp rebuild \
108-
--directory="$(shell pwd)/$(dir)" \
109-
--nodedir="$(shell pwd)" && ) echo "build done"
106+
touch $@
107+
108+
ADDONS_BINDING_GYPS := \
109+
$(filter-out test/addons/doc-*/binding.gyp, \
110+
$(wildcard test/addons/*/binding.gyp))
111+
112+
# Implicitly depends on $(NODE_EXE), see the build-addons rule for rationale.
113+
test/addons/.buildstamp: $(ADDONS_BINDING_GYPS) | test/addons/.docbuildstamp
114+
# Cannot use $(wildcard test/addons/*/) here, it's evaluated before
115+
# embedded addons have been generated from the documentation.
116+
for dirname in test/addons/*/; do \
117+
$(NODE) deps/npm/node_modules/node-gyp/bin/node-gyp rebuild \
118+
--directory="$$PWD/$$dirname" \
119+
--nodedir="$$PWD"; \
120+
done
121+
touch $@
122+
123+
# .buildstamp and .docbuildstamp need $(NODE_EXE) but cannot depend on it
124+
# directly because it calls make recursively. The parent make cannot know
125+
# if the subprocess touched anything so it pessimistically assumes that
126+
# .buildstamp and .docbuildstamp are out of date and need a rebuild.
127+
# Just goes to show that recursive make really is harmful...
128+
# TODO(bnoordhuis) Force rebuild after gyp or node-gyp update.
129+
build-addons: $(NODE_EXE) test/addons/.buildstamp
110130

111131
test-gc: all test/gc/node_modules/weak/build/Release/weakref.node
112132
$(PYTHON) tools/test.py --mode=release gc
113133

114-
test-build: all build-addons
134+
test-build: | all build-addons
115135

116136
test-all: test-build test/gc/node_modules/weak/build/Release/weakref.node
117137
$(PYTHON) tools/test.py --mode=debug,release
118138

119139
test-all-valgrind: test-build
120140
$(PYTHON) tools/test.py --mode=debug,release --valgrind
121141

122-
test-ci:
123-
$(PYTHON) tools/test.py -p tap --logfile test.tap --mode=release message parallel sequential
142+
test-ci: | build-addons
143+
$(PYTHON) tools/test.py -p tap --logfile test.tap --mode=release \
144+
addons message parallel sequential
124145

125146
test-release: test-build
126147
$(PYTHON) tools/test.py --mode=release

test/addons/.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
.buildstamp
2+
.docbuildstamp
13
Makefile
24
*.Makefile
35
*.mk

0 commit comments

Comments
 (0)