@@ -234,6 +234,18 @@ ADDONS_BINDING_SOURCES := \
234234 $(filter-out test/addons/??_* /* .cc, $(wildcard test/addons/* /* .cc) ) \
235235 $(filter-out test/addons/??_* /* .h, $(wildcard test/addons/* /* .h) )
236236
237+ define test_addons
238+ @for dirname in $(1 ) /*/; do \
239+ printf "\nBuilding addon $$PWD/$$dirname\n" ; \
240+ env MAKEFLAGS="-j1" $(NODE ) deps/npm/node_modules/node-gyp/bin/node-gyp \
241+ --loglevel=$(LOGLEVEL ) rebuild \
242+ --python="$(PYTHON ) " \
243+ --directory="$$PWD/$$dirname" \
244+ --nodedir="$$PWD" || exit 1 ; \
245+ done
246+ touch $(2 )
247+ endef
248+
237249# Implicitly depends on $(NODE_EXE), see the build-addons rule for rationale.
238250# Depends on node-gyp package.json so that build-addons is (re)executed when
239251# node-gyp is updated as part of an npm update.
@@ -243,17 +255,7 @@ test/addons/.buildstamp: config.gypi \
243255 deps/uv/include/* .h deps/v8/include/* .h \
244256 src/node.h src/node_buffer.h src/node_object_wrap.h src/node_version.h \
245257 test/addons/.docbuildstamp
246- # Cannot use $(wildcard test/addons/*/) here, it's evaluated before
247- # embedded addons have been generated from the documentation.
248- @for dirname in test/addons/*/; do \
249- printf "\nBuilding addon $$PWD/$$dirname\n" ; \
250- env MAKEFLAGS="-j1" $(NODE) deps/npm/node_modules/node-gyp/bin/node-gyp \
251- --loglevel=$(LOGLEVEL) rebuild \
252- --python="$(PYTHON)" \
253- --directory="$$PWD/$$dirname" \
254- --nodedir="$$PWD" || exit 1 ; \
255- done
256- touch $@
258+ $(call test_addons, $(@D ) , $@ )
257259
258260# .buildstamp and .docbuildstamp need $(NODE_EXE) but cannot depend on it
259261# directly because it calls make recursively. The parent make cannot know
@@ -278,17 +280,7 @@ test/addons-napi/.buildstamp: config.gypi \
278280 deps/uv/include/* .h deps/v8/include/* .h \
279281 src/node.h src/node_buffer.h src/node_object_wrap.h src/node_version.h \
280282 src/node_api.h src/node_api_types.h
281- # Cannot use $(wildcard test/addons-napi/*/) here, it's evaluated before
282- # embedded addons have been generated from the documentation.
283- @for dirname in test/addons-napi/*/; do \
284- printf "\nBuilding addon $$PWD/$$dirname\n" ; \
285- env MAKEFLAGS="-j1" $(NODE) deps/npm/node_modules/node-gyp/bin/node-gyp \
286- --loglevel=$(LOGLEVEL) rebuild \
287- --python="$(PYTHON)" \
288- --directory="$$PWD/$$dirname" \
289- --nodedir="$$PWD" || exit 1 ; \
290- done
291- touch $@
283+ $(call test_addons, $(@D ) , $@ )
292284
293285# .buildstamp and .docbuildstamp need $(NODE_EXE) but cannot depend on it
294286# directly because it calls make recursively. The parent make cannot know
0 commit comments