10 STAGINGSERVER ?= node-www
12 OSTYPE := $(shell uname -s | tr '[A-Z]' '[a-z]')
14 COV_SKIP_TESTS ?= core_line_numbers.js,testFinalizer.js,test_function/test.js
16 GNUMAKEFLAGS += --no-print-directory
23 PARALLEL_ARGS = -j $(JOBS)
29 TAP_V8 := --junitout $(PWD)/v8-tap.xml
30 TAP_V8_INTL := --junitout $(PWD)/v8-intl-tap.xml
31 TAP_V8_BENCHMARKS := --junitout $(PWD)/v8-benchmarks-tap.xml
34 V8_TEST_OPTIONS = $(V8_EXTRA_TEST_OPTIONS)
36 V8_BUILD_OPTIONS += i18nsupport=off
39 ifeq ($(OSTYPE), darwin)
40 GCOV = xcrun llvm-cov gcov
43 BUILDTYPE_LOWER := $(shell echo $(BUILDTYPE) | tr '[A-Z]' '[a-z]')
46 EXEEXT := $(shell $(PYTHON) -c \
47 "import sys; print('.exe' if sys.platform == 'win32' else '')")
49 NODE_EXE = node$(EXEEXT)
51 NODE_G_EXE = node_g$(EXEEXT)
52 NPM ?= ./deps/npm/bin/npm-cli.js
54 # Flags for packaging.
55 BUILD_DOWNLOAD_FLAGS ?= --download=all
56 BUILD_INTL_FLAGS ?= --with-intl=full-icu
57 BUILD_RELEASE_FLAGS ?= $(BUILD_DOWNLOAD_FLAGS) $(BUILD_INTL_FLAGS)
59 # Default to quiet/pretty builds.
60 # To do verbose builds, run `make V=1` or set the V environment variable.
63 # Use -e to double check in case it's a broken link
64 # Use $(PWD) so we can cd to anywhere before calling this
66 if [ -x $(PWD)/$(NODE) ] && [ -e $(PWD)/$(NODE) ]; then \
67 $(PWD)/$(NODE) $(1); \
68 elif [ -x `which node` ] && [ -e `which node` ] && [ `which node` ]; then \
71 echo "No available node, cannot run \"node $(1)\""; \
76 # BUILDTYPE=Debug builds both release and debug builds. If you want to compile
77 # just the debug build, run `make -C out BUILDTYPE=Debug` instead.
78 ifeq ($(BUILDTYPE),Release)
79 all: $(NODE_EXE) ## Default target, builds node in out/Release/node.
81 all: $(NODE_EXE) $(NODE_G_EXE)
85 # To add a target to the help, add a double comment (##) on the target line.
86 help: ## Print help for targets with comments.
87 @printf "For more targets and info see the comments in the Makefile.\n\n"
88 @grep -E '^[a-zA-Z0-9._-]+:.*?## .*$$' Makefile | sort | \
89 awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-15s\033[0m %s\n", $$1, $$2}'
91 # The .PHONY is needed to ensure that we recursively use the out/Makefile
92 # to check for changes.
93 .PHONY: $(NODE_EXE) $(NODE_G_EXE)
95 # The -r/-L check stops it recreating the link if it is already in place,
96 # otherwise $(NODE_EXE) being a .PHONY target means it is always re-run.
97 # Without the check there is a race condition between the link being deleted
98 # and recreated which can break the addons build when running test-ci
99 # See comments on the build-addons target for some more info
100 ifeq ($(BUILD_WITH), make)
101 $(NODE_EXE): build_type:=Release
102 $(NODE_G_EXE): build_type:=Debug
103 $(NODE_EXE) $(NODE_G_EXE): config.gypi out/Makefile
104 $(MAKE) -C out BUILDTYPE=${build_type} V=$(V)
105 if [ ! -r $@ -o ! -L $@ ]; then \
106 ln -fs out/${build_type}/$(NODE_EXE) $@; fi
108 ifeq ($(BUILD_WITH), ninja)
110 NINJA_ARGS := $(NINJA_ARGS) -v
113 NINJA_ARGS := $(NINJA_ARGS) -j$(JOBS)
115 NINJA_ARGS := $(NINJA_ARGS) $(filter -j%,$(MAKEFLAGS))
117 $(NODE_EXE): config.gypi out/Release/build.ninja
118 ninja -C out/Release $(NINJA_ARGS)
119 if [ ! -r $@ -o ! -L $@ ]; then ln -fs out/Release/$(NODE_EXE) $@; fi
121 $(NODE_G_EXE): config.gypi out/Debug/build.ninja
122 ninja -C out/Debug $(NINJA_ARGS)
123 if [ ! -r $@ -o ! -L $@ ]; then ln -fs out/Debug/$(NODE_EXE) $@; fi
125 $(NODE_EXE) $(NODE_G_EXE):
126 echo This Makefile currently only supports building with 'make' or 'ninja'
131 ifeq ($(BUILDTYPE),Debug)
132 CONFIG_FLAGS += --debug
135 .PHONY: with-code-cache
137 echo "'with-code-cache' target is a noop"
139 .PHONY: test-code-cache
140 test-code-cache: with-code-cache
141 echo "'test-code-cache' target is a noop"
143 out/Makefile: config.gypi common.gypi node.gyp \
144 deps/uv/uv.gyp deps/llhttp/llhttp.gyp deps/zlib/zlib.gyp \
145 tools/v8_gypfiles/toolchain.gypi tools/v8_gypfiles/features.gypi \
146 tools/v8_gypfiles/inspector.gypi tools/v8_gypfiles/v8.gyp
147 $(PYTHON) tools/gyp_node.py -f make
149 # node_version.h is listed because the N-API version is taken from there
150 # and included in config.gypi
151 config.gypi: configure configure.py src/node_version.h
152 @if [ -x config.status ]; then \
155 echo Missing or stale $@, please run ./$<; \
160 install: all ## Installs node into $PREFIX (default=/usr/local).
161 $(PYTHON) tools/install.py $@ '$(DESTDIR)' '$(PREFIX)'
164 uninstall: ## Uninstalls node from $PREFIX (default=/usr/local).
165 $(PYTHON) tools/install.py $@ '$(DESTDIR)' '$(PREFIX)'
168 clean: ## Remove build artifacts.
169 $(RM) -r out/Makefile $(NODE_EXE) $(NODE_G_EXE) out/$(BUILDTYPE)/$(NODE_EXE) \
170 out/$(BUILDTYPE)/node.exp
171 @if [ -d out ]; then $(FIND) out/ -name '*.o' -o -name '*.a' -o -name '*.d' | xargs $(RM) -r; fi
172 $(RM) -r node_modules
173 @if [ -d deps/icu ]; then echo deleting deps/icu; $(RM) -r deps/icu; fi
176 $(MAKE) test-addons-clean
177 $(MAKE) bench-addons-clean
181 # Next one is legacy remove this at some point
188 $(RM) config.gypi icu_config.gypi config_fips.gypi
190 $(RM) -r $(NODE_EXE) $(NODE_G_EXE)
191 $(RM) -r node_modules
193 $(RM) -r deps/icu4c*.tgz deps/icu4c*.zip deps/icu-tmp
194 $(RM) $(BINARYTAR).* $(TARBALL).*
199 .PHONY: coverage-clean
200 # Remove files generated by running coverage, put the non-instrumented lib back
203 if [ -d lib_ ]; then $(RM) -r lib; mv lib_ lib; fi
204 $(RM) -r node_modules
206 $(RM) -r out/$(BUILDTYPE)/.coverage
207 $(RM) out/$(BUILDTYPE)/obj.target/node/gen/*.gcda
208 $(RM) out/$(BUILDTYPE)/obj.target/node/src/*.gcda
209 $(RM) out/$(BUILDTYPE)/obj.target/node/src/tracing/*.gcda
210 $(RM) out/$(BUILDTYPE)/obj.target/node/gen/*.gcno
211 $(RM) out/$(BUILDTYPE)/obj.target/node/src/*.gcno
212 $(RM) out/$(BUILDTYPE)/obj.target/node/src/tracing/*.gcno
213 $(RM) out/$(BUILDTYPE)/obj.target/cctest/src/*.gcno
214 $(RM) out/$(BUILDTYPE)/obj.target/cctest/test/cctest/*.gcno
215 $(RM) out/$(BUILDTYPE)/obj.target/embedtest/src/*.gcno
216 $(RM) out/$(BUILDTYPE)/obj.target/embedtest/test/embedding/*.gcno
219 # Build and test with code coverage reporting. Leave the lib directory
220 # instrumented for any additional runs the user may want to make.
221 # For C++ coverage reporting, this needs to be run in conjunction with configure
222 # --coverage. html coverage reports will be created under coverage/
223 # Related CI job: node-test-commit-linux-coverage
224 coverage: coverage-test ## Run the tests and generate a coverage report.
226 .PHONY: coverage-build
228 -$(MAKE) coverage-build-js
229 if [ ! -d gcovr ]; then git clone -b 3.4 --depth=1 \
230 --single-branch https://github.com/gcovr/gcovr.git; fi
231 if [ ! -d build ]; then git clone --depth=1 \
232 --single-branch https://github.com/nodejs/build.git; fi
233 if [ ! -f gcovr/scripts/gcovr.orig ]; then \
234 (cd gcovr && patch -N -p1 < \
235 "$(CURDIR)/build/jenkins/scripts/coverage/gcovr-patches-3.4.diff"); fi
238 .PHONY: coverage-build-js
240 mkdir -p node_modules
241 if [ ! -d node_modules/c8 ]; then \
242 $(NODE) ./deps/npm install c8 --no-save --no-package-lock;\
245 .PHONY: coverage-test
246 coverage-test: coverage-build
247 $(RM) out/$(BUILDTYPE)/obj.target/node/src/*.gcda
248 $(RM) out/$(BUILDTYPE)/obj.target/node/src/*/*.gcda
249 $(RM) out/$(BUILDTYPE)/obj.target/node_lib/src/*.gcda
250 $(RM) out/$(BUILDTYPE)/obj.target/node_lib/src/*/*.gcda
251 -NODE_V8_COVERAGE=out/$(BUILDTYPE)/.coverage \
252 TEST_CI_ARGS="$(TEST_CI_ARGS) --type=coverage" $(MAKE) $(COVTESTS)
253 $(MAKE) coverage-report-js
254 -(cd out && "../gcovr/scripts/gcovr" \
255 --gcov-exclude='.*\b(deps|usr|out|cctest|embedding)\b' -v \
256 -r Release/obj.target --html --html-detail -o ../coverage/cxxcoverage.html \
257 --gcov-executable="$(GCOV)")
258 @echo -n "Javascript coverage %: "
259 @grep -B1 Lines coverage/index.html | head -n1 \
260 | sed 's/<[^>]*>//g'| sed 's/ //g'
261 @echo -n "C++ coverage %: "
262 @grep -A3 Lines coverage/cxxcoverage.html | grep style \
263 | sed 's/<[^>]*>//g'| sed 's/ //g'
265 COV_REPORT_OPTIONS = --reporter=html \
266 --temp-directory=out/$(BUILDTYPE)/.coverage --omit-relative=false \
267 --resolve=./lib --exclude="benchmark/" --exclude="deps/" --exclude="test/" --exclude="tools/" \
269 ifdef COV_ENFORCE_THRESHOLD
270 COV_REPORT_OPTIONS += --check-coverage --lines=$(COV_ENFORCE_THRESHOLD)
273 .PHONY: coverage-report-js
275 $(NODE) ./node_modules/.bin/c8 report $(COV_REPORT_OPTIONS)
278 # Runs the C++ tests using the built `cctest` executable.
280 @out/$(BUILDTYPE)/$@ --gtest_filter=$(GTEST_FILTER)
281 @out/$(BUILDTYPE)/embedtest "require('./test/embedding/test-embedding.js')"
285 ifeq (,$(wildcard out/$(BUILDTYPE)/cctest))
286 $(error Please run 'make cctest' first)
288 @out/$(BUILDTYPE)/cctest --gtest_list_tests
291 # Related CI job: node-test-commit-v8-linux
292 # Rebuilds deps/v8 as a git tree, pulls its third-party dependencies, and
295 tools/make-v8.sh $(V8_ARCH).$(BUILDTYPE_LOWER) $(V8_BUILD_OPTIONS)
298 jstest: build-addons build-js-native-api-tests build-node-api-tests ## Runs addon tests and JS tests
299 $(PYTHON) tools/test.py $(PARALLEL_ARGS) --mode=$(BUILDTYPE_LOWER) \
300 --skip-tests=$(CI_SKIP_TESTS) \
306 @$(PYTHON) -m unittest discover -s ./test/tools
308 .PHONY: coverage-run-js
310 $(RM) -r out/$(BUILDTYPE)/.coverage
311 $(MAKE) coverage-build-js
312 -NODE_V8_COVERAGE=out/$(BUILDTYPE)/.coverage CI_SKIP_TESTS=$(COV_SKIP_TESTS) \
313 TEST_CI_ARGS="$(TEST_CI_ARGS) --type=coverage" $(MAKE) jstest
314 $(MAKE) coverage-report-js
317 # This does not run tests of third-party libraries inside deps.
318 test: all ## Runs default tests, linters, and builds docs.
321 $(MAKE) -s build-addons
322 $(MAKE) -s build-js-native-api-tests
323 $(MAKE) -s build-node-api-tests
328 test-only: all ## For a quick test, does not run linter or build docs.
330 $(MAKE) build-js-native-api-tests
331 $(MAKE) build-node-api-tests
336 # Used by `make coverage-test`
339 $(MAKE) build-js-native-api-tests
340 $(MAKE) build-node-api-tests
342 CI_SKIP_TESTS=$(COV_SKIP_TESTS) $(MAKE) jstest
345 $(PYTHON) tools/test.py $(PARALLEL_ARGS) --mode=$(BUILDTYPE_LOWER) parallel
348 $(PYTHON) tools/test.py $(PARALLEL_ARGS) --mode=$(BUILDTYPE_LOWER) --valgrind sequential parallel message
350 test-check-deopts: all
351 $(PYTHON) tools/test.py $(PARALLEL_ARGS) --mode=$(BUILDTYPE_LOWER) --check-deopts parallel sequential
353 DOCBUILDSTAMP_PREREQS = tools/doc/addon-verify.js doc/api/addons.md
356 DOCBUILDSTAMP_PREREQS := $(DOCBUILDSTAMP_PREREQS) out/$(BUILDTYPE)/node.exp
359 node_use_openssl = $(call available-node,"-p" \
360 "process.versions.openssl != undefined")
361 test/addons/.docbuildstamp: $(DOCBUILDSTAMP_PREREQS) tools/doc/node_modules
362 @if [ "$(shell $(node_use_openssl))" != "true" ]; then \
363 echo "Skipping .docbuildstamp (no crypto)"; \
365 $(RM) -r test/addons/??_*/; \
366 [ -x $(NODE) ] && $(NODE) $< || node $< ; \
370 ADDONS_BINDING_GYPS := \
371 $(filter-out test/addons/??_*/binding.gyp, \
372 $(wildcard test/addons/*/binding.gyp))
374 ADDONS_BINDING_SOURCES := \
375 $(filter-out test/addons/??_*/*.cc, $(wildcard test/addons/*/*.cc)) \
376 $(filter-out test/addons/??_*/*.h, $(wildcard test/addons/*/*.h))
378 ADDONS_PREREQS := config.gypi \
379 deps/npm/node_modules/node-gyp/package.json tools/build-addons.js \
380 deps/uv/include/*.h deps/v8/include/*.h \
381 src/node.h src/node_buffer.h src/node_object_wrap.h src/node_version.h
383 define run_build_addons
384 env npm_config_loglevel=$(LOGLEVEL) npm_config_nodedir="$$PWD" \
385 npm_config_python="$(PYTHON)" $(NODE) "$$PWD/tools/build-addons" \
386 "$$PWD/deps/npm/node_modules/node-gyp/bin/node-gyp.js" \
391 # Implicitly depends on $(NODE_EXE), see the build-addons rule for rationale.
392 # Depends on node-gyp package.json so that build-addons is (re)executed when
393 # node-gyp is updated as part of an npm update.
394 test/addons/.buildstamp: $(ADDONS_PREREQS) \
395 $(ADDONS_BINDING_GYPS) $(ADDONS_BINDING_SOURCES) \
396 test/addons/.docbuildstamp
397 @$(call run_build_addons,"$$PWD/test/addons",$@)
400 # .buildstamp needs $(NODE_EXE) but cannot depend on it
401 # directly because it calls make recursively. The parent make cannot know
402 # if the subprocess touched anything so it pessimistically assumes that
403 # .buildstamp is out of date and need a rebuild.
404 # Just goes to show that recursive make really is harmful...
405 # TODO(bnoordhuis) Force rebuild after gyp update.
406 build-addons: | $(NODE_EXE) test/addons/.buildstamp
408 JS_NATIVE_API_BINDING_GYPS := \
409 $(filter-out test/js-native-api/??_*/binding.gyp, \
410 $(wildcard test/js-native-api/*/binding.gyp))
412 JS_NATIVE_API_BINDING_SOURCES := \
413 $(filter-out test/js-native-api/??_*/*.c, $(wildcard test/js-native-api/*/*.c)) \
414 $(filter-out test/js-native-api/??_*/*.cc, $(wildcard test/js-native-api/*/*.cc)) \
415 $(filter-out test/js-native-api/??_*/*.h, $(wildcard test/js-native-api/*/*.h))
417 # Implicitly depends on $(NODE_EXE), see the build-js-native-api-tests rule for rationale.
418 test/js-native-api/.buildstamp: $(ADDONS_PREREQS) \
419 $(JS_NATIVE_API_BINDING_GYPS) $(JS_NATIVE_API_BINDING_SOURCES) \
420 src/node_api.h src/node_api_types.h src/js_native_api.h \
421 src/js_native_api_types.h src/js_native_api_v8.h src/js_native_api_v8_internals.h
422 @$(call run_build_addons,"$$PWD/test/js-native-api",$@)
424 .PHONY: build-js-native-api-tests
425 # .buildstamp needs $(NODE_EXE) but cannot depend on it
426 # directly because it calls make recursively. The parent make cannot know
427 # if the subprocess touched anything so it pessimistically assumes that
428 # .buildstamp is out of date and need a rebuild.
429 # Just goes to show that recursive make really is harmful...
430 # TODO(bnoordhuis) Force rebuild after gyp or node-gyp update.
431 build-js-native-api-tests: | $(NODE_EXE) test/js-native-api/.buildstamp
433 NODE_API_BINDING_GYPS := \
434 $(filter-out test/node-api/??_*/binding.gyp, \
435 $(wildcard test/node-api/*/binding.gyp))
437 NODE_API_BINDING_SOURCES := \
438 $(filter-out test/node-api/??_*/*.c, $(wildcard test/node-api/*/*.c)) \
439 $(filter-out test/node-api/??_*/*.cc, $(wildcard test/node-api/*/*.cc)) \
440 $(filter-out test/node-api/??_*/*.h, $(wildcard test/node-api/*/*.h))
442 # Implicitly depends on $(NODE_EXE), see the build-node-api-tests rule for rationale.
443 test/node-api/.buildstamp: $(ADDONS_PREREQS) \
444 $(NODE_API_BINDING_GYPS) $(NODE_API_BINDING_SOURCES) \
445 src/node_api.h src/node_api_types.h src/js_native_api.h \
446 src/js_native_api_types.h src/js_native_api_v8.h src/js_native_api_v8_internals.h
447 @$(call run_build_addons,"$$PWD/test/node-api",$@)
449 .PHONY: build-node-api-tests
450 # .buildstamp needs $(NODE_EXE) but cannot depend on it
451 # directly because it calls make recursively. The parent make cannot know
452 # if the subprocess touched anything so it pessimistically assumes that
453 # .buildstamp is out of date and need a rebuild.
454 # Just goes to show that recursive make really is harmful...
455 # TODO(bnoordhuis) Force rebuild after gyp or node-gyp update.
456 build-node-api-tests: | $(NODE_EXE) test/node-api/.buildstamp
458 BENCHMARK_NAPI_BINDING_GYPS := $(wildcard benchmark/napi/*/binding.gyp)
460 BENCHMARK_NAPI_BINDING_SOURCES := \
461 $(wildcard benchmark/napi/*/*.c) \
462 $(wildcard benchmark/napi/*/*.cc) \
463 $(wildcard benchmark/napi/*/*.h)
465 benchmark/napi/.buildstamp: $(ADDONS_PREREQS) \
466 $(BENCHMARK_NAPI_BINDING_GYPS) $(BENCHMARK_NAPI_BINDING_SOURCES)
467 @$(call run_build_addons,"$$PWD/benchmark/napi",$@)
469 .PHONY: clear-stalled
471 @echo "Clean up any leftover processes but don't error if found."
472 ps awwx | grep Release/node | grep -v grep | cat
473 @PS_OUT=`ps awwx | grep Release/node | grep -v grep | awk '{print $$1}'`; \
474 if [ "$${PS_OUT}" ]; then \
475 echo $${PS_OUT} | xargs kill -9; \
478 test-build: | all build-addons build-js-native-api-tests build-node-api-tests
480 test-build-js-native-api: all build-js-native-api-tests
482 test-build-node-api: all build-node-api-tests
485 test-all: test-build ## Run default tests with both Debug and Release builds.
486 $(PYTHON) tools/test.py $(PARALLEL_ARGS) --mode=debug,release
488 test-all-valgrind: test-build
489 $(PYTHON) tools/test.py $(PARALLEL_ARGS) --mode=debug,release --valgrind
491 .PHONY: test-all-suites
492 test-all-suites: | clear-stalled test-build bench-addons-build doc-only ## Run all test suites.
493 $(PYTHON) tools/test.py $(PARALLEL_ARGS) --mode=$(BUILDTYPE_LOWER) test/*
496 NATIVE_SUITES ?= addons js-native-api node-api
497 # CI_* variables should be kept synchronized with the ones in vcbuild.bat
498 CI_NATIVE_SUITES ?= $(NATIVE_SUITES) benchmark
499 CI_JS_SUITES ?= $(JS_SUITES)
500 ifeq ($(node_use_openssl), false)
506 .PHONY: test-ci-native
507 # Build and test addons without building anything else
508 # Related CI job: node-test-commit-arm-fanned
509 test-ci-native: LOGLEVEL := info
510 test-ci-native: | benchmark/napi/.buildstamp test/addons/.buildstamp test/js-native-api/.buildstamp test/node-api/.buildstamp
511 $(PYTHON) tools/test.py $(PARALLEL_ARGS) -p tap --logfile test.tap \
512 --mode=$(BUILDTYPE_LOWER) --flaky-tests=$(FLAKY_TESTS) \
513 $(TEST_CI_ARGS) $(CI_NATIVE_SUITES)
516 # This target should not use a native compiler at all
517 # Related CI job: node-test-commit-arm-fanned
518 test-ci-js: | clear-stalled
519 $(PYTHON) tools/test.py $(PARALLEL_ARGS) -p tap --logfile test.tap \
520 --mode=$(BUILDTYPE_LOWER) --flaky-tests=$(FLAKY_TESTS) \
521 $(TEST_CI_ARGS) $(CI_JS_SUITES)
522 @echo "Clean up any leftover processes, error if found."
523 ps awwx | grep Release/node | grep -v grep | cat
524 @PS_OUT=`ps awwx | grep Release/node | grep -v grep | awk '{print $$1}'`; \
525 if [ "$${PS_OUT}" ]; then \
526 echo $${PS_OUT} | xargs kill -9; exit 1; \
530 # Related CI jobs: most CI tests, excluding node-test-commit-arm-fanned
531 test-ci: LOGLEVEL := info
532 test-ci: | clear-stalled bench-addons-build build-addons build-js-native-api-tests build-node-api-tests doc-only
533 out/Release/cctest --gtest_output=xml:out/junit/cctest.xml
534 $(PYTHON) tools/test.py $(PARALLEL_ARGS) -p tap --logfile test.tap \
535 --mode=$(BUILDTYPE_LOWER) --flaky-tests=$(FLAKY_TESTS) \
536 $(TEST_CI_ARGS) $(CI_JS_SUITES) $(CI_NATIVE_SUITES) $(CI_DOC)
537 out/Release/embedtest 'require("./test/embedding/test-embedding.js")'
538 @echo "Clean up any leftover processes, error if found."
539 ps awwx | grep Release/node | grep -v grep | cat
540 @PS_OUT=`ps awwx | grep Release/node | grep -v grep | awk '{print $$1}'`; \
541 if [ "$${PS_OUT}" ]; then \
542 echo $${PS_OUT} | xargs kill -9; exit 1; \
546 # Prepare the build for running the tests.
547 # Related CI jobs: most CI tests, excluding node-test-commit-arm-fanned
549 $(PYTHON) ./configure --verbose $(CONFIG_FLAGS)
553 # Run by CI tests, exceptions:
554 # - node-test-commit-arm-fanned (Raspberry Pis), where the binaries are
555 # cross-compiled, then transferred elsewhere to run different subsets
556 # of tests. See `test-ci-native` and `test-ci-js`.
557 # - node-test-commit-linux-coverage: where the build and the tests need
558 # to be instrumented, see `coverage`.
560 # Using -j1 as the sub target in `test-ci` already have internal parallelism.
561 # Refs: https://github.com/nodejs/node/pull/23733
565 test-release: test-build
566 $(PYTHON) tools/test.py $(PARALLEL_ARGS) --mode=$(BUILDTYPE_LOWER)
568 test-debug: test-build
569 $(PYTHON) tools/test.py $(PARALLEL_ARGS) --mode=debug
571 test-message: test-build
572 $(PYTHON) tools/test.py $(PARALLEL_ARGS) message
575 $(PYTHON) tools/test.py $(PARALLEL_ARGS) wpt
577 test-simple: | cctest # Depends on 'all'.
578 $(PYTHON) tools/test.py $(PARALLEL_ARGS) parallel sequential
581 $(PYTHON) tools/test.py $(PARALLEL_ARGS) pummel
584 $(PYTHON) tools/test.py $(PARALLEL_ARGS) internet
586 test-node-inspect: $(NODE_EXE)
587 USE_EMBEDDED_NODE_INSPECT=1 $(NODE) tools/test-npm-package \
588 --install deps/node-inspect test
590 test-benchmark: | bench-addons-build
591 $(PYTHON) tools/test.py $(PARALLEL_ARGS) benchmark
593 test-tick-processor: all
594 $(PYTHON) tools/test.py $(PARALLEL_ARGS) tick-processor
596 .PHONY: test-hash-seed
597 # Verifies the hash seed used by V8 for hashing is random.
599 $(NODE) test/pummel/test-hash-seed.js
602 test-doc: doc-only lint ## Builds, lints, and verifies the docs.
603 @if [ "$(shell $(node_use_openssl))" != "true" ]; then \
604 echo "Skipping test-doc (no crypto)"; \
606 $(PYTHON) tools/test.py $(PARALLEL_ARGS) doctool; \
608 $(NODE) tools/doc/checkLinks.js .
610 test-known-issues: all
611 $(PYTHON) tools/test.py $(PARALLEL_ARGS) known_issues
613 # Related CI job: node-test-npm
614 test-npm: $(NODE_EXE) ## Run the npm test suite on deps/npm.
615 $(NODE) tools/test-npm-package --install --logfile=test-npm.tap deps/npm test-node
617 test-npm-publish: $(NODE_EXE)
618 npm_package_config_publishtest=true $(NODE) deps/npm/test/run.js
620 .PHONY: test-js-native-api
621 test-js-native-api: test-build-js-native-api
622 $(PYTHON) tools/test.py $(PARALLEL_ARGS) --mode=$(BUILDTYPE_LOWER) js-native-api
624 .PHONY: test-js-native-api-clean
625 test-js-native-api-clean:
626 $(RM) -r test/js-native-api/*/build
627 $(RM) test/js-native-api/.buildstamp
629 .PHONY: test-node-api
630 test-node-api: test-build-node-api
631 $(PYTHON) tools/test.py $(PARALLEL_ARGS) --mode=$(BUILDTYPE_LOWER) node-api
633 .PHONY: test-node-api-clean
635 $(RM) -r test/node-api/*/build
636 $(RM) test/node-api/.buildstamp
639 test-addons: test-build test-js-native-api test-node-api
640 $(PYTHON) tools/test.py $(PARALLEL_ARGS) --mode=$(BUILDTYPE_LOWER) addons
642 .PHONY: test-addons-clean
644 $(RM) -r test/addons/??_*/
645 $(RM) -r test/addons/*/build
646 $(RM) test/addons/.buildstamp test/addons/.docbuildstamp
647 $(MAKE) test-js-native-api-clean
648 $(MAKE) test-node-api-clean
651 $(PYTHON) tools/test.py $(PARALLEL_ARGS) --mode=$(BUILDTYPE_LOWER) async-hooks
653 test-with-async-hooks:
655 $(MAKE) build-js-native-api-tests
656 $(MAKE) build-node-api-tests
658 NODE_TEST_WITH_ASYNC_HOOKS=1 $(PYTHON) tools/test.py $(PARALLEL_ARGS) --mode=$(BUILDTYPE_LOWER) \
665 .PHONY: test-v8-benchmarks
667 .PHONY: test-v8-updates
668 ifneq ("","$(wildcard deps/v8/tools/run-tests.py)")
669 # Related CI job: node-test-commit-v8-linux
670 test-v8: v8 ## Runs the V8 test suite on deps/v8.
671 deps/v8/tools/run-tests.py --gn --arch=$(V8_ARCH) \
672 --mode=$(BUILDTYPE_LOWER) $(V8_TEST_OPTIONS) \
673 mjsunit cctest debugger inspector message preparser \
675 @echo Testing hash seed
676 $(MAKE) test-hash-seed
679 deps/v8/tools/run-tests.py --gn --arch=$(V8_ARCH) \
680 --mode=$(BUILDTYPE_LOWER) intl \
683 test-v8-benchmarks: v8
684 deps/v8/tools/run-tests.py --gn --arch=$(V8_ARCH) --mode=$(BUILDTYPE_LOWER) \
689 $(PYTHON) tools/test.py $(PARALLEL_ARGS) --mode=$(BUILDTYPE_LOWER) v8-updates
691 test-v8-all: test-v8 test-v8-intl test-v8-benchmarks test-v8-updates
694 test-v8 test-v8-intl test-v8-benchmarks test-v8-all:
695 @echo "Testing v8 is not available through the source tarball."
696 @echo "Use the git repo instead:" \
697 "$ git clone https://github.com/nodejs/node.git"
700 apidoc_dirs = out/doc out/doc/api out/doc/api/assets
701 apidoc_sources = $(wildcard doc/api/*.md)
702 apidocs_html = $(addprefix out/,$(apidoc_sources:.md=.html))
703 apidocs_json = $(addprefix out/,$(apidoc_sources:.md=.json))
705 apiassets = $(subst api_assets,api/assets,$(addprefix out/,$(wildcard doc/api_assets/*)))
707 tools/doc/node_modules: tools/doc/package.json
708 @if [ "$(shell $(node_use_openssl))" != "true" ]; then \
709 echo "Skipping tools/doc/node_modules (no crypto)"; \
711 cd tools/doc && $(call available-node,$(run-npm-ci)) \
715 doc-only: tools/doc/node_modules \
716 $(apidoc_dirs) $(apiassets) ## Builds the docs with the local or the global Node.js binary.
717 @if [ "$(shell $(node_use_openssl))" != "true" ]; then \
718 echo "Skipping doc-only (no crypto)"; \
720 $(MAKE) out/doc/api/all.html out/doc/api/all.json; \
724 doc: $(NODE_EXE) doc-only
729 # If it's a source tarball, doc/api already contains the generated docs.
730 # Just copy everything under doc/api over.
733 cp -r doc/api out/doc
735 # If it's a source tarball, assets are already in doc/api/assets
738 if [ -d doc/api/assets ]; then cp -r doc/api/assets out/doc/api; fi;
740 # If it's not a source tarball, we need to copy assets from doc/api_assets
741 out/doc/api/assets/%: doc/api_assets/% | out/doc/api/assets
742 @cp $< $@ ; $(RM) out/doc/api/assets/README.md
745 run-npm-ci = $(PWD)/$(NPM) ci
747 LINK_DATA = out/doc/apilinks.json
748 VERSIONS_DATA = out/previous-doc-versions.json
749 gen-api = tools/doc/generate.js --node-version=$(FULLVERSION) \
750 --apilinks=$(LINK_DATA) $< --output-directory=out/doc/api \
751 --versions-file=$(VERSIONS_DATA)
752 gen-apilink = tools/doc/apilinks.js $(LINK_DATA) $(wildcard lib/*.js)
754 $(LINK_DATA): $(wildcard lib/*.js) tools/doc/apilinks.js | out/doc
755 $(call available-node, $(gen-apilink))
757 # Regenerate previous versions data if the current version changes
758 $(VERSIONS_DATA): CHANGELOG.md src/node_version.h tools/doc/versions.js
759 $(call available-node, tools/doc/versions.js $@)
761 out/doc/api/%.json out/doc/api/%.html: doc/api/%.md tools/doc/generate.js \
762 tools/doc/markdown.js tools/doc/html.js tools/doc/json.js \
763 tools/doc/apilinks.js $(VERSIONS_DATA) | $(LINK_DATA) out/doc/api
764 $(call available-node, $(gen-api))
766 out/doc/api/all.html: $(apidocs_html) tools/doc/allhtml.js \
767 tools/doc/apilinks.js | out/doc/api
768 $(call available-node, tools/doc/allhtml.js)
770 out/doc/api/all.json: $(apidocs_json) tools/doc/alljson.js | out/doc/api
771 $(call available-node, tools/doc/alljson.js)
774 docopen: out/doc/api/all.html
775 @$(PYTHON) -mwebbrowser file://$(abspath $<)
778 docserve: $(apidocs_html) $(apiassets)
779 @$(PYTHON) -m http.server 8000 --bind 127.0.0.1 --directory out/doc/api
784 $(RM) "$(VERSIONS_DATA)"
786 RAWVER=$(shell $(PYTHON) tools/getnodeversion.py)
789 # For nightly builds, you must set DISTTYPE to "nightly", "next-nightly" or
790 # "custom". For the nightly and next-nightly case, you need to set DATESTRING
791 # and COMMIT in order to properly name the build.
792 # For the rc case you need to set CUSTOMTAG to an appropriate CUSTOMTAG number
797 ifeq ($(DISTTYPE),release)
798 FULLVERSION=$(VERSION)
799 else # ifeq ($(DISTTYPE),release)
800 ifeq ($(DISTTYPE),custom)
802 $(error CUSTOMTAG is not set for DISTTYPE=custom)
803 endif # ifndef CUSTOMTAG
805 else # ifeq ($(DISTTYPE),custom)
807 $(error DATESTRING is not set for nightly)
808 endif # ifndef DATESTRING
810 $(error COMMIT is not set for nightly)
811 endif # ifndef COMMIT
812 ifneq ($(DISTTYPE),nightly)
813 ifneq ($(DISTTYPE),next-nightly)
814 $(error DISTTYPE is not release, custom, nightly or next-nightly)
815 endif # ifneq ($(DISTTYPE),next-nightly)
816 endif # ifneq ($(DISTTYPE),nightly)
817 TAG=$(DISTTYPE)$(DATESTRING)$(COMMIT)
818 endif # ifeq ($(DISTTYPE),custom)
819 FULLVERSION=$(VERSION)-$(TAG)
820 endif # ifeq ($(DISTTYPE),release)
822 DISTTYPEDIR ?= $(DISTTYPE)
823 RELEASE=$(shell sed -ne 's/\#define NODE_VERSION_IS_RELEASE \([01]\)/\1/p' src/node_version.h)
824 PLATFORM=$(shell uname | tr '[:upper:]' '[:lower:]')
825 NPMVERSION=v$(shell cat deps/npm/package.json | grep '"version"' | sed 's/^[^:]*: "\([^"]*\)",.*/\1/')
827 UNAME_M=$(shell uname -m)
828 ifeq ($(findstring x86_64,$(UNAME_M)),x86_64)
831 ifeq ($(findstring amd64,$(UNAME_M)),amd64)
834 ifeq ($(findstring ppc64,$(UNAME_M)),ppc64)
837 ifeq ($(findstring ppc,$(UNAME_M)),ppc)
840 ifeq ($(findstring s390x,$(UNAME_M)),s390x)
843 ifeq ($(findstring s390,$(UNAME_M)),s390)
846 ifeq ($(findstring arm,$(UNAME_M)),arm)
849 ifeq ($(findstring aarch64,$(UNAME_M)),aarch64)
852 ifeq ($(findstring powerpc,$(shell uname -p)),powerpc)
865 ifeq ($(DESTCPU),x64)
868 ifeq ($(DESTCPU),arm)
871 ifeq ($(DESTCPU),arm64)
874 ifeq ($(DESTCPU),ppc64)
877 ifeq ($(DESTCPU),ppc)
880 ifeq ($(DESTCPU),s390)
883 ifeq ($(DESTCPU),s390x)
895 # node and v8 use different arch names (e.g. node 'x86' vs v8 'ia32').
896 # pass the proper v8 arch name to $V8_ARCH based on user-specified $DESTCPU.
897 ifeq ($(DESTCPU),x86)
900 V8_ARCH ?= $(DESTCPU)
904 # enforce "x86" over "ia32" as the generally accepted way of referring to 32-bit intel
908 ifeq ($(DESTCPU),ia32)
912 TARNAME=node-$(FULLVERSION)
913 TARBALL=$(TARNAME).tar
914 # Custom user-specified variation, use it directly
916 BINARYNAME=$(TARNAME)-$(PLATFORM)-$(ARCH)-$(VARIATION)
918 BINARYNAME=$(TARNAME)-$(PLATFORM)-$(ARCH)
920 BINARYTAR=$(BINARYNAME).tar
921 # OSX doesn't have xz installed by default, http://macpkg.sourceforge.net/
922 HAS_XZ ?= $(shell which xz > /dev/null 2>&1; [ $$? -eq 0 ] && echo 1 || echo 0)
923 # Supply SKIP_XZ=1 to explicitly skip .tar.xz creation
925 XZ = $(shell [ $(HAS_XZ) -eq 1 -a $(SKIP_XZ) -eq 0 ] && echo 1 || echo 0)
928 MACOSOUTDIR=out/macos
932 @echo "SKIP_XZ=1 supplied, skipping .tar.xz creation"
938 @echo "No xz command, cannot continue"
944 release-only: check-xz
945 @if [ "$(DISTTYPE)" = "release" ] && `grep -q REPLACEME doc/api/*.md`; then \
946 echo 'Please update REPLACEME tags in the following doc/api/*.md files (See doc/guides/releases.md):\n' ; \
947 REPLACEMES="$(shell grep -l REPLACEME doc/api/*.md)" ; \
948 echo "$$REPLACEMES\n" | tr " " "\n" ; \
951 @if [ "$(DISTTYPE)" = "release" ] && \
952 `grep -q DEP...X doc/api/deprecations.md`; then \
953 echo 'Please update DEP...X in doc/api/deprecations.md (See doc/guides/releases.md)' ; \
956 @if [ "$(shell git status --porcelain | egrep -v '^\?\? ')" = "" ]; then \
960 echo "The git repository is not clean." >&2 ; \
961 echo "Please commit changes before building release tarball." >&2 ; \
963 git status --porcelain | egrep -v '^\?\?' >&2 ; \
967 @if [ "$(DISTTYPE)" != "release" -o "$(RELEASE)" = "1" ]; then \
971 echo "#NODE_VERSION_IS_RELEASE is set to $(RELEASE)." >&2 ; \
972 echo "Did you remember to update src/node_version.h?" >&2 ; \
978 $(RM) -r $(MACOSOUTDIR)
979 mkdir -p $(MACOSOUTDIR)/installer/productbuild
980 cat tools/macos-installer/productbuild/distribution.xml.tmpl \
981 | sed -E "s/\\{nodeversion\\}/$(FULLVERSION)/g" \
982 | sed -E "s/\\{npmversion\\}/$(NPMVERSION)/g" \
983 >$(MACOSOUTDIR)/installer/productbuild/distribution.xml ; \
985 @for dirname in tools/macos-installer/productbuild/Resources/*/; do \
986 lang=$$(basename $$dirname) ; \
987 mkdir -p $(MACOSOUTDIR)/installer/productbuild/Resources/$$lang ; \
988 printf "Found localization directory $$dirname\n" ; \
989 cat $$dirname/welcome.html.tmpl \
990 | sed -E "s/\\{nodeversion\\}/$(FULLVERSION)/g" \
991 | sed -E "s/\\{npmversion\\}/$(NPMVERSION)/g" \
992 >$(MACOSOUTDIR)/installer/productbuild/Resources/$$lang/welcome.html ; \
993 cat $$dirname/conclusion.html.tmpl \
994 | sed -E "s/\\{nodeversion\\}/$(FULLVERSION)/g" \
995 | sed -E "s/\\{npmversion\\}/$(NPMVERSION)/g" \
996 >$(MACOSOUTDIR)/installer/productbuild/Resources/$$lang/conclusion.html ; \
998 $(PYTHON) ./configure \
1001 --release-urlbase=$(RELEASE_URLBASE) \
1002 $(CONFIG_FLAGS) $(BUILD_RELEASE_FLAGS)
1003 $(MAKE) install V=$(V) DESTDIR=$(MACOSOUTDIR)/dist/node
1004 SIGN="$(CODESIGN_CERT)" PKGDIR="$(MACOSOUTDIR)/dist/node/usr/local" bash \
1005 tools/osx-codesign.sh
1006 mkdir -p $(MACOSOUTDIR)/dist/npm/usr/local/lib/node_modules
1007 mkdir -p $(MACOSOUTDIR)/pkgs
1008 mv $(MACOSOUTDIR)/dist/node/usr/local/lib/node_modules/npm \
1009 $(MACOSOUTDIR)/dist/npm/usr/local/lib/node_modules
1010 unlink $(MACOSOUTDIR)/dist/node/usr/local/bin/npm
1011 unlink $(MACOSOUTDIR)/dist/node/usr/local/bin/npx
1012 $(NODE) tools/license2rtf.js < LICENSE > \
1013 $(MACOSOUTDIR)/installer/productbuild/Resources/license.rtf
1014 cp doc/osx_installer_logo.png $(MACOSOUTDIR)/installer/productbuild/Resources
1015 pkgbuild --version $(FULLVERSION) \
1016 --identifier org.nodejs.node.pkg \
1017 --root $(MACOSOUTDIR)/dist/node $(MACOSOUTDIR)/pkgs/node-$(FULLVERSION).pkg
1018 pkgbuild --version $(NPMVERSION) \
1019 --identifier org.nodejs.npm.pkg \
1020 --root $(MACOSOUTDIR)/dist/npm \
1021 --scripts ./tools/macos-installer/pkgbuild/npm/scripts \
1022 $(MACOSOUTDIR)/pkgs/npm-$(NPMVERSION).pkg
1023 productbuild --distribution $(MACOSOUTDIR)/installer/productbuild/distribution.xml \
1024 --resources $(MACOSOUTDIR)/installer/productbuild/Resources \
1025 --package-path $(MACOSOUTDIR)/pkgs ./$(PKG)
1026 SIGN="$(PRODUCTSIGN_CERT)" PKG="$(PKG)" bash tools/osx-productsign.sh
1027 bash tools/osx-notarize.sh $(FULLVERSION)
1030 # Builds the macOS installer for releases.
1033 # Note: this is strictly for release builds on release machines only.
1035 ssh $(STAGINGSERVER) "mkdir -p nodejs/$(DISTTYPEDIR)/$(FULLVERSION)"
1036 chmod 664 $(TARNAME).pkg
1037 scp -p $(TARNAME).pkg $(STAGINGSERVER):nodejs/$(DISTTYPEDIR)/$(FULLVERSION)/$(TARNAME).pkg
1038 ssh $(STAGINGSERVER) "touch nodejs/$(DISTTYPEDIR)/$(FULLVERSION)/$(TARNAME).pkg.done"
1040 $(TARBALL): release-only doc-only
1041 git checkout-index -a -f --prefix=$(TARNAME)/
1042 mkdir -p $(TARNAME)/doc/api
1043 cp doc/node.1 $(TARNAME)/doc/node.1
1044 cp -r out/doc/api/* $(TARNAME)/doc/api/
1045 $(RM) -r $(TARNAME)/.editorconfig
1046 $(RM) -r $(TARNAME)/.git*
1047 $(RM) -r $(TARNAME)/.mailmap
1048 $(RM) -r $(TARNAME)/deps/openssl/openssl/demos
1049 $(RM) -r $(TARNAME)/deps/openssl/openssl/doc
1050 $(RM) -r $(TARNAME)/deps/openssl/openssl/test
1051 $(RM) -r $(TARNAME)/deps/uv/docs
1052 $(RM) -r $(TARNAME)/deps/uv/samples
1053 $(RM) -r $(TARNAME)/deps/uv/test
1054 $(RM) -r $(TARNAME)/deps/v8/samples
1055 $(RM) -r $(TARNAME)/deps/v8/tools/profviz
1056 $(RM) -r $(TARNAME)/deps/v8/tools/run-tests.py
1057 $(RM) -r $(TARNAME)/doc/images # too big
1058 $(RM) -r $(TARNAME)/test*.tap
1059 $(RM) -r $(TARNAME)/tools/cpplint.py
1060 $(RM) -r $(TARNAME)/tools/eslint-rules
1061 $(RM) -r $(TARNAME)/tools/license-builder.sh
1062 $(RM) -r $(TARNAME)/tools/node_modules
1063 $(RM) -r $(TARNAME)/tools/osx-*
1064 $(RM) -r $(TARNAME)/tools/osx-pkg.pmdoc
1065 find $(TARNAME)/deps/v8/test/* -type d ! -regex '.*/test/torque$$' | xargs $(RM) -r
1066 find $(TARNAME)/deps/v8/test -type f ! -regex '.*/test/torque/.*' | xargs $(RM)
1067 find $(TARNAME)/deps/zlib/contrib/* -type d ! -regex '.*/contrib/optimizations$$' | xargs $(RM) -r
1068 find $(TARNAME)/ -name ".eslint*" -maxdepth 2 | xargs $(RM)
1069 find $(TARNAME)/ -type l | xargs $(RM) # annoying on windows
1070 tar -cf $(TARNAME).tar $(TARNAME)
1072 gzip -c -f -9 $(TARNAME).tar > $(TARNAME).tar.gz
1074 xz -c -f -$(XZ_COMPRESSION) $(TARNAME).tar > $(TARNAME).tar.xz
1076 $(RM) $(TARNAME).tar
1079 tar: $(TARBALL) ## Create a source tarball.
1081 # Note: this is strictly for release builds on release machines only.
1083 ssh $(STAGINGSERVER) "mkdir -p nodejs/$(DISTTYPEDIR)/$(FULLVERSION)"
1084 chmod 664 $(TARNAME).tar.gz
1085 scp -p $(TARNAME).tar.gz $(STAGINGSERVER):nodejs/$(DISTTYPEDIR)/$(FULLVERSION)/$(TARNAME).tar.gz
1086 ssh $(STAGINGSERVER) "touch nodejs/$(DISTTYPEDIR)/$(FULLVERSION)/$(TARNAME).tar.gz.done"
1088 chmod 664 $(TARNAME).tar.xz
1089 scp -p $(TARNAME).tar.xz $(STAGINGSERVER):nodejs/$(DISTTYPEDIR)/$(FULLVERSION)/$(TARNAME).tar.xz
1090 ssh $(STAGINGSERVER) "touch nodejs/$(DISTTYPEDIR)/$(FULLVERSION)/$(TARNAME).tar.xz.done"
1093 # Note: this is strictly for release builds on release machines only.
1095 ssh $(STAGINGSERVER) "mkdir -p nodejs/$(DISTTYPEDIR)/$(FULLVERSION)/docs/"
1096 chmod -R ug=rw-x+X,o=r+X out/doc/
1097 scp -pr out/doc/* $(STAGINGSERVER):nodejs/$(DISTTYPEDIR)/$(FULLVERSION)/docs/
1098 ssh $(STAGINGSERVER) "touch nodejs/$(DISTTYPEDIR)/$(FULLVERSION)/docs.done"
1100 .PHONY: $(TARBALL)-headers
1101 $(TARBALL)-headers: release-only
1102 $(PYTHON) ./configure \
1104 --dest-cpu=$(DESTCPU) \
1106 --release-urlbase=$(RELEASE_URLBASE) \
1107 $(CONFIG_FLAGS) $(BUILD_RELEASE_FLAGS)
1108 HEADERS_ONLY=1 $(PYTHON) tools/install.py install '$(TARNAME)' '/'
1109 find $(TARNAME)/ -type l | xargs $(RM)
1110 tar -cf $(TARNAME)-headers.tar $(TARNAME)
1112 gzip -c -f -9 $(TARNAME)-headers.tar > $(TARNAME)-headers.tar.gz
1114 xz -c -f -$(XZ_COMPRESSION) $(TARNAME)-headers.tar > $(TARNAME)-headers.tar.xz
1116 $(RM) $(TARNAME)-headers.tar
1118 tar-headers: $(TARBALL)-headers ## Build the node header tarball.
1120 tar-headers-upload: tar-headers
1121 ssh $(STAGINGSERVER) "mkdir -p nodejs/$(DISTTYPEDIR)/$(FULLVERSION)"
1122 chmod 664 $(TARNAME)-headers.tar.gz
1123 scp -p $(TARNAME)-headers.tar.gz $(STAGINGSERVER):nodejs/$(DISTTYPEDIR)/$(FULLVERSION)/$(TARNAME)-headers.tar.gz
1124 ssh $(STAGINGSERVER) "touch nodejs/$(DISTTYPEDIR)/$(FULLVERSION)/$(TARNAME)-headers.tar.gz.done"
1126 chmod 664 $(TARNAME)-headers.tar.xz
1127 scp -p $(TARNAME)-headers.tar.xz $(STAGINGSERVER):nodejs/$(DISTTYPEDIR)/$(FULLVERSION)/$(TARNAME)-headers.tar.xz
1128 ssh $(STAGINGSERVER) "touch nodejs/$(DISTTYPEDIR)/$(FULLVERSION)/$(TARNAME)-headers.tar.xz.done"
1131 $(BINARYTAR): release-only
1132 $(RM) -r $(BINARYNAME)
1133 $(RM) -r out/deps out/Release
1134 $(PYTHON) ./configure \
1136 --dest-cpu=$(DESTCPU) \
1138 --release-urlbase=$(RELEASE_URLBASE) \
1139 $(CONFIG_FLAGS) $(BUILD_RELEASE_FLAGS)
1140 $(MAKE) install DESTDIR=$(BINARYNAME) V=$(V) PORTABLE=1
1141 cp README.md $(BINARYNAME)
1142 cp LICENSE $(BINARYNAME)
1143 cp CHANGELOG.md $(BINARYNAME)
1144 ifeq ($(OSTYPE),darwin)
1145 SIGN="$(CODESIGN_CERT)" PKGDIR="$(BINARYNAME)" bash tools/osx-codesign.sh
1147 tar -cf $(BINARYNAME).tar $(BINARYNAME)
1148 $(RM) -r $(BINARYNAME)
1149 gzip -c -f -9 $(BINARYNAME).tar > $(BINARYNAME).tar.gz
1151 xz -c -f -$(XZ_COMPRESSION) $(BINARYNAME).tar > $(BINARYNAME).tar.xz
1153 $(RM) $(BINARYNAME).tar
1156 # This requires NODE_VERSION_IS_RELEASE defined as 1 in src/node_version.h.
1157 binary: $(BINARYTAR) ## Build release binary tarballs.
1159 # Note: this is strictly for release builds on release machines only.
1160 binary-upload: binary
1161 ssh $(STAGINGSERVER) "mkdir -p nodejs/$(DISTTYPEDIR)/$(FULLVERSION)"
1162 chmod 664 $(TARNAME)-$(OSTYPE)-$(ARCH).tar.gz
1163 scp -p $(TARNAME)-$(OSTYPE)-$(ARCH).tar.gz $(STAGINGSERVER):nodejs/$(DISTTYPEDIR)/$(FULLVERSION)/$(TARNAME)-$(OSTYPE)-$(ARCH).tar.gz
1164 ssh $(STAGINGSERVER) "touch nodejs/$(DISTTYPEDIR)/$(FULLVERSION)/$(TARNAME)-$(OSTYPE)-$(ARCH).tar.gz.done"
1166 chmod 664 $(TARNAME)-$(OSTYPE)-$(ARCH).tar.xz
1167 scp -p $(TARNAME)-$(OSTYPE)-$(ARCH).tar.xz $(STAGINGSERVER):nodejs/$(DISTTYPEDIR)/$(FULLVERSION)/$(TARNAME)-$(OSTYPE)-$(ARCH).tar.xz
1168 ssh $(STAGINGSERVER) "touch nodejs/$(DISTTYPEDIR)/$(FULLVERSION)/$(TARNAME)-$(OSTYPE)-$(ARCH).tar.xz.done"
1172 bench-all: bench-addons-build
1173 @echo "Please use benchmark/run.js or benchmark/compare.js to run the benchmarks."
1176 bench: bench-addons-build
1177 @echo "Please use benchmark/run.js or benchmark/compare.js to run the benchmarks."
1179 # Build required addons for benchmark before running it.
1180 .PHONY: bench-addons-build
1181 bench-addons-build: | $(NODE_EXE) benchmark/napi/.buildstamp
1183 .PHONY: bench-addons-clean
1185 $(RM) -r benchmark/napi/*/build
1186 $(RM) benchmark/napi/.buildstamp
1188 .PHONY: lint-md-rollup
1190 $(RM) tools/.*mdlintstamp
1191 cd tools/node-lint-md-cli-rollup && npm install
1192 cd tools/node-lint-md-cli-rollup && npm run build-node
1194 .PHONY: lint-md-clean
1196 $(RM) -r tools/node-lint-md-cli-rollup/node_modules
1197 $(RM) tools/.*mdlintstamp
1199 .PHONY: lint-md-build
1201 $(warning "Deprecated no-op target 'lint-md-build'")
1203 ifeq ("$(wildcard tools/.mdlintstamp)","")
1206 LINT_MD_NEWER = -newer tools/.mdlintstamp
1209 LINT_MD_TARGETS = doc src lib benchmark test tools/doc tools/icu $(wildcard *.md)
1210 LINT_MD_FILES = $(shell $(FIND) $(LINT_MD_TARGETS) -type f \
1211 ! -path '*node_modules*' ! -path 'test/fixtures/*' -name '*.md' \
1213 run-lint-md = tools/lint-md.js -q -f --no-stdout $(LINT_MD_FILES)
1214 # Lint all changed markdown files maintained by us
1215 tools/.mdlintstamp: $(LINT_MD_FILES)
1216 @echo "Running Markdown linter..."
1217 @$(call available-node,$(run-lint-md))
1221 # Lints the markdown documents maintained by us in the codebase.
1222 lint-md: | tools/.mdlintstamp
1225 LINT_JS_TARGETS = .eslintrc.js benchmark doc lib test tools
1227 run-lint-js = tools/node_modules/eslint/bin/eslint.js --cache \
1228 --report-unused-disable-directives --ext=.js,.mjs,.md $(LINT_JS_TARGETS)
1229 run-lint-js-fix = $(run-lint-js) --fix
1233 @$(call available-node,$(run-lint-js-fix))
1236 # Note that on the CI `lint-js-ci` is run instead.
1237 # Lints the JavaScript code with eslint.
1239 @if [ "$(shell $(node_use_openssl))" != "true" ]; then \
1240 echo "Skipping $@ (no crypto)"; \
1242 echo "Running JS linter..."; \
1243 $(call available-node,$(run-lint-js)) \
1247 @echo "Please use lint-js instead of jslint"
1249 run-lint-js-ci = tools/node_modules/eslint/bin/eslint.js \
1250 --report-unused-disable-directives --ext=.js,.mjs,.md -f tap \
1251 -o test-eslint.tap $(LINT_JS_TARGETS)
1254 # On the CI the output is emitted in the TAP format.
1256 @echo "Running JS linter..."
1257 @$(call available-node,$(run-lint-js-ci))
1259 jslint-ci: lint-js-ci
1260 @echo "Please use lint-js-ci instead of jslint-ci"
1262 LINT_CPP_ADDON_DOC_FILES_GLOB = test/addons/??_*/*.cc test/addons/??_*/*.h
1263 LINT_CPP_ADDON_DOC_FILES = $(wildcard $(LINT_CPP_ADDON_DOC_FILES_GLOB))
1265 LINT_CPP_EXCLUDE += src/node_root_certs.h
1266 LINT_CPP_EXCLUDE += $(LINT_CPP_ADDON_DOC_FILES)
1267 LINT_CPP_EXCLUDE += $(wildcard test/js-native-api/??_*/*.cc test/js-native-api/??_*/*.h test/node-api/??_*/*.cc test/node-api/??_*/*.h)
1268 # These files were copied more or less verbatim from V8.
1269 LINT_CPP_EXCLUDE += src/tracing/trace_event.h src/tracing/trace_event_common.h
1271 LINT_CPP_FILES = $(filter-out $(LINT_CPP_EXCLUDE), $(wildcard \
1272 benchmark/napi/*/*.cc \
1279 test/addons/*/*.cc \
1283 test/embedding/*.cc \
1284 test/embedding/*.h \
1285 test/js-native-api/*/*.cc \
1286 test/js-native-api/*/*.h \
1287 test/node-api/*/*.cc \
1288 test/node-api/*/*.h \
1291 tools/code_cache/*.cc \
1292 tools/code_cache/*.h \
1293 tools/snapshot/*.cc \
1294 tools/snapshot/*.h \
1297 # Code blocks don't have newline at the end,
1298 # and the actual filename is generated so it won't match header guards
1299 ADDON_DOC_LINT_FLAGS=-whitespace/ending_newline,-build/header_guard
1302 cd tools/clang-format && $(call available-node,$(run-npm-ci))
1305 $(RM) -r tools/clang-format/node_modules
1307 CLANG_FORMAT_START ?= HEAD
1309 # To format staged changes:
1311 # To format HEAD~1...HEAD (latest commit):
1312 # $ CLANG_FORMAT_START=`git rev-parse HEAD~1` make format-cpp
1313 # To format diff between master and current branch head (master...HEAD):
1314 # $ CLANG_FORMAT_START=master make format-cpp
1315 format-cpp: ## Format C++ diff from $CLANG_FORMAT_START to current changes
1316 ifneq ("","$(wildcard tools/clang-format/node_modules/)")
1317 @echo "Formatting C++ diff from $(CLANG_FORMAT_START).."
1318 @$(PYTHON) tools/clang-format/node_modules/.bin/git-clang-format \
1319 --binary=tools/clang-format/node_modules/.bin/clang-format \
1321 $(CLANG_FORMAT_START) -- \
1324 @echo "clang-format is not installed."
1325 @echo "To install (requires internet access) run: $ make format-cpp-build"
1331 CPPLINT_QUIET = --quiet
1334 # Lints the C++ code with cpplint.py and checkimports.py.
1335 lint-cpp: tools/.cpplintstamp
1337 tools/.cpplintstamp: $(LINT_CPP_FILES)
1338 @echo "Running C++ linter..."
1339 @$(PYTHON) tools/cpplint.py $(CPPLINT_QUIET) $?
1340 @$(PYTHON) tools/checkimports.py $?
1343 .PHONY: lint-addon-docs
1344 lint-addon-docs: tools/.doclintstamp
1346 tools/.doclintstamp: test/addons/.docbuildstamp
1347 @echo "Running C++ linter on addon docs..."
1348 @$(PYTHON) tools/cpplint.py $(CPPLINT_QUIET) --filter=$(ADDON_DOC_LINT_FLAGS) \
1349 $(LINT_CPP_ADDON_DOC_FILES_GLOB)
1353 @echo "Please use lint-cpp instead of cpplint"
1355 .PHONY: lint-py-build
1356 # python -m pip install flake8
1357 # Try with '--system' is to overcome systems that blindly set '--user'
1359 @echo "Pip installing flake8 linter on $(shell $(PYTHON) --version)..."
1360 $(PYTHON) -m pip install --upgrade -t tools/pip/site-packages flake8 || \
1361 $(PYTHON) -m pip install --upgrade --system -t tools/pip/site-packages flake8
1363 ifneq ("","$(wildcard tools/pip/site-packages)")
1365 # Lints the Python code with flake8.
1366 # Flag the build if there are Python syntax errors or undefined names
1368 PYTHONPATH=tools/pip $(PYTHON) -m flake8 --count --show-source --statistics .
1371 @echo "Python linting with flake8 is not avalible"
1372 @echo "Run 'make lint-py-build'"
1377 ifneq ("","$(wildcard tools/node_modules/eslint/)")
1378 lint: ## Run JS, C++, MD and doc linters.
1380 $(MAKE) lint-js || EXIT_STATUS=$$? ; \
1381 $(MAKE) lint-cpp || EXIT_STATUS=$$? ; \
1382 $(MAKE) lint-addon-docs || EXIT_STATUS=$$? ; \
1383 $(MAKE) lint-md || EXIT_STATUS=$$? ; \
1385 CONFLICT_RE=^>>>>>>> [0-9A-Fa-f]+|^<<<<<<< [A-Za-z]+
1387 # Related CI job: node-test-linter
1388 lint-ci: lint-js-ci lint-cpp lint-py lint-md lint-addon-docs
1389 @if ! ( grep -IEqrs "$(CONFLICT_RE)" benchmark deps doc lib src test tools ) \
1390 && ! ( $(FIND) . -maxdepth 1 -type f | xargs grep -IEqs "$(CONFLICT_RE)" ); then \
1394 echo "Conflict marker detected in one or more files. Please fix them first." >&2 ; \
1399 @echo "Linting is not available through the source tarball."
1400 @echo "Use the git repo instead:" \
1401 "$ git clone https://github.com/nodejs/node.git"
1408 $(RM) tools/.*lintstamp
1411 HAS_DOCKER ?= $(shell which docker > /dev/null 2>&1; [ $$? -eq 0 ] && echo 1 || echo 0)
1413 ifeq ($(HAS_DOCKER), 1)
1414 DOCKER_COMMAND ?= docker run -it -v $(PWD):/node
1415 IS_IN_WORKTREE = $(shell grep '^gitdir: ' $(PWD)/.git 2>/dev/null)
1416 GIT_WORKTREE_COMMON = $(shell git rev-parse --git-common-dir)
1417 DOCKER_COMMAND += $(if $(IS_IN_WORKTREE), -v $(GIT_WORKTREE_COMMON):$(GIT_WORKTREE_COMMON))
1418 gen-openssl: ## Generate platform dependent openssl files (requires docker)
1419 docker build -t node-openssl-builder deps/openssl/config/
1420 $(DOCKER_COMMAND) node-openssl-builder make -C deps/openssl/config
1423 @echo "No docker command, cannot continue"