From cdb8c1b44db998cfafb2018da885877a535d54f9 Mon Sep 17 00:00:00 2001 From: Daniel Bevenius Date: Tue, 7 Aug 2018 13:09:04 +0200 Subject: [PATCH] build: extract common parts from addon .buildstamp This commit extracts common parts from the targets test/addons/.buildstamp, and test/addons-napi/.buildstamp to reduce some duplication. PR-URL: https://github.com/nodejs/node/pull/22171 Reviewed-By: Jon Moss --- Makefile | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/Makefile b/Makefile index fc4a094656a452..f1242bbb30fc73 100644 --- a/Makefile +++ b/Makefile @@ -333,19 +333,26 @@ ADDONS_BINDING_SOURCES := \ $(filter-out test/addons/??_*/*.cc, $(wildcard test/addons/*/*.cc)) \ $(filter-out test/addons/??_*/*.h, $(wildcard test/addons/*/*.h)) +ADDONS_PREREQS := config.gypi \ + deps/npm/node_modules/node-gyp/package.json tools/build-addons.js \ + deps/uv/include/*.h deps/v8/include/*.h \ + src/node.h src/node_buffer.h src/node_object_wrap.h src/node_version.h + +define run_build_addons +env npm_config_loglevel=$(LOGLEVEL) npm_config_nodedir="$$PWD" \ + npm_config_python="$(PYTHON)" $(NODE) "$$PWD/tools/build-addons" \ + "$$PWD/deps/npm/node_modules/node-gyp/bin/node-gyp.js" \ + $1 +touch $2 +endef + # Implicitly depends on $(NODE_EXE), see the build-addons rule for rationale. # Depends on node-gyp package.json so that build-addons is (re)executed when # node-gyp is updated as part of an npm update. -test/addons/.buildstamp: config.gypi \ - deps/npm/node_modules/node-gyp/package.json tools/build-addons.js \ +test/addons/.buildstamp: $(ADDONS_PREREQS) \ $(ADDONS_BINDING_GYPS) $(ADDONS_BINDING_SOURCES) \ - deps/uv/include/*.h deps/v8/include/*.h \ - src/node.h src/node_buffer.h src/node_object_wrap.h src/node_version.h \ test/addons/.docbuildstamp - env npm_config_loglevel=$(LOGLEVEL) npm_config_nodedir="$$PWD" \ - npm_config_python="$(PYTHON)" $(NODE) "$$PWD/tools/build-addons" \ - "$$PWD/deps/npm/node_modules/node-gyp/bin/node-gyp.js" "$$PWD/test/addons" - touch $@ + @$(call run_build_addons,"$$PWD/test/addons",$@) .PHONY: build-addons # .buildstamp needs $(NODE_EXE) but cannot depend on it @@ -366,17 +373,10 @@ ADDONS_NAPI_BINDING_SOURCES := \ $(filter-out test/addons-napi/??_*/*.h, $(wildcard test/addons-napi/*/*.h)) # Implicitly depends on $(NODE_EXE), see the build-addons-napi rule for rationale. -test/addons-napi/.buildstamp: config.gypi \ - deps/npm/node_modules/node-gyp/package.json tools/build-addons.js \ +test/addons-napi/.buildstamp: $(ADDONS_PREREQS) \ $(ADDONS_NAPI_BINDING_GYPS) $(ADDONS_NAPI_BINDING_SOURCES) \ - deps/uv/include/*.h deps/v8/include/*.h \ - src/node.h src/node_buffer.h src/node_object_wrap.h src/node_version.h \ src/node_api.h src/node_api_types.h - env npm_config_loglevel=$(LOGLEVEL) npm_config_nodedir="$$PWD" \ - npm_config_python="$(PYTHON)" $(NODE) "$$PWD/tools/build-addons" \ - "$$PWD/deps/npm/node_modules/node-gyp/bin/node-gyp.js" \ - "$$PWD/test/addons-napi" - touch $@ + @$(call run_build_addons,"$$PWD/test/addons-napi",$@) .PHONY: build-addons-napi # .buildstamp needs $(NODE_EXE) but cannot depend on it