xref: /third_party/node/Makefile (revision 1cb0ef41)
11cb0ef41Sopenharmony_ci-include config.mk
21cb0ef41Sopenharmony_ci
31cb0ef41Sopenharmony_ciBUILDTYPE ?= Release
41cb0ef41Sopenharmony_ciPYTHON ?= python3
51cb0ef41Sopenharmony_ciDESTDIR ?=
61cb0ef41Sopenharmony_ciSIGN ?=
71cb0ef41Sopenharmony_ciPREFIX ?= /usr/local
81cb0ef41Sopenharmony_ciFLAKY_TESTS ?= run
91cb0ef41Sopenharmony_ciTEST_CI_ARGS ?=
101cb0ef41Sopenharmony_ciSTAGINGSERVER ?= node-www
111cb0ef41Sopenharmony_ciLOGLEVEL ?= silent
121cb0ef41Sopenharmony_ciOSTYPE := $(shell uname -s | tr '[:upper:]' '[:lower:]')
131cb0ef41Sopenharmony_ciifeq ($(findstring os/390,$OSTYPE),os/390)
141cb0ef41Sopenharmony_ciOSTYPE ?= os390
151cb0ef41Sopenharmony_ciendif
161cb0ef41Sopenharmony_ciARCHTYPE := $(shell uname -m | tr '[:upper:]' '[:lower:]')
171cb0ef41Sopenharmony_ciCOVTESTS ?= test-cov
181cb0ef41Sopenharmony_ciCOV_SKIP_TESTS ?= core_line_numbers.js,testFinalizer.js,test_function/test.js
191cb0ef41Sopenharmony_ciGTEST_FILTER ?= "*"
201cb0ef41Sopenharmony_ciGNUMAKEFLAGS += --no-print-directory
211cb0ef41Sopenharmony_ciGCOV ?= gcov
221cb0ef41Sopenharmony_ciPWD = $(CURDIR)
231cb0ef41Sopenharmony_ciBUILD_WITH ?= make
241cb0ef41Sopenharmony_ciFIND ?= find
251cb0ef41Sopenharmony_ci
261cb0ef41Sopenharmony_ciifdef JOBS
271cb0ef41Sopenharmony_ci	PARALLEL_ARGS = -j $(JOBS)
281cb0ef41Sopenharmony_cielse
291cb0ef41Sopenharmony_ci	PARALLEL_ARGS =
301cb0ef41Sopenharmony_ciendif
311cb0ef41Sopenharmony_ci
321cb0ef41Sopenharmony_ciifdef ENABLE_V8_TAP
331cb0ef41Sopenharmony_ci	TAP_V8 := --junitout $(PWD)/v8-tap.xml
341cb0ef41Sopenharmony_ci	TAP_V8_INTL := --junitout $(PWD)/v8-intl-tap.xml
351cb0ef41Sopenharmony_ci	TAP_V8_BENCHMARKS := --junitout $(PWD)/v8-benchmarks-tap.xml
361cb0ef41Sopenharmony_cidefine convert_to_junit
371cb0ef41Sopenharmony_ci	@true
381cb0ef41Sopenharmony_ciendef
391cb0ef41Sopenharmony_ciendif
401cb0ef41Sopenharmony_ci
411cb0ef41Sopenharmony_ciifdef ENABLE_CONVERT_V8_JSON_TO_XML
421cb0ef41Sopenharmony_ci	TAP_V8_JSON := $(PWD)/v8-tap.json
431cb0ef41Sopenharmony_ci	TAP_V8_INTL_JSON := $(PWD)/v8-intl-tap.json
441cb0ef41Sopenharmony_ci	TAP_V8_BENCHMARKS_JSON := $(PWD)/v8-benchmarks-tap.json
451cb0ef41Sopenharmony_ci
461cb0ef41Sopenharmony_ci	# By default, the V8's JSON test output only includes the tests which have
471cb0ef41Sopenharmony_ci	# failed. We use --slow-tests-cutoff to ensure that all tests are present
481cb0ef41Sopenharmony_ci	# in the output, including those which pass.
491cb0ef41Sopenharmony_ci	TAP_V8 := --json-test-results $(TAP_V8_JSON) --slow-tests-cutoff 1000000
501cb0ef41Sopenharmony_ci	TAP_V8_INTL := --json-test-results $(TAP_V8_INTL_JSON) --slow-tests-cutoff 1000000
511cb0ef41Sopenharmony_ci	TAP_V8_BENCHMARKS := --json-test-results $(TAP_V8_BENCHMARKS_JSON) --slow-tests-cutoff 1000000
521cb0ef41Sopenharmony_ci
531cb0ef41Sopenharmony_cidefine convert_to_junit
541cb0ef41Sopenharmony_ci	export PATH="$(NO_BIN_OVERRIDE_PATH)" && \
551cb0ef41Sopenharmony_ci		$(PYTHON) tools/v8-json-to-junit.py < $(1) > $(1:.json=.xml)
561cb0ef41Sopenharmony_ciendef
571cb0ef41Sopenharmony_ciendif
581cb0ef41Sopenharmony_ci
591cb0ef41Sopenharmony_ciV8_TEST_OPTIONS = $(V8_EXTRA_TEST_OPTIONS)
601cb0ef41Sopenharmony_ciifdef DISABLE_V8_I18N
611cb0ef41Sopenharmony_ci	V8_BUILD_OPTIONS += i18nsupport=off
621cb0ef41Sopenharmony_ciendif
631cb0ef41Sopenharmony_ci# V8 build and test toolchains are not currently compatible with Python 3.
641cb0ef41Sopenharmony_ci# config.mk may have prepended a symlink for `python` to PATH which we need
651cb0ef41Sopenharmony_ci# to undo before calling V8's tools.
661cb0ef41Sopenharmony_ciOVERRIDE_BIN_DIR=$(dir $(abspath $(lastword $(MAKEFILE_LIST))))out/tools/bin
671cb0ef41Sopenharmony_ciNO_BIN_OVERRIDE_PATH=$(subst $() $(),:,$(filter-out $(OVERRIDE_BIN_DIR),$(subst :, ,$(PATH))))
681cb0ef41Sopenharmony_ci
691cb0ef41Sopenharmony_ciifeq ($(OSTYPE), darwin)
701cb0ef41Sopenharmony_ci	GCOV = xcrun llvm-cov gcov
711cb0ef41Sopenharmony_ciendif
721cb0ef41Sopenharmony_ci
731cb0ef41Sopenharmony_ciBUILDTYPE_LOWER := $(shell echo $(BUILDTYPE) | tr '[:upper:]' '[:lower:]')
741cb0ef41Sopenharmony_ci
751cb0ef41Sopenharmony_ci# Determine EXEEXT
761cb0ef41Sopenharmony_ciEXEEXT := $(shell $(PYTHON) -c \
771cb0ef41Sopenharmony_ci		"import sys; print('.exe' if sys.platform == 'win32' else '')")
781cb0ef41Sopenharmony_ci
791cb0ef41Sopenharmony_ciNODE_EXE = node$(EXEEXT)
801cb0ef41Sopenharmony_ciNODE ?= ./$(NODE_EXE)
811cb0ef41Sopenharmony_ciNODE_G_EXE = node_g$(EXEEXT)
821cb0ef41Sopenharmony_ciNPM ?= ./deps/npm/bin/npm-cli.js
831cb0ef41Sopenharmony_ci
841cb0ef41Sopenharmony_ci# Flags for packaging.
851cb0ef41Sopenharmony_ciBUILD_DOWNLOAD_FLAGS ?= --download=all
861cb0ef41Sopenharmony_ciBUILD_INTL_FLAGS ?= --with-intl=full-icu
871cb0ef41Sopenharmony_ciBUILD_RELEASE_FLAGS ?= $(BUILD_DOWNLOAD_FLAGS) $(BUILD_INTL_FLAGS)
881cb0ef41Sopenharmony_ci
891cb0ef41Sopenharmony_ci# Default to quiet/pretty builds.
901cb0ef41Sopenharmony_ci# To do verbose builds, run `make V=1` or set the V environment variable.
911cb0ef41Sopenharmony_ciV ?= 0
921cb0ef41Sopenharmony_ci
931cb0ef41Sopenharmony_ci# Use -e to double check in case it's a broken link
941cb0ef41Sopenharmony_ci# Use $(PWD) so we can cd to anywhere before calling this
951cb0ef41Sopenharmony_ciavailable-node = \
961cb0ef41Sopenharmony_ci	if [ -x $(PWD)/$(NODE) ] && [ -e $(PWD)/$(NODE) ]; then \
971cb0ef41Sopenharmony_ci		$(PWD)/$(NODE) $(1); \
981cb0ef41Sopenharmony_ci	elif [ -x `command -v node` ] && [ -e `command -v node` ] && [ `command -v node` ]; then \
991cb0ef41Sopenharmony_ci		`command -v node` $(1); \
1001cb0ef41Sopenharmony_ci	else \
1011cb0ef41Sopenharmony_ci		echo "No available node, cannot run \"node $(1)\""; \
1021cb0ef41Sopenharmony_ci		exit 1; \
1031cb0ef41Sopenharmony_ci	fi;
1041cb0ef41Sopenharmony_ci
1051cb0ef41Sopenharmony_ci.PHONY: all
1061cb0ef41Sopenharmony_ci# BUILDTYPE=Debug builds both release and debug builds. If you want to compile
1071cb0ef41Sopenharmony_ci# just the debug build, run `make -C out BUILDTYPE=Debug` instead.
1081cb0ef41Sopenharmony_ciifeq ($(BUILDTYPE),Release)
1091cb0ef41Sopenharmony_ciall: $(NODE_EXE) ## Default target, builds node in out/Release/node.
1101cb0ef41Sopenharmony_cielse
1111cb0ef41Sopenharmony_ciall: $(NODE_EXE) $(NODE_G_EXE)
1121cb0ef41Sopenharmony_ciendif
1131cb0ef41Sopenharmony_ci
1141cb0ef41Sopenharmony_ci.PHONY: help
1151cb0ef41Sopenharmony_ci# To add a target to the help, add a double comment (##) on the target line.
1161cb0ef41Sopenharmony_cihelp: ## Print help for targets with comments.
1171cb0ef41Sopenharmony_ci	@printf "For more targets and info see the comments in the Makefile.\n\n"
1181cb0ef41Sopenharmony_ci	@grep -E '^[[:alnum:]._-]+:.*?## .*$$' Makefile | sort | \
1191cb0ef41Sopenharmony_ci		awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-15s\033[0m %s\n", $$1, $$2}'
1201cb0ef41Sopenharmony_ci
1211cb0ef41Sopenharmony_ci# The .PHONY is needed to ensure that we recursively use the out/Makefile
1221cb0ef41Sopenharmony_ci# to check for changes.
1231cb0ef41Sopenharmony_ci.PHONY: $(NODE_EXE) $(NODE_G_EXE)
1241cb0ef41Sopenharmony_ci
1251cb0ef41Sopenharmony_ci# The -r/-L check stops it recreating the link if it is already in place,
1261cb0ef41Sopenharmony_ci# otherwise $(NODE_EXE) being a .PHONY target means it is always re-run.
1271cb0ef41Sopenharmony_ci# Without the check there is a race condition between the link being deleted
1281cb0ef41Sopenharmony_ci# and recreated which can break the addons build when running test-ci
1291cb0ef41Sopenharmony_ci# See comments on the build-addons target for some more info
1301cb0ef41Sopenharmony_ciifeq ($(BUILD_WITH), make)
1311cb0ef41Sopenharmony_ci$(NODE_EXE): build_type:=Release
1321cb0ef41Sopenharmony_ci$(NODE_G_EXE): build_type:=Debug
1331cb0ef41Sopenharmony_ci$(NODE_EXE) $(NODE_G_EXE): config.gypi out/Makefile
1341cb0ef41Sopenharmony_ci	$(MAKE) -C out BUILDTYPE=${build_type} V=$(V)
1351cb0ef41Sopenharmony_ci	if [ ! -r $@ ] || [ ! -L $@ ]; then \
1361cb0ef41Sopenharmony_ci	  ln -fs out/${build_type}/$(NODE_EXE) $@; fi
1371cb0ef41Sopenharmony_cielse
1381cb0ef41Sopenharmony_ciifeq ($(BUILD_WITH), ninja)
1391cb0ef41Sopenharmony_ciNINJA ?= ninja
1401cb0ef41Sopenharmony_ciifeq ($(V),1)
1411cb0ef41Sopenharmony_ci	NINJA_ARGS := $(NINJA_ARGS) -v
1421cb0ef41Sopenharmony_ciendif
1431cb0ef41Sopenharmony_ciifdef JOBS
1441cb0ef41Sopenharmony_ci	NINJA_ARGS := $(NINJA_ARGS) -j$(JOBS)
1451cb0ef41Sopenharmony_cielse
1461cb0ef41Sopenharmony_ci	NINJA_ARGS := $(NINJA_ARGS) $(filter -j%,$(MAKEFLAGS))
1471cb0ef41Sopenharmony_ciendif
1481cb0ef41Sopenharmony_ci$(NODE_EXE): config.gypi out/Release/build.ninja
1491cb0ef41Sopenharmony_ci	$(NINJA) -C out/Release $(NINJA_ARGS)
1501cb0ef41Sopenharmony_ci	if [ ! -r $@ ] || [ ! -L $@ ]; then ln -fs out/Release/$(NODE_EXE) $@; fi
1511cb0ef41Sopenharmony_ci
1521cb0ef41Sopenharmony_ci$(NODE_G_EXE): config.gypi out/Debug/build.ninja
1531cb0ef41Sopenharmony_ci	$(NINJA) -C out/Debug $(NINJA_ARGS)
1541cb0ef41Sopenharmony_ci	if [ ! -r $@ ] || [ ! -L $@ ]; then ln -fs out/Debug/$(NODE_EXE) $@; fi
1551cb0ef41Sopenharmony_cielse
1561cb0ef41Sopenharmony_ci$(NODE_EXE) $(NODE_G_EXE):
1571cb0ef41Sopenharmony_ci	$(warning This Makefile currently only supports building with 'make' or 'ninja')
1581cb0ef41Sopenharmony_ciendif
1591cb0ef41Sopenharmony_ciendif
1601cb0ef41Sopenharmony_ci
1611cb0ef41Sopenharmony_ci
1621cb0ef41Sopenharmony_ciifeq ($(BUILDTYPE),Debug)
1631cb0ef41Sopenharmony_ciCONFIG_FLAGS += --debug
1641cb0ef41Sopenharmony_ciendif
1651cb0ef41Sopenharmony_ci
1661cb0ef41Sopenharmony_ci.PHONY: with-code-cache
1671cb0ef41Sopenharmony_ci.PHONY: test-code-cache
1681cb0ef41Sopenharmony_ciwith-code-cache test-code-cache:
1691cb0ef41Sopenharmony_ci	$(warning '$@' target is a noop)
1701cb0ef41Sopenharmony_ci
1711cb0ef41Sopenharmony_ciout/Makefile: config.gypi common.gypi node.gyp \
1721cb0ef41Sopenharmony_ci	deps/uv/uv.gyp deps/llhttp/llhttp.gyp deps/zlib/zlib.gyp \
1731cb0ef41Sopenharmony_ci	deps/simdutf/simdutf.gyp deps/ada/ada.gyp \
1741cb0ef41Sopenharmony_ci	tools/v8_gypfiles/toolchain.gypi tools/v8_gypfiles/features.gypi \
1751cb0ef41Sopenharmony_ci	tools/v8_gypfiles/inspector.gypi tools/v8_gypfiles/v8.gyp
1761cb0ef41Sopenharmony_ci	$(PYTHON) tools/gyp_node.py -f make
1771cb0ef41Sopenharmony_ci
1781cb0ef41Sopenharmony_ci# node_version.h is listed because the N-API version is taken from there
1791cb0ef41Sopenharmony_ci# and included in config.gypi
1801cb0ef41Sopenharmony_ciconfig.gypi: configure configure.py src/node_version.h
1811cb0ef41Sopenharmony_ci	@if [ -x config.status ]; then \
1821cb0ef41Sopenharmony_ci		export PATH="$(NO_BIN_OVERRIDE_PATH)" && ./config.status; \
1831cb0ef41Sopenharmony_ci	else \
1841cb0ef41Sopenharmony_ci		echo Missing or stale $@, please run ./$<; \
1851cb0ef41Sopenharmony_ci		exit 1; \
1861cb0ef41Sopenharmony_ci	fi
1871cb0ef41Sopenharmony_ci
1881cb0ef41Sopenharmony_ci.PHONY: install
1891cb0ef41Sopenharmony_ciinstall: all ## Installs node into $PREFIX (default=/usr/local).
1901cb0ef41Sopenharmony_ci	$(PYTHON) tools/install.py $@ '$(DESTDIR)' '$(PREFIX)'
1911cb0ef41Sopenharmony_ci
1921cb0ef41Sopenharmony_ci.PHONY: uninstall
1931cb0ef41Sopenharmony_ciuninstall: ## Uninstalls node from $PREFIX (default=/usr/local).
1941cb0ef41Sopenharmony_ci	$(PYTHON) tools/install.py $@ '$(DESTDIR)' '$(PREFIX)'
1951cb0ef41Sopenharmony_ci
1961cb0ef41Sopenharmony_ci.PHONY: clean
1971cb0ef41Sopenharmony_ci.NOTPARALLEL: clean
1981cb0ef41Sopenharmony_ciclean: ## Remove build artifacts.
1991cb0ef41Sopenharmony_ci	$(RM) -r out/Makefile $(NODE_EXE) $(NODE_G_EXE) out/$(BUILDTYPE)/$(NODE_EXE) \
2001cb0ef41Sopenharmony_ci		out/$(BUILDTYPE)/node.exp
2011cb0ef41Sopenharmony_ci	@if [ -d out ]; then $(FIND) out/ -name '*.o' -o -name '*.a' -o -name '*.d' | xargs $(RM) -r; fi
2021cb0ef41Sopenharmony_ci	$(RM) -r node_modules
2031cb0ef41Sopenharmony_ci	@if [ -d deps/icu ]; then echo deleting deps/icu; $(RM) -r deps/icu; fi
2041cb0ef41Sopenharmony_ci	$(RM) test.tap
2051cb0ef41Sopenharmony_ci	$(MAKE) testclean
2061cb0ef41Sopenharmony_ci	$(MAKE) test-addons-clean
2071cb0ef41Sopenharmony_ci	$(MAKE) bench-addons-clean
2081cb0ef41Sopenharmony_ci
2091cb0ef41Sopenharmony_ci.PHONY: testclean
2101cb0ef41Sopenharmony_ci.NOTPARALLEL: testclean
2111cb0ef41Sopenharmony_citestclean:
2121cb0ef41Sopenharmony_ci# Next one is legacy remove this at some point
2131cb0ef41Sopenharmony_ci	$(RM) -r test/tmp*
2141cb0ef41Sopenharmony_ci	$(RM) -r test/.tmp*
2151cb0ef41Sopenharmony_ci
2161cb0ef41Sopenharmony_ci.PHONY: distclean
2171cb0ef41Sopenharmony_ci.NOTPARALLEL: distclean
2181cb0ef41Sopenharmony_cidistclean:
2191cb0ef41Sopenharmony_ci	$(RM) -r out
2201cb0ef41Sopenharmony_ci	$(RM) config.gypi icu_config.gypi
2211cb0ef41Sopenharmony_ci	$(RM) config.mk
2221cb0ef41Sopenharmony_ci	$(RM) -r $(NODE_EXE) $(NODE_G_EXE)
2231cb0ef41Sopenharmony_ci	$(RM) -r node_modules
2241cb0ef41Sopenharmony_ci	$(RM) -r deps/icu
2251cb0ef41Sopenharmony_ci	$(RM) -r deps/icu4c*.tgz deps/icu4c*.zip deps/icu-tmp
2261cb0ef41Sopenharmony_ci	$(RM) $(BINARYTAR).* $(TARBALL).*
2271cb0ef41Sopenharmony_ci
2281cb0ef41Sopenharmony_ci.PHONY: check
2291cb0ef41Sopenharmony_cicheck: test
2301cb0ef41Sopenharmony_ci
2311cb0ef41Sopenharmony_ci.PHONY: coverage-clean
2321cb0ef41Sopenharmony_ci.NOTPARALLEL: coverage-clean
2331cb0ef41Sopenharmony_ci# Remove files generated by running coverage, put the non-instrumented lib back
2341cb0ef41Sopenharmony_ci# in place
2351cb0ef41Sopenharmony_cicoverage-clean:
2361cb0ef41Sopenharmony_ci	$(RM) -r node_modules
2371cb0ef41Sopenharmony_ci	$(RM) -r gcovr
2381cb0ef41Sopenharmony_ci	$(RM) -r coverage/tmp
2391cb0ef41Sopenharmony_ci	$(FIND) out/$(BUILDTYPE)/obj.target \( -name "*.gcda" -o -name "*.gcno" \) \
2401cb0ef41Sopenharmony_ci		-type f -exec $(RM) {} \;
2411cb0ef41Sopenharmony_ci
2421cb0ef41Sopenharmony_ci.PHONY: coverage
2431cb0ef41Sopenharmony_ci# Build and test with code coverage reporting. HTML coverage reports will be
2441cb0ef41Sopenharmony_ci# created under coverage/. For C++ coverage reporting, this needs to be run
2451cb0ef41Sopenharmony_ci# in conjunction with configure --coverage.
2461cb0ef41Sopenharmony_ci# Related CI job: node-test-commit-linux-coverage-daily
2471cb0ef41Sopenharmony_cicoverage: coverage-test ## Run the tests and generate a coverage report.
2481cb0ef41Sopenharmony_ci
2491cb0ef41Sopenharmony_ci.PHONY: coverage-build
2501cb0ef41Sopenharmony_cicoverage-build: all
2511cb0ef41Sopenharmony_ci	-$(MAKE) coverage-build-js
2521cb0ef41Sopenharmony_ci	if [ ! -d gcovr ]; then $(PYTHON) -m pip install -t gcovr gcovr==4.2; fi
2531cb0ef41Sopenharmony_ci	$(MAKE)
2541cb0ef41Sopenharmony_ci
2551cb0ef41Sopenharmony_ci.PHONY: coverage-build-js
2561cb0ef41Sopenharmony_cicoverage-build-js:
2571cb0ef41Sopenharmony_ci	mkdir -p node_modules
2581cb0ef41Sopenharmony_ci	if [ ! -d node_modules/c8 ]; then \
2591cb0ef41Sopenharmony_ci		$(NODE) ./deps/npm install c8 --no-save --no-package-lock;\
2601cb0ef41Sopenharmony_ci	fi
2611cb0ef41Sopenharmony_ci
2621cb0ef41Sopenharmony_ci.PHONY: coverage-test
2631cb0ef41Sopenharmony_cicoverage-test: coverage-build
2641cb0ef41Sopenharmony_ci	$(FIND) out/$(BUILDTYPE)/obj.target -name "*.gcda" -type f -exec $(RM) {} \;
2651cb0ef41Sopenharmony_ci	-NODE_V8_COVERAGE=coverage/tmp \
2661cb0ef41Sopenharmony_ci		TEST_CI_ARGS="$(TEST_CI_ARGS) --type=coverage" $(MAKE) $(COVTESTS)
2671cb0ef41Sopenharmony_ci	$(MAKE) coverage-report-js
2681cb0ef41Sopenharmony_ci	-(cd out && PYTHONPATH=../gcovr $(PYTHON) -m gcovr \
2691cb0ef41Sopenharmony_ci		--gcov-exclude='.*\b(deps|usr|out|cctest|embedding)\b' -v \
2701cb0ef41Sopenharmony_ci		-r ../src/ --object-directory Release/obj.target \
2711cb0ef41Sopenharmony_ci		--html --html-details -o ../coverage/cxxcoverage.html \
2721cb0ef41Sopenharmony_ci		--gcov-executable="$(GCOV)")
2731cb0ef41Sopenharmony_ci	@printf "Javascript coverage %%: "
2741cb0ef41Sopenharmony_ci	@grep -B1 Lines coverage/index.html | head -n1 \
2751cb0ef41Sopenharmony_ci		| sed 's/<[^>]*>//g'| sed 's/ //g'
2761cb0ef41Sopenharmony_ci	@printf "C++ coverage %%: "
2771cb0ef41Sopenharmony_ci	@grep -A3 Lines coverage/cxxcoverage.html | grep style  \
2781cb0ef41Sopenharmony_ci		| sed 's/<[^>]*>//g'| sed 's/ //g'
2791cb0ef41Sopenharmony_ci
2801cb0ef41Sopenharmony_ci.PHONY: coverage-report-js
2811cb0ef41Sopenharmony_cicoverage-report-js:
2821cb0ef41Sopenharmony_ci	-$(MAKE) coverage-build-js
2831cb0ef41Sopenharmony_ci	$(NODE) ./node_modules/.bin/c8 report
2841cb0ef41Sopenharmony_ci
2851cb0ef41Sopenharmony_ci.PHONY: cctest
2861cb0ef41Sopenharmony_ci# Runs the C++ tests using the built `cctest` executable.
2871cb0ef41Sopenharmony_cicctest: all
2881cb0ef41Sopenharmony_ci	@out/$(BUILDTYPE)/$@ --gtest_filter=$(GTEST_FILTER)
2891cb0ef41Sopenharmony_ci	@out/$(BUILDTYPE)/embedtest "require('./test/embedding/test-embedding.js')"
2901cb0ef41Sopenharmony_ci
2911cb0ef41Sopenharmony_ci.PHONY: list-gtests
2921cb0ef41Sopenharmony_cilist-gtests:
2931cb0ef41Sopenharmony_ciifeq (,$(wildcard out/$(BUILDTYPE)/cctest))
2941cb0ef41Sopenharmony_ci	$(error Please run 'make cctest' first)
2951cb0ef41Sopenharmony_ciendif
2961cb0ef41Sopenharmony_ci	@out/$(BUILDTYPE)/cctest --gtest_list_tests
2971cb0ef41Sopenharmony_ci
2981cb0ef41Sopenharmony_ci.PHONY: v8
2991cb0ef41Sopenharmony_ci# Related CI job: node-test-commit-v8-linux
3001cb0ef41Sopenharmony_ci# Rebuilds deps/v8 as a git tree, pulls its third-party dependencies, and
3011cb0ef41Sopenharmony_ci# builds it.
3021cb0ef41Sopenharmony_civ8:
3031cb0ef41Sopenharmony_ci	export PATH="$(NO_BIN_OVERRIDE_PATH)" && \
3041cb0ef41Sopenharmony_ci		tools/make-v8.sh $(V8_ARCH).$(BUILDTYPE_LOWER) $(V8_BUILD_OPTIONS)
3051cb0ef41Sopenharmony_ci
3061cb0ef41Sopenharmony_ci.PHONY: jstest
3071cb0ef41Sopenharmony_cijstest: build-addons build-js-native-api-tests build-node-api-tests ## Runs addon tests and JS tests
3081cb0ef41Sopenharmony_ci	$(PYTHON) tools/test.py $(PARALLEL_ARGS) --mode=$(BUILDTYPE_LOWER) \
3091cb0ef41Sopenharmony_ci		$(TEST_CI_ARGS) \
3101cb0ef41Sopenharmony_ci		--skip-tests=$(CI_SKIP_TESTS) \
3111cb0ef41Sopenharmony_ci		$(JS_SUITES) \
3121cb0ef41Sopenharmony_ci		$(NATIVE_SUITES)
3131cb0ef41Sopenharmony_ci
3141cb0ef41Sopenharmony_ci.PHONY: tooltest
3151cb0ef41Sopenharmony_citooltest:
3161cb0ef41Sopenharmony_ci	@$(PYTHON) -m unittest discover -s ./test/tools
3171cb0ef41Sopenharmony_ci
3181cb0ef41Sopenharmony_ci.PHONY: coverage-run-js
3191cb0ef41Sopenharmony_cicoverage-run-js:
3201cb0ef41Sopenharmony_ci	$(RM) -r coverage/tmp
3211cb0ef41Sopenharmony_ci	-NODE_V8_COVERAGE=coverage/tmp CI_SKIP_TESTS=$(COV_SKIP_TESTS) \
3221cb0ef41Sopenharmony_ci					TEST_CI_ARGS="$(TEST_CI_ARGS) --type=coverage" $(MAKE) jstest
3231cb0ef41Sopenharmony_ci	$(MAKE) coverage-report-js
3241cb0ef41Sopenharmony_ci
3251cb0ef41Sopenharmony_ci.PHONY: test
3261cb0ef41Sopenharmony_ci# This does not run tests of third-party libraries inside deps.
3271cb0ef41Sopenharmony_citest: all ## Runs default tests, linters, and builds docs.
3281cb0ef41Sopenharmony_ci	$(MAKE) -s tooltest
3291cb0ef41Sopenharmony_ci	$(MAKE) -s test-doc
3301cb0ef41Sopenharmony_ci	$(MAKE) -s build-addons
3311cb0ef41Sopenharmony_ci	$(MAKE) -s build-js-native-api-tests
3321cb0ef41Sopenharmony_ci	$(MAKE) -s build-node-api-tests
3331cb0ef41Sopenharmony_ci	$(MAKE) -s cctest
3341cb0ef41Sopenharmony_ci	$(MAKE) -s jstest
3351cb0ef41Sopenharmony_ci
3361cb0ef41Sopenharmony_ci.PHONY: test-only
3371cb0ef41Sopenharmony_citest-only: all  ## For a quick test, does not run linter or build docs.
3381cb0ef41Sopenharmony_ci	$(MAKE) build-addons
3391cb0ef41Sopenharmony_ci	$(MAKE) build-js-native-api-tests
3401cb0ef41Sopenharmony_ci	$(MAKE) build-node-api-tests
3411cb0ef41Sopenharmony_ci	$(MAKE) cctest
3421cb0ef41Sopenharmony_ci	$(MAKE) jstest
3431cb0ef41Sopenharmony_ci	$(MAKE) tooltest
3441cb0ef41Sopenharmony_ci
3451cb0ef41Sopenharmony_ci# Used by `make coverage-test`
3461cb0ef41Sopenharmony_ci.PHONY: test-cov
3471cb0ef41Sopenharmony_citest-cov: all
3481cb0ef41Sopenharmony_ci	$(MAKE) build-addons
3491cb0ef41Sopenharmony_ci	$(MAKE) build-js-native-api-tests
3501cb0ef41Sopenharmony_ci	$(MAKE) build-node-api-tests
3511cb0ef41Sopenharmony_ci	$(MAKE) cctest
3521cb0ef41Sopenharmony_ci	CI_SKIP_TESTS=$(COV_SKIP_TESTS) $(MAKE) jstest
3531cb0ef41Sopenharmony_ci
3541cb0ef41Sopenharmony_ci.PHONY: test-parallel
3551cb0ef41Sopenharmony_citest-parallel: all
3561cb0ef41Sopenharmony_ci	$(PYTHON) tools/test.py $(PARALLEL_ARGS) --mode=$(BUILDTYPE_LOWER) parallel
3571cb0ef41Sopenharmony_ci
3581cb0ef41Sopenharmony_ci.PHONY: test-valgrind
3591cb0ef41Sopenharmony_citest-valgrind: all
3601cb0ef41Sopenharmony_ci	$(PYTHON) tools/test.py $(PARALLEL_ARGS) --mode=$(BUILDTYPE_LOWER) --valgrind sequential parallel message
3611cb0ef41Sopenharmony_ci
3621cb0ef41Sopenharmony_ci.PHONY: test-check-deopts
3631cb0ef41Sopenharmony_citest-check-deopts: all
3641cb0ef41Sopenharmony_ci	$(PYTHON) tools/test.py $(PARALLEL_ARGS) --mode=$(BUILDTYPE_LOWER) --check-deopts parallel sequential
3651cb0ef41Sopenharmony_ci
3661cb0ef41Sopenharmony_ciDOCBUILDSTAMP_PREREQS = tools/doc/addon-verify.mjs doc/api/addons.md
3671cb0ef41Sopenharmony_ci
3681cb0ef41Sopenharmony_ciifeq ($(OSTYPE),aix)
3691cb0ef41Sopenharmony_ciDOCBUILDSTAMP_PREREQS := $(DOCBUILDSTAMP_PREREQS) out/$(BUILDTYPE)/node.exp
3701cb0ef41Sopenharmony_ciendif
3711cb0ef41Sopenharmony_ciifeq ($(OSTYPE),os400)
3721cb0ef41Sopenharmony_ciDOCBUILDSTAMP_PREREQS := $(DOCBUILDSTAMP_PREREQS) out/$(BUILDTYPE)/node.exp
3731cb0ef41Sopenharmony_ciendif
3741cb0ef41Sopenharmony_ci
3751cb0ef41Sopenharmony_cinode_use_openssl = $(call available-node,"-p" \
3761cb0ef41Sopenharmony_ci			 "process.versions.openssl != undefined")
3771cb0ef41Sopenharmony_citest/addons/.docbuildstamp: $(DOCBUILDSTAMP_PREREQS) tools/doc/node_modules
3781cb0ef41Sopenharmony_ci	@if [ "$(shell $(node_use_openssl))" != "true" ]; then \
3791cb0ef41Sopenharmony_ci		echo "Skipping .docbuildstamp (no crypto)"; \
3801cb0ef41Sopenharmony_ci	else \
3811cb0ef41Sopenharmony_ci		$(RM) -r test/addons/??_*/; \
3821cb0ef41Sopenharmony_ci		[ -x $(NODE) ] && $(NODE) $< || node $< ; \
3831cb0ef41Sopenharmony_ci		[ $$? -eq 0 ] && touch $@; \
3841cb0ef41Sopenharmony_ci	fi
3851cb0ef41Sopenharmony_ci
3861cb0ef41Sopenharmony_ciADDONS_BINDING_GYPS := \
3871cb0ef41Sopenharmony_ci	$(filter-out test/addons/??_*/binding.gyp, \
3881cb0ef41Sopenharmony_ci		$(wildcard test/addons/*/binding.gyp))
3891cb0ef41Sopenharmony_ci
3901cb0ef41Sopenharmony_ciADDONS_BINDING_SOURCES := \
3911cb0ef41Sopenharmony_ci	$(filter-out test/addons/??_*/*.cc, $(wildcard test/addons/*/*.cc)) \
3921cb0ef41Sopenharmony_ci	$(filter-out test/addons/??_*/*.h, $(wildcard test/addons/*/*.h))
3931cb0ef41Sopenharmony_ci
3941cb0ef41Sopenharmony_ciADDONS_PREREQS := config.gypi \
3951cb0ef41Sopenharmony_ci	deps/npm/node_modules/node-gyp/package.json tools/build-addons.mjs \
3961cb0ef41Sopenharmony_ci	deps/uv/include/*.h deps/v8/include/*.h \
3971cb0ef41Sopenharmony_ci	src/node.h src/node_buffer.h src/node_object_wrap.h src/node_version.h
3981cb0ef41Sopenharmony_ci
3991cb0ef41Sopenharmony_cidefine run_build_addons
4001cb0ef41Sopenharmony_cienv npm_config_loglevel=$(LOGLEVEL) npm_config_nodedir="$$PWD" \
4011cb0ef41Sopenharmony_ci	npm_config_python="$(PYTHON)" $(NODE) "$$PWD/tools/build-addons.mjs" \
4021cb0ef41Sopenharmony_ci	"$$PWD/deps/npm/node_modules/node-gyp/bin/node-gyp.js" \
4031cb0ef41Sopenharmony_ci	$1
4041cb0ef41Sopenharmony_citouch $2
4051cb0ef41Sopenharmony_ciendef
4061cb0ef41Sopenharmony_ci
4071cb0ef41Sopenharmony_ci# Implicitly depends on $(NODE_EXE), see the build-addons rule for rationale.
4081cb0ef41Sopenharmony_ci# Depends on node-gyp package.json so that build-addons is (re)executed when
4091cb0ef41Sopenharmony_ci# node-gyp is updated as part of an npm update.
4101cb0ef41Sopenharmony_citest/addons/.buildstamp: $(ADDONS_PREREQS) \
4111cb0ef41Sopenharmony_ci	$(ADDONS_BINDING_GYPS) $(ADDONS_BINDING_SOURCES) \
4121cb0ef41Sopenharmony_ci	test/addons/.docbuildstamp
4131cb0ef41Sopenharmony_ci	@$(call run_build_addons,"$$PWD/test/addons",$@)
4141cb0ef41Sopenharmony_ci
4151cb0ef41Sopenharmony_ci.PHONY: build-addons
4161cb0ef41Sopenharmony_ci# .buildstamp needs $(NODE_EXE) but cannot depend on it
4171cb0ef41Sopenharmony_ci# directly because it calls make recursively.  The parent make cannot know
4181cb0ef41Sopenharmony_ci# if the subprocess touched anything so it pessimistically assumes that
4191cb0ef41Sopenharmony_ci# .buildstamp is out of date and need a rebuild.
4201cb0ef41Sopenharmony_ci# Just goes to show that recursive make really is harmful...
4211cb0ef41Sopenharmony_ci# TODO(bnoordhuis) Force rebuild after gyp update.
4221cb0ef41Sopenharmony_cibuild-addons: | $(NODE_EXE) test/addons/.buildstamp
4231cb0ef41Sopenharmony_ci
4241cb0ef41Sopenharmony_ciJS_NATIVE_API_BINDING_GYPS := \
4251cb0ef41Sopenharmony_ci	$(filter-out test/js-native-api/??_*/binding.gyp, \
4261cb0ef41Sopenharmony_ci		$(wildcard test/js-native-api/*/binding.gyp))
4271cb0ef41Sopenharmony_ci
4281cb0ef41Sopenharmony_ciJS_NATIVE_API_BINDING_SOURCES := \
4291cb0ef41Sopenharmony_ci	$(filter-out test/js-native-api/??_*/*.c, $(wildcard test/js-native-api/*/*.c)) \
4301cb0ef41Sopenharmony_ci	$(filter-out test/js-native-api/??_*/*.cc, $(wildcard test/js-native-api/*/*.cc)) \
4311cb0ef41Sopenharmony_ci	$(filter-out test/js-native-api/??_*/*.h, $(wildcard test/js-native-api/*/*.h))
4321cb0ef41Sopenharmony_ci
4331cb0ef41Sopenharmony_ci# Implicitly depends on $(NODE_EXE), see the build-js-native-api-tests rule for rationale.
4341cb0ef41Sopenharmony_citest/js-native-api/.buildstamp: $(ADDONS_PREREQS) \
4351cb0ef41Sopenharmony_ci	$(JS_NATIVE_API_BINDING_GYPS) $(JS_NATIVE_API_BINDING_SOURCES) \
4361cb0ef41Sopenharmony_ci	src/node_api.h src/node_api_types.h src/js_native_api.h \
4371cb0ef41Sopenharmony_ci	src/js_native_api_types.h src/js_native_api_v8.h src/js_native_api_v8_internals.h
4381cb0ef41Sopenharmony_ci	@$(call run_build_addons,"$$PWD/test/js-native-api",$@)
4391cb0ef41Sopenharmony_ci
4401cb0ef41Sopenharmony_ci.PHONY: build-js-native-api-tests
4411cb0ef41Sopenharmony_ci# .buildstamp needs $(NODE_EXE) but cannot depend on it
4421cb0ef41Sopenharmony_ci# directly because it calls make recursively.  The parent make cannot know
4431cb0ef41Sopenharmony_ci# if the subprocess touched anything so it pessimistically assumes that
4441cb0ef41Sopenharmony_ci# .buildstamp is out of date and need a rebuild.
4451cb0ef41Sopenharmony_ci# Just goes to show that recursive make really is harmful...
4461cb0ef41Sopenharmony_ci# TODO(bnoordhuis) Force rebuild after gyp or node-gyp update.
4471cb0ef41Sopenharmony_cibuild-js-native-api-tests: | $(NODE_EXE) test/js-native-api/.buildstamp
4481cb0ef41Sopenharmony_ci
4491cb0ef41Sopenharmony_ciNODE_API_BINDING_GYPS := \
4501cb0ef41Sopenharmony_ci	$(filter-out test/node-api/??_*/binding.gyp, \
4511cb0ef41Sopenharmony_ci		$(wildcard test/node-api/*/binding.gyp))
4521cb0ef41Sopenharmony_ci
4531cb0ef41Sopenharmony_ciNODE_API_BINDING_SOURCES := \
4541cb0ef41Sopenharmony_ci	$(filter-out test/node-api/??_*/*.c, $(wildcard test/node-api/*/*.c)) \
4551cb0ef41Sopenharmony_ci	$(filter-out test/node-api/??_*/*.cc, $(wildcard test/node-api/*/*.cc)) \
4561cb0ef41Sopenharmony_ci	$(filter-out test/node-api/??_*/*.h, $(wildcard test/node-api/*/*.h))
4571cb0ef41Sopenharmony_ci
4581cb0ef41Sopenharmony_ci# Implicitly depends on $(NODE_EXE), see the build-node-api-tests rule for rationale.
4591cb0ef41Sopenharmony_citest/node-api/.buildstamp: $(ADDONS_PREREQS) \
4601cb0ef41Sopenharmony_ci	$(NODE_API_BINDING_GYPS) $(NODE_API_BINDING_SOURCES) \
4611cb0ef41Sopenharmony_ci	src/node_api.h src/node_api_types.h src/js_native_api.h \
4621cb0ef41Sopenharmony_ci	src/js_native_api_types.h src/js_native_api_v8.h src/js_native_api_v8_internals.h
4631cb0ef41Sopenharmony_ci	@$(call run_build_addons,"$$PWD/test/node-api",$@)
4641cb0ef41Sopenharmony_ci
4651cb0ef41Sopenharmony_ci.PHONY: build-node-api-tests
4661cb0ef41Sopenharmony_ci# .buildstamp needs $(NODE_EXE) but cannot depend on it
4671cb0ef41Sopenharmony_ci# directly because it calls make recursively.  The parent make cannot know
4681cb0ef41Sopenharmony_ci# if the subprocess touched anything so it pessimistically assumes that
4691cb0ef41Sopenharmony_ci# .buildstamp is out of date and need a rebuild.
4701cb0ef41Sopenharmony_ci# Just goes to show that recursive make really is harmful...
4711cb0ef41Sopenharmony_ci# TODO(bnoordhuis) Force rebuild after gyp or node-gyp update.
4721cb0ef41Sopenharmony_cibuild-node-api-tests: | $(NODE_EXE) test/node-api/.buildstamp
4731cb0ef41Sopenharmony_ci
4741cb0ef41Sopenharmony_ciBENCHMARK_NAPI_BINDING_GYPS := $(wildcard benchmark/napi/*/binding.gyp)
4751cb0ef41Sopenharmony_ci
4761cb0ef41Sopenharmony_ciBENCHMARK_NAPI_BINDING_SOURCES := \
4771cb0ef41Sopenharmony_ci	$(wildcard benchmark/napi/*/*.c) \
4781cb0ef41Sopenharmony_ci	$(wildcard benchmark/napi/*/*.cc) \
4791cb0ef41Sopenharmony_ci	$(wildcard benchmark/napi/*/*.h)
4801cb0ef41Sopenharmony_ci
4811cb0ef41Sopenharmony_cibenchmark/napi/.buildstamp: $(ADDONS_PREREQS) \
4821cb0ef41Sopenharmony_ci	$(BENCHMARK_NAPI_BINDING_GYPS) $(BENCHMARK_NAPI_BINDING_SOURCES)
4831cb0ef41Sopenharmony_ci	@$(call run_build_addons,"$$PWD/benchmark/napi",$@)
4841cb0ef41Sopenharmony_ci
4851cb0ef41Sopenharmony_ci.PHONY: clear-stalled
4861cb0ef41Sopenharmony_ciclear-stalled:
4871cb0ef41Sopenharmony_ci	$(info Clean up any leftover processes but don't error if found.)
4881cb0ef41Sopenharmony_ci	ps awwx | grep Release/node | grep -v grep | cat
4891cb0ef41Sopenharmony_ci	@PS_OUT=`ps awwx | grep Release/node | grep -v grep | awk '{print $$1}'`; \
4901cb0ef41Sopenharmony_ci	if [ "$${PS_OUT}" ]; then \
4911cb0ef41Sopenharmony_ci		echo $${PS_OUT} | xargs kill -9; \
4921cb0ef41Sopenharmony_ci	fi
4931cb0ef41Sopenharmony_ci
4941cb0ef41Sopenharmony_ci.PHONY: test-build
4951cb0ef41Sopenharmony_citest-build: | all build-addons build-js-native-api-tests build-node-api-tests
4961cb0ef41Sopenharmony_ci
4971cb0ef41Sopenharmony_ci.PHONY: test-build-js-native-api
4981cb0ef41Sopenharmony_citest-build-js-native-api: all build-js-native-api-tests
4991cb0ef41Sopenharmony_ci
5001cb0ef41Sopenharmony_ci.PHONY: test-build-node-api
5011cb0ef41Sopenharmony_citest-build-node-api: all build-node-api-tests
5021cb0ef41Sopenharmony_ci
5031cb0ef41Sopenharmony_ci.PHONY: test-all
5041cb0ef41Sopenharmony_citest-all: test-build ## Run default tests with both Debug and Release builds.
5051cb0ef41Sopenharmony_ci	$(PYTHON) tools/test.py $(PARALLEL_ARGS) --mode=debug,release
5061cb0ef41Sopenharmony_ci
5071cb0ef41Sopenharmony_ci.PHONY: test-all-valgrind
5081cb0ef41Sopenharmony_citest-all-valgrind: test-build
5091cb0ef41Sopenharmony_ci	$(PYTHON) tools/test.py $(PARALLEL_ARGS) --mode=debug,release --valgrind
5101cb0ef41Sopenharmony_ci
5111cb0ef41Sopenharmony_ci.PHONY: test-all-suites
5121cb0ef41Sopenharmony_citest-all-suites: | clear-stalled test-build bench-addons-build doc-only ## Run all test suites.
5131cb0ef41Sopenharmony_ci	$(PYTHON) tools/test.py $(PARALLEL_ARGS) --mode=$(BUILDTYPE_LOWER) test/*
5141cb0ef41Sopenharmony_ci
5151cb0ef41Sopenharmony_ciJS_SUITES ?= default
5161cb0ef41Sopenharmony_ciNATIVE_SUITES ?= addons js-native-api node-api
5171cb0ef41Sopenharmony_ci# CI_* variables should be kept synchronized with the ones in vcbuild.bat
5181cb0ef41Sopenharmony_ciCI_NATIVE_SUITES ?= $(NATIVE_SUITES) benchmark
5191cb0ef41Sopenharmony_ciCI_JS_SUITES ?= $(JS_SUITES) pummel
5201cb0ef41Sopenharmony_ciifeq ($(node_use_openssl), false)
5211cb0ef41Sopenharmony_ci	CI_DOC := doctool
5221cb0ef41Sopenharmony_cielse
5231cb0ef41Sopenharmony_ci	CI_DOC =
5241cb0ef41Sopenharmony_ciendif
5251cb0ef41Sopenharmony_ci
5261cb0ef41Sopenharmony_ci.PHONY: test-ci-native
5271cb0ef41Sopenharmony_ci# Build and test addons without building anything else
5281cb0ef41Sopenharmony_ci# Related CI job: node-test-commit-arm-fanned
5291cb0ef41Sopenharmony_citest-ci-native: LOGLEVEL := info
5301cb0ef41Sopenharmony_citest-ci-native: | benchmark/napi/.buildstamp test/addons/.buildstamp test/js-native-api/.buildstamp test/node-api/.buildstamp
5311cb0ef41Sopenharmony_ci	$(PYTHON) tools/test.py $(PARALLEL_ARGS) -p tap --logfile test.tap \
5321cb0ef41Sopenharmony_ci		--mode=$(BUILDTYPE_LOWER) --flaky-tests=$(FLAKY_TESTS) \
5331cb0ef41Sopenharmony_ci		$(TEST_CI_ARGS) $(CI_NATIVE_SUITES)
5341cb0ef41Sopenharmony_ci
5351cb0ef41Sopenharmony_ci.PHONY: test-ci-js
5361cb0ef41Sopenharmony_ci# This target should not use a native compiler at all
5371cb0ef41Sopenharmony_ci# Related CI job: node-test-commit-arm-fanned
5381cb0ef41Sopenharmony_citest-ci-js: | clear-stalled
5391cb0ef41Sopenharmony_ci	$(PYTHON) tools/test.py $(PARALLEL_ARGS) -p tap --logfile test.tap \
5401cb0ef41Sopenharmony_ci		--mode=$(BUILDTYPE_LOWER) --flaky-tests=$(FLAKY_TESTS) \
5411cb0ef41Sopenharmony_ci		$(TEST_CI_ARGS) $(CI_JS_SUITES)
5421cb0ef41Sopenharmony_ci	$(info Clean up any leftover processes, error if found.)
5431cb0ef41Sopenharmony_ci	ps awwx | grep Release/node | grep -v grep | cat
5441cb0ef41Sopenharmony_ci	@PS_OUT=`ps awwx | grep Release/node | grep -v grep | awk '{print $$1}'`; \
5451cb0ef41Sopenharmony_ci	if [ "$${PS_OUT}" ]; then \
5461cb0ef41Sopenharmony_ci		echo $${PS_OUT} | xargs kill -9; exit 1; \
5471cb0ef41Sopenharmony_ci	fi
5481cb0ef41Sopenharmony_ci
5491cb0ef41Sopenharmony_ci.PHONY: test-ci
5501cb0ef41Sopenharmony_ci# Related CI jobs: most CI tests, excluding node-test-commit-arm-fanned
5511cb0ef41Sopenharmony_citest-ci: LOGLEVEL := info
5521cb0ef41Sopenharmony_citest-ci: | clear-stalled bench-addons-build build-addons build-js-native-api-tests build-node-api-tests doc-only
5531cb0ef41Sopenharmony_ci	out/Release/cctest --gtest_output=xml:out/junit/cctest.xml
5541cb0ef41Sopenharmony_ci	$(PYTHON) tools/test.py $(PARALLEL_ARGS) -p tap --logfile test.tap \
5551cb0ef41Sopenharmony_ci		--mode=$(BUILDTYPE_LOWER) --flaky-tests=$(FLAKY_TESTS) \
5561cb0ef41Sopenharmony_ci		$(TEST_CI_ARGS) $(CI_JS_SUITES) $(CI_NATIVE_SUITES) $(CI_DOC)
5571cb0ef41Sopenharmony_ci	out/Release/embedtest 'require("./test/embedding/test-embedding.js")'
5581cb0ef41Sopenharmony_ci	$(info Clean up any leftover processes, error if found.)
5591cb0ef41Sopenharmony_ci	ps awwx | grep Release/node | grep -v grep | cat
5601cb0ef41Sopenharmony_ci	@PS_OUT=`ps awwx | grep Release/node | grep -v grep | awk '{print $$1}'`; \
5611cb0ef41Sopenharmony_ci	if [ "$${PS_OUT}" ]; then \
5621cb0ef41Sopenharmony_ci		echo $${PS_OUT} | xargs kill -9; exit 1; \
5631cb0ef41Sopenharmony_ci	fi
5641cb0ef41Sopenharmony_ci
5651cb0ef41Sopenharmony_ci.PHONY: build-ci
5661cb0ef41Sopenharmony_ci# Prepare the build for running the tests.
5671cb0ef41Sopenharmony_ci# Related CI jobs: most CI tests, excluding node-test-commit-arm-fanned
5681cb0ef41Sopenharmony_cibuild-ci:
5691cb0ef41Sopenharmony_ci	$(PYTHON) ./configure --verbose $(CONFIG_FLAGS)
5701cb0ef41Sopenharmony_ci	$(MAKE)
5711cb0ef41Sopenharmony_ci
5721cb0ef41Sopenharmony_ci.PHONY: run-ci
5731cb0ef41Sopenharmony_ci# Run by CI tests, exceptions:
5741cb0ef41Sopenharmony_ci# - node-test-commit-arm-fanned (Raspberry Pis), where the binaries are
5751cb0ef41Sopenharmony_ci#   cross-compiled, then transferred elsewhere to run different subsets
5761cb0ef41Sopenharmony_ci#   of tests. See `test-ci-native` and `test-ci-js`.
5771cb0ef41Sopenharmony_ci# - node-test-commit-linux-coverage: where the build and the tests need
5781cb0ef41Sopenharmony_ci#   to be instrumented, see `coverage`.
5791cb0ef41Sopenharmony_ci#
5801cb0ef41Sopenharmony_ci# Using -j1 as the sub target in `test-ci` already have internal parallelism.
5811cb0ef41Sopenharmony_ci# Refs: https://github.com/nodejs/node/pull/23733
5821cb0ef41Sopenharmony_cirun-ci: build-ci
5831cb0ef41Sopenharmony_ci	$(MAKE) test-ci -j1
5841cb0ef41Sopenharmony_ci
5851cb0ef41Sopenharmony_ci.PHONY: test-release
5861cb0ef41Sopenharmony_citest-release: test-build
5871cb0ef41Sopenharmony_ci	$(PYTHON) tools/test.py $(PARALLEL_ARGS) --mode=$(BUILDTYPE_LOWER)
5881cb0ef41Sopenharmony_ci
5891cb0ef41Sopenharmony_ci.PHONY: test-debug
5901cb0ef41Sopenharmony_citest-debug: test-build
5911cb0ef41Sopenharmony_ci	$(PYTHON) tools/test.py $(PARALLEL_ARGS) --mode=debug
5921cb0ef41Sopenharmony_ci
5931cb0ef41Sopenharmony_ci.PHONY: test-message
5941cb0ef41Sopenharmony_citest-message: test-build
5951cb0ef41Sopenharmony_ci	$(PYTHON) tools/test.py $(PARALLEL_ARGS) message
5961cb0ef41Sopenharmony_ci
5971cb0ef41Sopenharmony_ci.PHONY: test-wpt
5981cb0ef41Sopenharmony_citest-wpt: all
5991cb0ef41Sopenharmony_ci	$(PYTHON) tools/test.py $(PARALLEL_ARGS) wpt
6001cb0ef41Sopenharmony_ci
6011cb0ef41Sopenharmony_ci.PHONY: test-wpt-report
6021cb0ef41Sopenharmony_citest-wpt-report:
6031cb0ef41Sopenharmony_ci	$(RM) -r out/wpt
6041cb0ef41Sopenharmony_ci	mkdir -p out/wpt
6051cb0ef41Sopenharmony_ci	WPT_REPORT=1 $(PYTHON) tools/test.py --shell $(NODE) $(PARALLEL_ARGS) wpt
6061cb0ef41Sopenharmony_ci
6071cb0ef41Sopenharmony_ci.PHONY: test-simple
6081cb0ef41Sopenharmony_citest-simple: | cctest # Depends on 'all'.
6091cb0ef41Sopenharmony_ci	$(PYTHON) tools/test.py $(PARALLEL_ARGS) parallel sequential
6101cb0ef41Sopenharmony_ci
6111cb0ef41Sopenharmony_ci.PHONY: test-pummel
6121cb0ef41Sopenharmony_citest-pummel: all
6131cb0ef41Sopenharmony_ci	$(PYTHON) tools/test.py $(PARALLEL_ARGS) pummel
6141cb0ef41Sopenharmony_ci
6151cb0ef41Sopenharmony_ci.PHONY: test-internet
6161cb0ef41Sopenharmony_citest-internet: all
6171cb0ef41Sopenharmony_ci	$(PYTHON) tools/test.py $(PARALLEL_ARGS) internet
6181cb0ef41Sopenharmony_ci
6191cb0ef41Sopenharmony_ci.PHONY: test-benchmark
6201cb0ef41Sopenharmony_citest-benchmark: | bench-addons-build
6211cb0ef41Sopenharmony_ci	$(PYTHON) tools/test.py $(PARALLEL_ARGS) benchmark
6221cb0ef41Sopenharmony_ci
6231cb0ef41Sopenharmony_ci.PHONY: test-tick-processor
6241cb0ef41Sopenharmony_citest-tick-processor: all
6251cb0ef41Sopenharmony_ci	$(PYTHON) tools/test.py $(PARALLEL_ARGS) tick-processor
6261cb0ef41Sopenharmony_ci
6271cb0ef41Sopenharmony_ci.PHONY: test-hash-seed
6281cb0ef41Sopenharmony_ci# Verifies the hash seed used by V8 for hashing is random.
6291cb0ef41Sopenharmony_citest-hash-seed: all
6301cb0ef41Sopenharmony_ci	$(NODE) test/pummel/test-hash-seed.js
6311cb0ef41Sopenharmony_ci
6321cb0ef41Sopenharmony_ci.PHONY: test-doc
6331cb0ef41Sopenharmony_citest-doc: doc-only lint-md ## Builds, lints, and verifies the docs.
6341cb0ef41Sopenharmony_ci	@if [ "$(shell $(node_use_openssl))" != "true" ]; then \
6351cb0ef41Sopenharmony_ci		echo "Skipping test-doc (no crypto)"; \
6361cb0ef41Sopenharmony_ci	else \
6371cb0ef41Sopenharmony_ci		$(PYTHON) tools/test.py $(PARALLEL_ARGS) doctool; \
6381cb0ef41Sopenharmony_ci	fi
6391cb0ef41Sopenharmony_ci
6401cb0ef41Sopenharmony_ci.PHONY: test-doc-ci
6411cb0ef41Sopenharmony_citest-doc-ci: doc-only
6421cb0ef41Sopenharmony_ci	$(PYTHON) tools/test.py --shell $(NODE) $(TEST_CI_ARGS) $(PARALLEL_ARGS) doctool
6431cb0ef41Sopenharmony_ci
6441cb0ef41Sopenharmony_ci.PHONY: test-known-issues
6451cb0ef41Sopenharmony_citest-known-issues: all
6461cb0ef41Sopenharmony_ci	$(PYTHON) tools/test.py $(PARALLEL_ARGS) known_issues
6471cb0ef41Sopenharmony_ci
6481cb0ef41Sopenharmony_ci# Related CI job: node-test-npm
6491cb0ef41Sopenharmony_ci.PHONY: test-npm
6501cb0ef41Sopenharmony_citest-npm: $(NODE_EXE) ## Run the npm test suite on deps/npm.
6511cb0ef41Sopenharmony_ci	$(NODE) tools/test-npm-package --install --logfile=test-npm.tap deps/npm test
6521cb0ef41Sopenharmony_ci
6531cb0ef41Sopenharmony_ci.PHONY: test-npm-publish
6541cb0ef41Sopenharmony_citest-npm-publish: $(NODE_EXE)
6551cb0ef41Sopenharmony_ci	npm_package_config_publishtest=true $(NODE) deps/npm/test/run.js
6561cb0ef41Sopenharmony_ci
6571cb0ef41Sopenharmony_ci.PHONY: test-js-native-api
6581cb0ef41Sopenharmony_citest-js-native-api: test-build-js-native-api
6591cb0ef41Sopenharmony_ci	$(PYTHON) tools/test.py $(PARALLEL_ARGS) --mode=$(BUILDTYPE_LOWER) js-native-api
6601cb0ef41Sopenharmony_ci
6611cb0ef41Sopenharmony_ci.PHONY: test-js-native-api-clean
6621cb0ef41Sopenharmony_ci.NOTPARALLEL: test-js-native-api-clean
6631cb0ef41Sopenharmony_citest-js-native-api-clean:
6641cb0ef41Sopenharmony_ci	$(RM) -r test/js-native-api/*/build
6651cb0ef41Sopenharmony_ci	$(RM) test/js-native-api/.buildstamp
6661cb0ef41Sopenharmony_ci
6671cb0ef41Sopenharmony_ci.PHONY: test-node-api
6681cb0ef41Sopenharmony_citest-node-api: test-build-node-api
6691cb0ef41Sopenharmony_ci	$(PYTHON) tools/test.py $(PARALLEL_ARGS) --mode=$(BUILDTYPE_LOWER) node-api
6701cb0ef41Sopenharmony_ci
6711cb0ef41Sopenharmony_ci.PHONY: test-node-api-clean
6721cb0ef41Sopenharmony_ci.NOTPARALLEL: test-node-api-clean
6731cb0ef41Sopenharmony_citest-node-api-clean:
6741cb0ef41Sopenharmony_ci	$(RM) -r test/node-api/*/build
6751cb0ef41Sopenharmony_ci	$(RM) test/node-api/.buildstamp
6761cb0ef41Sopenharmony_ci
6771cb0ef41Sopenharmony_ci.PHONY: test-addons
6781cb0ef41Sopenharmony_citest-addons: test-build test-js-native-api test-node-api
6791cb0ef41Sopenharmony_ci	$(PYTHON) tools/test.py $(PARALLEL_ARGS) --mode=$(BUILDTYPE_LOWER) addons
6801cb0ef41Sopenharmony_ci
6811cb0ef41Sopenharmony_ci.PHONY: test-addons-clean
6821cb0ef41Sopenharmony_ci.NOTPARALLEL: test-addons-clean
6831cb0ef41Sopenharmony_citest-addons-clean:
6841cb0ef41Sopenharmony_ci	$(RM) -r test/addons/??_*/
6851cb0ef41Sopenharmony_ci	$(RM) -r test/addons/*/build
6861cb0ef41Sopenharmony_ci	$(RM) test/addons/.buildstamp test/addons/.docbuildstamp
6871cb0ef41Sopenharmony_ci	$(MAKE) test-js-native-api-clean
6881cb0ef41Sopenharmony_ci	$(MAKE) test-node-api-clean
6891cb0ef41Sopenharmony_ci
6901cb0ef41Sopenharmony_ci.PHONY: test-async-hooks
6911cb0ef41Sopenharmony_citest-async-hooks:
6921cb0ef41Sopenharmony_ci	$(PYTHON) tools/test.py $(PARALLEL_ARGS) --mode=$(BUILDTYPE_LOWER) async-hooks
6931cb0ef41Sopenharmony_ci
6941cb0ef41Sopenharmony_ci.PHONY: test-with-async-hooks
6951cb0ef41Sopenharmony_citest-with-async-hooks:
6961cb0ef41Sopenharmony_ci	$(MAKE) build-addons
6971cb0ef41Sopenharmony_ci	$(MAKE) build-js-native-api-tests
6981cb0ef41Sopenharmony_ci	$(MAKE) build-node-api-tests
6991cb0ef41Sopenharmony_ci	$(MAKE) cctest
7001cb0ef41Sopenharmony_ci	NODE_TEST_WITH_ASYNC_HOOKS=1 $(PYTHON) tools/test.py $(PARALLEL_ARGS) --mode=$(BUILDTYPE_LOWER) \
7011cb0ef41Sopenharmony_ci		$(JS_SUITES) \
7021cb0ef41Sopenharmony_ci		$(NATIVE_SUITES)
7031cb0ef41Sopenharmony_ci
7041cb0ef41Sopenharmony_ci
7051cb0ef41Sopenharmony_ci.PHONY: test-v8
7061cb0ef41Sopenharmony_ci.PHONY: test-v8-all
7071cb0ef41Sopenharmony_ci.PHONY: test-v8-benchmarks
7081cb0ef41Sopenharmony_ci.PHONY: test-v8-intl
7091cb0ef41Sopenharmony_ci.PHONY: test-v8-updates
7101cb0ef41Sopenharmony_ciifneq ("","$(wildcard deps/v8/tools/run-tests.py)")
7111cb0ef41Sopenharmony_ci# Related CI job: node-test-commit-v8-linux
7121cb0ef41Sopenharmony_citest-v8: v8  ## Runs the V8 test suite on deps/v8.
7131cb0ef41Sopenharmony_ci	export PATH="$(NO_BIN_OVERRIDE_PATH)" && \
7141cb0ef41Sopenharmony_ci		$(PYTHON) deps/v8/tools/run-tests.py --gn --arch=$(V8_ARCH) $(V8_TEST_OPTIONS) \
7151cb0ef41Sopenharmony_ci				mjsunit cctest debugger inspector message preparser \
7161cb0ef41Sopenharmony_ci				$(TAP_V8)
7171cb0ef41Sopenharmony_ci	$(call convert_to_junit,$(TAP_V8_JSON))
7181cb0ef41Sopenharmony_ci	$(info Testing hash seed)
7191cb0ef41Sopenharmony_ci	$(MAKE) test-hash-seed
7201cb0ef41Sopenharmony_ci
7211cb0ef41Sopenharmony_citest-v8-intl: v8
7221cb0ef41Sopenharmony_ci	export PATH="$(NO_BIN_OVERRIDE_PATH)" && \
7231cb0ef41Sopenharmony_ci		$(PYTHON) deps/v8/tools/run-tests.py --gn --arch=$(V8_ARCH) \
7241cb0ef41Sopenharmony_ci				intl \
7251cb0ef41Sopenharmony_ci				$(TAP_V8_INTL)
7261cb0ef41Sopenharmony_ci	$(call convert_to_junit,$(TAP_V8_INTL_JSON))
7271cb0ef41Sopenharmony_ci
7281cb0ef41Sopenharmony_citest-v8-benchmarks: v8
7291cb0ef41Sopenharmony_ci	export PATH="$(NO_BIN_OVERRIDE_PATH)" && \
7301cb0ef41Sopenharmony_ci		$(PYTHON) deps/v8/tools/run-tests.py --gn --arch=$(V8_ARCH) \
7311cb0ef41Sopenharmony_ci				benchmarks \
7321cb0ef41Sopenharmony_ci				$(TAP_V8_BENCHMARKS)
7331cb0ef41Sopenharmony_ci	$(call convert_to_junit,$(TAP_V8_BENCHMARKS_JSON))
7341cb0ef41Sopenharmony_ci
7351cb0ef41Sopenharmony_citest-v8-updates:
7361cb0ef41Sopenharmony_ci	$(PYTHON) tools/test.py $(PARALLEL_ARGS) --mode=$(BUILDTYPE_LOWER) v8-updates
7371cb0ef41Sopenharmony_ci
7381cb0ef41Sopenharmony_citest-v8-all: test-v8 test-v8-intl test-v8-benchmarks test-v8-updates
7391cb0ef41Sopenharmony_ci# runs all v8 tests
7401cb0ef41Sopenharmony_cielse
7411cb0ef41Sopenharmony_citest-v8 test-v8-intl test-v8-benchmarks test-v8-all:
7421cb0ef41Sopenharmony_ci	$(warning Testing V8 is not available through the source tarball.)
7431cb0ef41Sopenharmony_ci	$(warning Use the git repo instead: $$ git clone https://github.com/nodejs/node.git)
7441cb0ef41Sopenharmony_ciendif
7451cb0ef41Sopenharmony_ci
7461cb0ef41Sopenharmony_ciapidoc_dirs = out/doc out/doc/api out/doc/api/assets
7471cb0ef41Sopenharmony_ciapidoc_sources = $(wildcard doc/api/*.md)
7481cb0ef41Sopenharmony_ciapidocs_html = $(addprefix out/,$(apidoc_sources:.md=.html))
7491cb0ef41Sopenharmony_ciapidocs_json = $(addprefix out/,$(apidoc_sources:.md=.json))
7501cb0ef41Sopenharmony_ci
7511cb0ef41Sopenharmony_ciapiassets = $(subst api_assets,api/assets,$(addprefix out/,$(wildcard doc/api_assets/*)))
7521cb0ef41Sopenharmony_ci
7531cb0ef41Sopenharmony_citools/doc/node_modules: tools/doc/package.json
7541cb0ef41Sopenharmony_ci	@if [ "$(shell $(node_use_openssl))" != "true" ]; then \
7551cb0ef41Sopenharmony_ci		echo "Skipping tools/doc/node_modules (no crypto)"; \
7561cb0ef41Sopenharmony_ci	else \
7571cb0ef41Sopenharmony_ci		cd tools/doc && $(call available-node,$(run-npm-ci)) \
7581cb0ef41Sopenharmony_ci	fi
7591cb0ef41Sopenharmony_ci
7601cb0ef41Sopenharmony_ci.PHONY: doc-only
7611cb0ef41Sopenharmony_cidoc-only: tools/doc/node_modules \
7621cb0ef41Sopenharmony_ci	$(apidoc_dirs) $(apiassets)  ## Builds the docs with the local or the global Node.js binary.
7631cb0ef41Sopenharmony_ci	@if [ "$(shell $(node_use_openssl))" != "true" ]; then \
7641cb0ef41Sopenharmony_ci		echo "Skipping doc-only (no crypto)"; \
7651cb0ef41Sopenharmony_ci	else \
7661cb0ef41Sopenharmony_ci		$(MAKE) out/doc/api/all.html out/doc/api/all.json out/doc/api/stability; \
7671cb0ef41Sopenharmony_ci	fi
7681cb0ef41Sopenharmony_ci
7691cb0ef41Sopenharmony_ci.PHONY: doc
7701cb0ef41Sopenharmony_cidoc: $(NODE_EXE) doc-only
7711cb0ef41Sopenharmony_ci
7721cb0ef41Sopenharmony_ciout/doc:
7731cb0ef41Sopenharmony_ci	mkdir -p $@
7741cb0ef41Sopenharmony_ci
7751cb0ef41Sopenharmony_ci# If it's a source tarball, doc/api already contains the generated docs.
7761cb0ef41Sopenharmony_ci# Just copy everything under doc/api over.
7771cb0ef41Sopenharmony_ciout/doc/api: doc/api
7781cb0ef41Sopenharmony_ci	mkdir -p $@
7791cb0ef41Sopenharmony_ci	cp -r doc/api out/doc
7801cb0ef41Sopenharmony_ci
7811cb0ef41Sopenharmony_ci# If it's a source tarball, assets are already in doc/api/assets
7821cb0ef41Sopenharmony_ciout/doc/api/assets:
7831cb0ef41Sopenharmony_ci	mkdir -p $@
7841cb0ef41Sopenharmony_ci	if [ -d doc/api/assets ]; then cp -r doc/api/assets out/doc/api; fi;
7851cb0ef41Sopenharmony_ci
7861cb0ef41Sopenharmony_ci# If it's not a source tarball, we need to copy assets from doc/api_assets
7871cb0ef41Sopenharmony_ciout/doc/api/assets/%: doc/api_assets/% | out/doc/api/assets
7881cb0ef41Sopenharmony_ci	@cp $< $@ ; $(RM) out/doc/api/assets/README.md
7891cb0ef41Sopenharmony_ci
7901cb0ef41Sopenharmony_ci
7911cb0ef41Sopenharmony_cirun-npm-ci = $(PWD)/$(NPM) ci
7921cb0ef41Sopenharmony_ci
7931cb0ef41Sopenharmony_ciLINK_DATA = out/doc/apilinks.json
7941cb0ef41Sopenharmony_ciVERSIONS_DATA = out/previous-doc-versions.json
7951cb0ef41Sopenharmony_cigen-api = tools/doc/generate.mjs --node-version=$(FULLVERSION) \
7961cb0ef41Sopenharmony_ci		--apilinks=$(LINK_DATA) $< --output-directory=out/doc/api \
7971cb0ef41Sopenharmony_ci		--versions-file=$(VERSIONS_DATA)
7981cb0ef41Sopenharmony_cigen-apilink = tools/doc/apilinks.mjs $(LINK_DATA) $(wildcard lib/*.js)
7991cb0ef41Sopenharmony_ci
8001cb0ef41Sopenharmony_ci$(LINK_DATA): $(wildcard lib/*.js) tools/doc/apilinks.mjs | out/doc
8011cb0ef41Sopenharmony_ci	$(call available-node, $(gen-apilink))
8021cb0ef41Sopenharmony_ci
8031cb0ef41Sopenharmony_ci# Regenerate previous versions data if the current version changes
8041cb0ef41Sopenharmony_ci$(VERSIONS_DATA): CHANGELOG.md src/node_version.h tools/doc/versions.mjs
8051cb0ef41Sopenharmony_ci	$(call available-node, tools/doc/versions.mjs $@)
8061cb0ef41Sopenharmony_ci
8071cb0ef41Sopenharmony_cinode_use_icu = $(call available-node,"-p" "typeof Intl === 'object'")
8081cb0ef41Sopenharmony_ci
8091cb0ef41Sopenharmony_ciout/doc/api/%.json out/doc/api/%.html: doc/api/%.md tools/doc/generate.mjs \
8101cb0ef41Sopenharmony_ci	tools/doc/markdown.mjs tools/doc/html.mjs tools/doc/json.mjs \
8111cb0ef41Sopenharmony_ci	tools/doc/apilinks.mjs $(VERSIONS_DATA) | $(LINK_DATA) out/doc/api
8121cb0ef41Sopenharmony_ci	@if [ "$(shell $(node_use_icu))" != "true" ]; then \
8131cb0ef41Sopenharmony_ci		echo "Skipping documentation generation (no ICU)"; \
8141cb0ef41Sopenharmony_ci	else \
8151cb0ef41Sopenharmony_ci		$(call available-node, $(gen-api)) \
8161cb0ef41Sopenharmony_ci	fi
8171cb0ef41Sopenharmony_ci
8181cb0ef41Sopenharmony_ciout/doc/api/all.html: $(apidocs_html) tools/doc/allhtml.mjs \
8191cb0ef41Sopenharmony_ci	tools/doc/apilinks.mjs | out/doc/api
8201cb0ef41Sopenharmony_ci	@if [ "$(shell $(node_use_icu))" != "true" ]; then \
8211cb0ef41Sopenharmony_ci		echo "Skipping HTML single-page doc generation (no ICU)"; \
8221cb0ef41Sopenharmony_ci	else \
8231cb0ef41Sopenharmony_ci		$(call available-node, tools/doc/allhtml.mjs) \
8241cb0ef41Sopenharmony_ci	fi
8251cb0ef41Sopenharmony_ci
8261cb0ef41Sopenharmony_ciout/doc/api/all.json: $(apidocs_json) tools/doc/alljson.mjs | out/doc/api
8271cb0ef41Sopenharmony_ci	@if [ "$(shell $(node_use_icu))" != "true" ]; then \
8281cb0ef41Sopenharmony_ci		echo "Skipping JSON single-file generation (no ICU)"; \
8291cb0ef41Sopenharmony_ci	else \
8301cb0ef41Sopenharmony_ci		$(call available-node, tools/doc/alljson.mjs) \
8311cb0ef41Sopenharmony_ci	fi
8321cb0ef41Sopenharmony_ci
8331cb0ef41Sopenharmony_ci.PHONY: out/doc/api/stability
8341cb0ef41Sopenharmony_ciout/doc/api/stability: out/doc/api/all.json tools/doc/stability.mjs | out/doc/api
8351cb0ef41Sopenharmony_ci	@if [ "$(shell $(node_use_icu))" != "true" ]; then \
8361cb0ef41Sopenharmony_ci		echo "Skipping stability indicator generation (no ICU)"; \
8371cb0ef41Sopenharmony_ci	else \
8381cb0ef41Sopenharmony_ci		$(call available-node, tools/doc/stability.mjs) \
8391cb0ef41Sopenharmony_ci	fi
8401cb0ef41Sopenharmony_ci
8411cb0ef41Sopenharmony_ci.PHONY: docopen
8421cb0ef41Sopenharmony_cidocopen: out/doc/api/all.html
8431cb0ef41Sopenharmony_ci	@$(PYTHON) -mwebbrowser file://$(abspath $<)
8441cb0ef41Sopenharmony_ci
8451cb0ef41Sopenharmony_ci.PHONY: docserve
8461cb0ef41Sopenharmony_cidocserve: $(apidocs_html) $(apiassets)
8471cb0ef41Sopenharmony_ci	@$(PYTHON) -m http.server 8000 --bind 127.0.0.1 --directory out/doc/api
8481cb0ef41Sopenharmony_ci
8491cb0ef41Sopenharmony_ci.PHONY: docclean
8501cb0ef41Sopenharmony_ci.NOTPARALLEL: docclean
8511cb0ef41Sopenharmony_cidocclean:
8521cb0ef41Sopenharmony_ci	$(RM) -r out/doc
8531cb0ef41Sopenharmony_ci	$(RM) "$(VERSIONS_DATA)"
8541cb0ef41Sopenharmony_ci
8551cb0ef41Sopenharmony_ciRAWVER=$(shell $(PYTHON) tools/getnodeversion.py)
8561cb0ef41Sopenharmony_ciVERSION=v$(RAWVER)
8571cb0ef41Sopenharmony_ciCHANGELOG=doc/changelogs/CHANGELOG_V$(firstword $(subst ., ,$(RAWVER))).md
8581cb0ef41Sopenharmony_ci
8591cb0ef41Sopenharmony_ci# For nightly builds, you must set DISTTYPE to "nightly", "next-nightly" or
8601cb0ef41Sopenharmony_ci# "custom". For the nightly and next-nightly case, you need to set DATESTRING
8611cb0ef41Sopenharmony_ci# and COMMIT in order to properly name the build.
8621cb0ef41Sopenharmony_ci# For the rc case you need to set CUSTOMTAG to an appropriate CUSTOMTAG number
8631cb0ef41Sopenharmony_ci
8641cb0ef41Sopenharmony_ciifndef DISTTYPE
8651cb0ef41Sopenharmony_ciDISTTYPE=release
8661cb0ef41Sopenharmony_ciendif
8671cb0ef41Sopenharmony_ciifeq ($(DISTTYPE),release)
8681cb0ef41Sopenharmony_ciFULLVERSION=$(VERSION)
8691cb0ef41Sopenharmony_cielse # ifeq ($(DISTTYPE),release)
8701cb0ef41Sopenharmony_ciifeq ($(DISTTYPE),custom)
8711cb0ef41Sopenharmony_ciifndef CUSTOMTAG
8721cb0ef41Sopenharmony_ci$(error CUSTOMTAG is not set for DISTTYPE=custom)
8731cb0ef41Sopenharmony_ciendif # ifndef CUSTOMTAG
8741cb0ef41Sopenharmony_ciTAG=$(CUSTOMTAG)
8751cb0ef41Sopenharmony_cielse # ifeq ($(DISTTYPE),custom)
8761cb0ef41Sopenharmony_ciifndef DATESTRING
8771cb0ef41Sopenharmony_ci$(error DATESTRING is not set for nightly)
8781cb0ef41Sopenharmony_ciendif # ifndef DATESTRING
8791cb0ef41Sopenharmony_ciifndef COMMIT
8801cb0ef41Sopenharmony_ci$(error COMMIT is not set for nightly)
8811cb0ef41Sopenharmony_ciendif # ifndef COMMIT
8821cb0ef41Sopenharmony_ciifneq ($(DISTTYPE),nightly)
8831cb0ef41Sopenharmony_ciifneq ($(DISTTYPE),next-nightly)
8841cb0ef41Sopenharmony_ci$(error DISTTYPE is not release, custom, nightly or next-nightly)
8851cb0ef41Sopenharmony_ciendif # ifneq ($(DISTTYPE),next-nightly)
8861cb0ef41Sopenharmony_ciendif # ifneq ($(DISTTYPE),nightly)
8871cb0ef41Sopenharmony_ciTAG=$(DISTTYPE)$(DATESTRING)$(COMMIT)
8881cb0ef41Sopenharmony_ciendif # ifeq ($(DISTTYPE),custom)
8891cb0ef41Sopenharmony_ciFULLVERSION=$(VERSION)-$(TAG)
8901cb0ef41Sopenharmony_ciendif # ifeq ($(DISTTYPE),release)
8911cb0ef41Sopenharmony_ci
8921cb0ef41Sopenharmony_ciDISTTYPEDIR ?= $(DISTTYPE)
8931cb0ef41Sopenharmony_ciRELEASE=$(shell sed -ne 's/\#define NODE_VERSION_IS_RELEASE \([01]\)/\1/p' src/node_version.h)
8941cb0ef41Sopenharmony_ciPLATFORM=$(shell uname | tr '[:upper:]' '[:lower:]')
8951cb0ef41Sopenharmony_ciifeq ($(findstring os/390,$PLATFORM),os/390)
8961cb0ef41Sopenharmony_ciPLATFORM ?= os390
8971cb0ef41Sopenharmony_ciendif
8981cb0ef41Sopenharmony_ciNPMVERSION=v$(shell cat deps/npm/package.json | grep '^  "version"' | sed 's/^[^:]*: "\([^"]*\)",.*/\1/')
8991cb0ef41Sopenharmony_ci
9001cb0ef41Sopenharmony_ciUNAME_M=$(shell uname -m)
9011cb0ef41Sopenharmony_ciifeq ($(findstring x86_64,$(UNAME_M)),x86_64)
9021cb0ef41Sopenharmony_ciDESTCPU ?= x64
9031cb0ef41Sopenharmony_cielse
9041cb0ef41Sopenharmony_ciifeq ($(findstring amd64,$(UNAME_M)),amd64)
9051cb0ef41Sopenharmony_ciDESTCPU ?= x64
9061cb0ef41Sopenharmony_cielse
9071cb0ef41Sopenharmony_ciifeq ($(findstring ppc64,$(UNAME_M)),ppc64)
9081cb0ef41Sopenharmony_ciDESTCPU ?= ppc64
9091cb0ef41Sopenharmony_cielse
9101cb0ef41Sopenharmony_ciifeq ($(findstring ppc,$(UNAME_M)),ppc)
9111cb0ef41Sopenharmony_ciDESTCPU ?= ppc
9121cb0ef41Sopenharmony_cielse
9131cb0ef41Sopenharmony_ciifeq ($(findstring s390x,$(UNAME_M)),s390x)
9141cb0ef41Sopenharmony_ciDESTCPU ?= s390x
9151cb0ef41Sopenharmony_cielse
9161cb0ef41Sopenharmony_ciifeq ($(findstring s390,$(UNAME_M)),s390)
9171cb0ef41Sopenharmony_ciDESTCPU ?= s390
9181cb0ef41Sopenharmony_cielse
9191cb0ef41Sopenharmony_ciifeq ($(findstring OS/390,$(shell uname -s)),OS/390)
9201cb0ef41Sopenharmony_ciDESTCPU ?= s390x
9211cb0ef41Sopenharmony_cielse
9221cb0ef41Sopenharmony_ciifeq ($(findstring arm64,$(UNAME_M)),arm64)
9231cb0ef41Sopenharmony_ciDESTCPU ?= arm64
9241cb0ef41Sopenharmony_cielse
9251cb0ef41Sopenharmony_ciifeq ($(findstring arm,$(UNAME_M)),arm)
9261cb0ef41Sopenharmony_ciDESTCPU ?= arm
9271cb0ef41Sopenharmony_cielse
9281cb0ef41Sopenharmony_ciifeq ($(findstring aarch64,$(UNAME_M)),aarch64)
9291cb0ef41Sopenharmony_ciDESTCPU ?= arm64
9301cb0ef41Sopenharmony_cielse
9311cb0ef41Sopenharmony_ciifeq ($(findstring powerpc,$(shell uname -p)),powerpc)
9321cb0ef41Sopenharmony_ciDESTCPU ?= ppc64
9331cb0ef41Sopenharmony_cielse
9341cb0ef41Sopenharmony_ciifeq ($(findstring riscv64,$(UNAME_M)),riscv64)
9351cb0ef41Sopenharmony_ciDESTCPU ?= riscv64
9361cb0ef41Sopenharmony_cielse
9371cb0ef41Sopenharmony_ciDESTCPU ?= x86
9381cb0ef41Sopenharmony_ciendif
9391cb0ef41Sopenharmony_ciendif
9401cb0ef41Sopenharmony_ciendif
9411cb0ef41Sopenharmony_ciendif
9421cb0ef41Sopenharmony_ciendif
9431cb0ef41Sopenharmony_ciendif
9441cb0ef41Sopenharmony_ciendif
9451cb0ef41Sopenharmony_ciendif
9461cb0ef41Sopenharmony_ciendif
9471cb0ef41Sopenharmony_ciendif
9481cb0ef41Sopenharmony_ciendif
9491cb0ef41Sopenharmony_ciendif
9501cb0ef41Sopenharmony_ciifeq ($(DESTCPU),x64)
9511cb0ef41Sopenharmony_ciARCH=x64
9521cb0ef41Sopenharmony_cielse
9531cb0ef41Sopenharmony_ciifeq ($(DESTCPU),arm)
9541cb0ef41Sopenharmony_ciARCH=arm
9551cb0ef41Sopenharmony_cielse
9561cb0ef41Sopenharmony_ciifeq ($(DESTCPU),arm64)
9571cb0ef41Sopenharmony_ciARCH=arm64
9581cb0ef41Sopenharmony_cielse
9591cb0ef41Sopenharmony_ciifeq ($(DESTCPU),ppc64)
9601cb0ef41Sopenharmony_ciARCH=ppc64
9611cb0ef41Sopenharmony_cielse
9621cb0ef41Sopenharmony_ciifeq ($(DESTCPU),ppc)
9631cb0ef41Sopenharmony_ciARCH=ppc
9641cb0ef41Sopenharmony_cielse
9651cb0ef41Sopenharmony_ciifeq ($(DESTCPU),s390)
9661cb0ef41Sopenharmony_ciARCH=s390
9671cb0ef41Sopenharmony_cielse
9681cb0ef41Sopenharmony_ciifeq ($(DESTCPU),s390x)
9691cb0ef41Sopenharmony_ciARCH=s390x
9701cb0ef41Sopenharmony_cielse
9711cb0ef41Sopenharmony_ciifeq ($(DESTCPU),riscv64)
9721cb0ef41Sopenharmony_ciARCH=riscv64
9731cb0ef41Sopenharmony_cielse
9741cb0ef41Sopenharmony_ciARCH=x86
9751cb0ef41Sopenharmony_ciendif
9761cb0ef41Sopenharmony_ciendif
9771cb0ef41Sopenharmony_ciendif
9781cb0ef41Sopenharmony_ciendif
9791cb0ef41Sopenharmony_ciendif
9801cb0ef41Sopenharmony_ciendif
9811cb0ef41Sopenharmony_ciendif
9821cb0ef41Sopenharmony_ciendif
9831cb0ef41Sopenharmony_ci
9841cb0ef41Sopenharmony_ci# node and v8 use different arch names (e.g. node 'x86' vs v8 'ia32').
9851cb0ef41Sopenharmony_ci# pass the proper v8 arch name to $V8_ARCH based on user-specified $DESTCPU.
9861cb0ef41Sopenharmony_ciifeq ($(DESTCPU),x86)
9871cb0ef41Sopenharmony_ciV8_ARCH=ia32
9881cb0ef41Sopenharmony_cielse
9891cb0ef41Sopenharmony_ciV8_ARCH ?= $(DESTCPU)
9901cb0ef41Sopenharmony_ci
9911cb0ef41Sopenharmony_ciendif
9921cb0ef41Sopenharmony_ci
9931cb0ef41Sopenharmony_ci# enforce "x86" over "ia32" as the generally accepted way of referring to 32-bit intel
9941cb0ef41Sopenharmony_ciifeq ($(ARCH),ia32)
9951cb0ef41Sopenharmony_cioverride ARCH=x86
9961cb0ef41Sopenharmony_ciendif
9971cb0ef41Sopenharmony_ciifeq ($(DESTCPU),ia32)
9981cb0ef41Sopenharmony_cioverride DESTCPU=x86
9991cb0ef41Sopenharmony_ciendif
10001cb0ef41Sopenharmony_ci
10011cb0ef41Sopenharmony_ciTARNAME=node-$(FULLVERSION)
10021cb0ef41Sopenharmony_ciTARBALL=$(TARNAME).tar
10031cb0ef41Sopenharmony_ci# Custom user-specified variation, use it directly
10041cb0ef41Sopenharmony_ciifdef VARIATION
10051cb0ef41Sopenharmony_ciBINARYNAME=$(TARNAME)-$(PLATFORM)-$(ARCH)-$(VARIATION)
10061cb0ef41Sopenharmony_cielse
10071cb0ef41Sopenharmony_ciBINARYNAME=$(TARNAME)-$(PLATFORM)-$(ARCH)
10081cb0ef41Sopenharmony_ciendif
10091cb0ef41Sopenharmony_ciBINARYTAR=$(BINARYNAME).tar
10101cb0ef41Sopenharmony_ci# OSX doesn't have xz installed by default, http://macpkg.sourceforge.net/
10111cb0ef41Sopenharmony_ciHAS_XZ ?= $(shell command -v xz > /dev/null 2>&1; [ $$? -eq 0 ] && echo 1 || echo 0)
10121cb0ef41Sopenharmony_ci# Supply SKIP_XZ=1 to explicitly skip .tar.xz creation
10131cb0ef41Sopenharmony_ciSKIP_XZ ?= 0
10141cb0ef41Sopenharmony_ciXZ = $(shell [ $(HAS_XZ) -eq 1 ] && [ $(SKIP_XZ) -eq 0 ] && echo 1 || echo 0)
10151cb0ef41Sopenharmony_ciXZ_COMPRESSION ?= 9e
10161cb0ef41Sopenharmony_ciPKG=$(TARNAME).pkg
10171cb0ef41Sopenharmony_ciMACOSOUTDIR=out/macos
10181cb0ef41Sopenharmony_ci
10191cb0ef41Sopenharmony_ci.PHONY: check-xz
10201cb0ef41Sopenharmony_ciifeq ($(SKIP_XZ), 1)
10211cb0ef41Sopenharmony_cicheck-xz:
10221cb0ef41Sopenharmony_ci	$(info SKIP_XZ=1 supplied, skipping .tar.xz creation)
10231cb0ef41Sopenharmony_cielse
10241cb0ef41Sopenharmony_ciifeq ($(HAS_XZ), 1)
10251cb0ef41Sopenharmony_cicheck-xz:
10261cb0ef41Sopenharmony_cielse
10271cb0ef41Sopenharmony_cicheck-xz:
10281cb0ef41Sopenharmony_ci	$(error No xz command, cannot continue)
10291cb0ef41Sopenharmony_ciendif
10301cb0ef41Sopenharmony_ciendif
10311cb0ef41Sopenharmony_ci
10321cb0ef41Sopenharmony_ci.PHONY: release-only
10331cb0ef41Sopenharmony_cirelease-only: check-xz
10341cb0ef41Sopenharmony_ci	@if [ "$(DISTTYPE)" = "release" ] && `grep -q REPLACEME doc/api/*.md`; then \
10351cb0ef41Sopenharmony_ci		echo 'Please update REPLACEME tags in the following doc/api/*.md files (See doc/contributing/releases.md):\n' ; \
10361cb0ef41Sopenharmony_ci		REPLACEMES="$(shell grep -l REPLACEME doc/api/*.md)" ; \
10371cb0ef41Sopenharmony_ci		echo "$$REPLACEMES\n" | tr " " "\n" ; \
10381cb0ef41Sopenharmony_ci		exit 1 ; \
10391cb0ef41Sopenharmony_ci	fi
10401cb0ef41Sopenharmony_ci	@if [ "$(DISTTYPE)" = "release" ] && \
10411cb0ef41Sopenharmony_ci		`grep -q DEP...X doc/api/deprecations.md`; then \
10421cb0ef41Sopenharmony_ci		echo 'Please update DEP...X in doc/api/deprecations.md (See doc/contributing/releases.md)' ; \
10431cb0ef41Sopenharmony_ci		exit 1 ; \
10441cb0ef41Sopenharmony_ci	fi
10451cb0ef41Sopenharmony_ci	@if [ "$(shell git status --porcelain | egrep -v '^\?\? ')" = "" ]; then \
10461cb0ef41Sopenharmony_ci		exit 0 ; \
10471cb0ef41Sopenharmony_ci	else \
10481cb0ef41Sopenharmony_ci		echo "" >&2 ; \
10491cb0ef41Sopenharmony_ci		echo "The git repository is not clean." >&2 ; \
10501cb0ef41Sopenharmony_ci		echo "Please commit changes before building release tarball." >&2 ; \
10511cb0ef41Sopenharmony_ci		echo "" >&2 ; \
10521cb0ef41Sopenharmony_ci		git status --porcelain | egrep -v '^\?\?' >&2 ; \
10531cb0ef41Sopenharmony_ci		echo "" >&2 ; \
10541cb0ef41Sopenharmony_ci		exit 1 ; \
10551cb0ef41Sopenharmony_ci	fi
10561cb0ef41Sopenharmony_ci	@if [ "$(DISTTYPE)" != "release" ] || [ "$(RELEASE)" = "1" ]; then \
10571cb0ef41Sopenharmony_ci		exit 0; \
10581cb0ef41Sopenharmony_ci	else \
10591cb0ef41Sopenharmony_ci		echo "" >&2 ; \
10601cb0ef41Sopenharmony_ci		echo "#NODE_VERSION_IS_RELEASE is set to $(RELEASE)." >&2 ; \
10611cb0ef41Sopenharmony_ci		echo "Did you remember to update src/node_version.h?" >&2 ; \
10621cb0ef41Sopenharmony_ci		echo "" >&2 ; \
10631cb0ef41Sopenharmony_ci		exit 1 ; \
10641cb0ef41Sopenharmony_ci	fi
10651cb0ef41Sopenharmony_ci	@if [ "$(RELEASE)" = "0" ] || [ -f "$(CHANGELOG)" ]; then \
10661cb0ef41Sopenharmony_ci		exit 0; \
10671cb0ef41Sopenharmony_ci	else \
10681cb0ef41Sopenharmony_ci		echo "" >&2 ; \
10691cb0ef41Sopenharmony_ci		echo "#NODE_VERSION_IS_RELEASE is set to $(RELEASE) but " >&2 ; \
10701cb0ef41Sopenharmony_ci		echo "$(CHANGELOG) does not exist." >&2 ; \
10711cb0ef41Sopenharmony_ci		echo "" >&2 ; \
10721cb0ef41Sopenharmony_ci		exit 1 ; \
10731cb0ef41Sopenharmony_ci	fi
10741cb0ef41Sopenharmony_ci
10751cb0ef41Sopenharmony_ci$(PKG): release-only
10761cb0ef41Sopenharmony_ci# pkg building is currently only supported on an ARM64 macOS host for
10771cb0ef41Sopenharmony_ci# ease of compiling fat-binaries for both macOS architectures.
10781cb0ef41Sopenharmony_ciifneq ($(OSTYPE),darwin)
10791cb0ef41Sopenharmony_ci	$(warning Invalid OSTYPE)
10801cb0ef41Sopenharmony_ci	$(error OSTYPE should be `darwin` currently is $(OSTYPE))
10811cb0ef41Sopenharmony_ciendif
10821cb0ef41Sopenharmony_ciifneq ($(ARCHTYPE),arm64)
10831cb0ef41Sopenharmony_ci	$(warning Invalid ARCHTYPE)
10841cb0ef41Sopenharmony_ci	$(error ARCHTYPE should be `arm64` currently is $(ARCHTYPE))
10851cb0ef41Sopenharmony_ciendif
10861cb0ef41Sopenharmony_ci	$(RM) -r $(MACOSOUTDIR)
10871cb0ef41Sopenharmony_ci	mkdir -p $(MACOSOUTDIR)/installer/productbuild
10881cb0ef41Sopenharmony_ci	cat tools/macos-installer/productbuild/distribution.xml.tmpl  \
10891cb0ef41Sopenharmony_ci		| sed -E "s/\\{nodeversion\\}/$(FULLVERSION)/g" \
10901cb0ef41Sopenharmony_ci		| sed -E "s/\\{npmversion\\}/$(NPMVERSION)/g" \
10911cb0ef41Sopenharmony_ci	>$(MACOSOUTDIR)/installer/productbuild/distribution.xml ; \
10921cb0ef41Sopenharmony_ci
10931cb0ef41Sopenharmony_ci	@for dirname in tools/macos-installer/productbuild/Resources/*/; do \
10941cb0ef41Sopenharmony_ci		lang=$$(basename $$dirname) ; \
10951cb0ef41Sopenharmony_ci		mkdir -p $(MACOSOUTDIR)/installer/productbuild/Resources/$$lang ; \
10961cb0ef41Sopenharmony_ci		printf "Found localization directory $$dirname\n" ; \
10971cb0ef41Sopenharmony_ci		cat $$dirname/welcome.html.tmpl  \
10981cb0ef41Sopenharmony_ci			| sed -E "s/\\{nodeversion\\}/$(FULLVERSION)/g" \
10991cb0ef41Sopenharmony_ci			| sed -E "s/\\{npmversion\\}/$(NPMVERSION)/g"  \
11001cb0ef41Sopenharmony_ci		>$(MACOSOUTDIR)/installer/productbuild/Resources/$$lang/welcome.html ; \
11011cb0ef41Sopenharmony_ci		cat $$dirname/conclusion.html.tmpl  \
11021cb0ef41Sopenharmony_ci			| sed -E "s/\\{nodeversion\\}/$(FULLVERSION)/g" \
11031cb0ef41Sopenharmony_ci			| sed -E "s/\\{npmversion\\}/$(NPMVERSION)/g"  \
11041cb0ef41Sopenharmony_ci		>$(MACOSOUTDIR)/installer/productbuild/Resources/$$lang/conclusion.html ; \
11051cb0ef41Sopenharmony_ci	done
11061cb0ef41Sopenharmony_ci	CC_host="cc -arch x86_64" CXX_host="c++ -arch x86_64"  \
11071cb0ef41Sopenharmony_ci	CC_target="cc -arch x86_64" CXX_target="c++ -arch x86_64" \
11081cb0ef41Sopenharmony_ci	CC="cc -arch x86_64" CXX="c++ -arch x86_64" $(PYTHON) ./configure \
11091cb0ef41Sopenharmony_ci		--dest-cpu=x86_64 \
11101cb0ef41Sopenharmony_ci		--tag=$(TAG) \
11111cb0ef41Sopenharmony_ci		--release-urlbase=$(RELEASE_URLBASE) \
11121cb0ef41Sopenharmony_ci		$(CONFIG_FLAGS) $(BUILD_RELEASE_FLAGS)
11131cb0ef41Sopenharmony_ci	arch -x86_64 $(MAKE) install V=$(V) DESTDIR=$(MACOSOUTDIR)/dist/x64/node
11141cb0ef41Sopenharmony_ci	SIGN="$(CODESIGN_CERT)" PKGDIR="$(MACOSOUTDIR)/dist/x64/node/usr/local" sh \
11151cb0ef41Sopenharmony_ci		tools/osx-codesign.sh
11161cb0ef41Sopenharmony_ci	$(PYTHON) ./configure \
11171cb0ef41Sopenharmony_ci		--dest-cpu=arm64 \
11181cb0ef41Sopenharmony_ci		--tag=$(TAG) \
11191cb0ef41Sopenharmony_ci		--release-urlbase=$(RELEASE_URLBASE) \
11201cb0ef41Sopenharmony_ci		$(CONFIG_FLAGS) $(BUILD_RELEASE_FLAGS)
11211cb0ef41Sopenharmony_ci	$(MAKE) install V=$(V) DESTDIR=$(MACOSOUTDIR)/dist/node
11221cb0ef41Sopenharmony_ci	SIGN="$(CODESIGN_CERT)" PKGDIR="$(MACOSOUTDIR)/dist/node/usr/local" sh \
11231cb0ef41Sopenharmony_ci		tools/osx-codesign.sh
11241cb0ef41Sopenharmony_ci	lipo $(MACOSOUTDIR)/dist/x64/node/usr/local/bin/node \
11251cb0ef41Sopenharmony_ci		$(MACOSOUTDIR)/dist/node/usr/local/bin/node \
11261cb0ef41Sopenharmony_ci		-output $(MACOSOUTDIR)/dist/node/usr/local/bin/node \
11271cb0ef41Sopenharmony_ci		-create
11281cb0ef41Sopenharmony_ci	mkdir -p $(MACOSOUTDIR)/dist/npm/usr/local/lib/node_modules
11291cb0ef41Sopenharmony_ci	mkdir -p $(MACOSOUTDIR)/pkgs
11301cb0ef41Sopenharmony_ci	mv $(MACOSOUTDIR)/dist/node/usr/local/lib/node_modules/npm \
11311cb0ef41Sopenharmony_ci		$(MACOSOUTDIR)/dist/npm/usr/local/lib/node_modules
11321cb0ef41Sopenharmony_ci	unlink $(MACOSOUTDIR)/dist/node/usr/local/bin/npm
11331cb0ef41Sopenharmony_ci	unlink $(MACOSOUTDIR)/dist/node/usr/local/bin/npx
11341cb0ef41Sopenharmony_ci	$(NODE) tools/license2rtf.mjs < LICENSE > \
11351cb0ef41Sopenharmony_ci		$(MACOSOUTDIR)/installer/productbuild/Resources/license.rtf
11361cb0ef41Sopenharmony_ci	cp doc/osx_installer_logo.png $(MACOSOUTDIR)/installer/productbuild/Resources
11371cb0ef41Sopenharmony_ci	pkgbuild --version $(FULLVERSION) \
11381cb0ef41Sopenharmony_ci		--identifier org.nodejs.node.pkg \
11391cb0ef41Sopenharmony_ci		--root $(MACOSOUTDIR)/dist/node $(MACOSOUTDIR)/pkgs/node-$(FULLVERSION).pkg
11401cb0ef41Sopenharmony_ci	pkgbuild --version $(NPMVERSION) \
11411cb0ef41Sopenharmony_ci		--identifier org.nodejs.npm.pkg \
11421cb0ef41Sopenharmony_ci		--root $(MACOSOUTDIR)/dist/npm \
11431cb0ef41Sopenharmony_ci		--scripts ./tools/macos-installer/pkgbuild/npm/scripts \
11441cb0ef41Sopenharmony_ci			$(MACOSOUTDIR)/pkgs/npm-$(NPMVERSION).pkg
11451cb0ef41Sopenharmony_ci	productbuild --distribution $(MACOSOUTDIR)/installer/productbuild/distribution.xml \
11461cb0ef41Sopenharmony_ci		--resources $(MACOSOUTDIR)/installer/productbuild/Resources \
11471cb0ef41Sopenharmony_ci		--package-path $(MACOSOUTDIR)/pkgs ./$(PKG)
11481cb0ef41Sopenharmony_ci	SIGN="$(PRODUCTSIGN_CERT)" PKG="$(PKG)" sh tools/osx-productsign.sh
11491cb0ef41Sopenharmony_ci	sh tools/osx-notarize.sh $(FULLVERSION)
11501cb0ef41Sopenharmony_ci
11511cb0ef41Sopenharmony_ci.PHONY: pkg
11521cb0ef41Sopenharmony_ci# Builds the macOS installer for releases.
11531cb0ef41Sopenharmony_cipkg: $(PKG)
11541cb0ef41Sopenharmony_ci
11551cb0ef41Sopenharmony_ci.PHONY: corepack-update
11561cb0ef41Sopenharmony_cicorepack-update:
11571cb0ef41Sopenharmony_ci	mkdir -p /tmp/node-corepack
11581cb0ef41Sopenharmony_ci	curl -qLo /tmp/node-corepack/package.tgz "$$(npm view corepack dist.tarball)"
11591cb0ef41Sopenharmony_ci
11601cb0ef41Sopenharmony_ci	rm -rf deps/corepack && mkdir deps/corepack
11611cb0ef41Sopenharmony_ci	cd deps/corepack && tar xf /tmp/node-corepack/package.tgz --strip-components=1
11621cb0ef41Sopenharmony_ci	chmod +x deps/corepack/shims/*
11631cb0ef41Sopenharmony_ci
11641cb0ef41Sopenharmony_ci	node deps/corepack/dist/corepack.js --version
11651cb0ef41Sopenharmony_ci
11661cb0ef41Sopenharmony_ci.PHONY: pkg-upload
11671cb0ef41Sopenharmony_ci# Note: this is strictly for release builds on release machines only.
11681cb0ef41Sopenharmony_cipkg-upload: pkg
11691cb0ef41Sopenharmony_ci	ssh $(STAGINGSERVER) "mkdir -p nodejs/$(DISTTYPEDIR)/$(FULLVERSION)"
11701cb0ef41Sopenharmony_ci	chmod 664 $(TARNAME).pkg
11711cb0ef41Sopenharmony_ci	scp -p $(TARNAME).pkg $(STAGINGSERVER):nodejs/$(DISTTYPEDIR)/$(FULLVERSION)/$(TARNAME).pkg
11721cb0ef41Sopenharmony_ci	ssh $(STAGINGSERVER) "touch nodejs/$(DISTTYPEDIR)/$(FULLVERSION)/$(TARNAME).pkg.done"
11731cb0ef41Sopenharmony_ci
11741cb0ef41Sopenharmony_ci$(TARBALL): release-only doc-only
11751cb0ef41Sopenharmony_ci	git checkout-index -a -f --prefix=$(TARNAME)/
11761cb0ef41Sopenharmony_ci	mkdir -p $(TARNAME)/doc/api
11771cb0ef41Sopenharmony_ci	cp doc/node.1 $(TARNAME)/doc/node.1
11781cb0ef41Sopenharmony_ci	cp -r out/doc/api/* $(TARNAME)/doc/api/
11791cb0ef41Sopenharmony_ci	$(RM) -r $(TARNAME)/.editorconfig
11801cb0ef41Sopenharmony_ci	$(RM) -r $(TARNAME)/.git*
11811cb0ef41Sopenharmony_ci	$(RM) -r $(TARNAME)/.mailmap
11821cb0ef41Sopenharmony_ci	$(RM) -r $(TARNAME)/deps/openssl/openssl/demos
11831cb0ef41Sopenharmony_ci	$(RM) -r $(TARNAME)/deps/openssl/openssl/doc
11841cb0ef41Sopenharmony_ci	$(RM) -r $(TARNAME)/deps/openssl/openssl/test
11851cb0ef41Sopenharmony_ci	$(RM) -r $(TARNAME)/deps/uv/docs
11861cb0ef41Sopenharmony_ci	$(RM) -r $(TARNAME)/deps/uv/samples
11871cb0ef41Sopenharmony_ci	$(RM) -r $(TARNAME)/deps/uv/test
11881cb0ef41Sopenharmony_ci	$(RM) -r $(TARNAME)/deps/v8/samples
11891cb0ef41Sopenharmony_ci	$(RM) -r $(TARNAME)/deps/v8/tools/profviz
11901cb0ef41Sopenharmony_ci	$(RM) -r $(TARNAME)/deps/v8/tools/run-tests.py
11911cb0ef41Sopenharmony_ci	$(RM) -r $(TARNAME)/doc/images # too big
11921cb0ef41Sopenharmony_ci	$(RM) -r $(TARNAME)/test*.tap
11931cb0ef41Sopenharmony_ci	$(RM) -r $(TARNAME)/tools/cpplint.py
11941cb0ef41Sopenharmony_ci	$(RM) -r $(TARNAME)/tools/eslint-rules
11951cb0ef41Sopenharmony_ci	$(RM) -r $(TARNAME)/tools/license-builder.sh
11961cb0ef41Sopenharmony_ci	$(RM) -r $(TARNAME)/tools/node_modules
11971cb0ef41Sopenharmony_ci	$(RM) -r $(TARNAME)/tools/osx-*
11981cb0ef41Sopenharmony_ci	$(RM) -r $(TARNAME)/tools/osx-pkg.pmdoc
11991cb0ef41Sopenharmony_ci	find $(TARNAME)/deps/v8/test/* -type d ! -regex '.*/test/torque$$' | xargs $(RM) -r
12001cb0ef41Sopenharmony_ci	find $(TARNAME)/deps/v8/test -type f ! -regex '.*/test/torque/.*' | xargs $(RM)
12011cb0ef41Sopenharmony_ci	find $(TARNAME)/deps/zlib/contrib/* -type d ! -regex '.*/contrib/optimizations$$' | xargs $(RM) -r
12021cb0ef41Sopenharmony_ci	find $(TARNAME)/ -name ".eslint*" -maxdepth 2 | xargs $(RM)
12031cb0ef41Sopenharmony_ci	find $(TARNAME)/ -type l | xargs $(RM)
12041cb0ef41Sopenharmony_ci	tar -cf $(TARNAME).tar $(TARNAME)
12051cb0ef41Sopenharmony_ci	$(RM) -r $(TARNAME)
12061cb0ef41Sopenharmony_ci	gzip -c -f -9 $(TARNAME).tar > $(TARNAME).tar.gz
12071cb0ef41Sopenharmony_ciifeq ($(XZ), 1)
12081cb0ef41Sopenharmony_ci	xz -c -f -$(XZ_COMPRESSION) $(TARNAME).tar > $(TARNAME).tar.xz
12091cb0ef41Sopenharmony_ciendif
12101cb0ef41Sopenharmony_ci	$(RM) $(TARNAME).tar
12111cb0ef41Sopenharmony_ci
12121cb0ef41Sopenharmony_ci.PHONY: tar
12131cb0ef41Sopenharmony_citar: $(TARBALL) ## Create a source tarball.
12141cb0ef41Sopenharmony_ci
12151cb0ef41Sopenharmony_ci.PHONY: tar-upload
12161cb0ef41Sopenharmony_ci# Note: this is strictly for release builds on release machines only.
12171cb0ef41Sopenharmony_citar-upload: tar
12181cb0ef41Sopenharmony_ci	ssh $(STAGINGSERVER) "mkdir -p nodejs/$(DISTTYPEDIR)/$(FULLVERSION)"
12191cb0ef41Sopenharmony_ci	chmod 664 $(TARNAME).tar.gz
12201cb0ef41Sopenharmony_ci	scp -p $(TARNAME).tar.gz $(STAGINGSERVER):nodejs/$(DISTTYPEDIR)/$(FULLVERSION)/$(TARNAME).tar.gz
12211cb0ef41Sopenharmony_ci	ssh $(STAGINGSERVER) "touch nodejs/$(DISTTYPEDIR)/$(FULLVERSION)/$(TARNAME).tar.gz.done"
12221cb0ef41Sopenharmony_ciifeq ($(XZ), 1)
12231cb0ef41Sopenharmony_ci	chmod 664 $(TARNAME).tar.xz
12241cb0ef41Sopenharmony_ci	scp -p $(TARNAME).tar.xz $(STAGINGSERVER):nodejs/$(DISTTYPEDIR)/$(FULLVERSION)/$(TARNAME).tar.xz
12251cb0ef41Sopenharmony_ci	ssh $(STAGINGSERVER) "touch nodejs/$(DISTTYPEDIR)/$(FULLVERSION)/$(TARNAME).tar.xz.done"
12261cb0ef41Sopenharmony_ciendif
12271cb0ef41Sopenharmony_ci
12281cb0ef41Sopenharmony_ci.PHONY: doc-upload
12291cb0ef41Sopenharmony_ci# Note: this is strictly for release builds on release machines only.
12301cb0ef41Sopenharmony_cidoc-upload: doc
12311cb0ef41Sopenharmony_ci	ssh $(STAGINGSERVER) "mkdir -p nodejs/$(DISTTYPEDIR)/$(FULLVERSION)/docs/"
12321cb0ef41Sopenharmony_ci	chmod -R ug=rw-x+X,o=r+X out/doc/
12331cb0ef41Sopenharmony_ci	scp -pr out/doc/* $(STAGINGSERVER):nodejs/$(DISTTYPEDIR)/$(FULLVERSION)/docs/
12341cb0ef41Sopenharmony_ci	ssh $(STAGINGSERVER) "touch nodejs/$(DISTTYPEDIR)/$(FULLVERSION)/docs.done"
12351cb0ef41Sopenharmony_ci
12361cb0ef41Sopenharmony_ci.PHONY: $(TARBALL)-headers
12371cb0ef41Sopenharmony_ci$(TARBALL)-headers: release-only
12381cb0ef41Sopenharmony_ci	$(PYTHON) ./configure \
12391cb0ef41Sopenharmony_ci		--prefix=/ \
12401cb0ef41Sopenharmony_ci		--dest-cpu=$(DESTCPU) \
12411cb0ef41Sopenharmony_ci		--tag=$(TAG) \
12421cb0ef41Sopenharmony_ci		--release-urlbase=$(RELEASE_URLBASE) \
12431cb0ef41Sopenharmony_ci		$(CONFIG_FLAGS) $(BUILD_RELEASE_FLAGS)
12441cb0ef41Sopenharmony_ci	HEADERS_ONLY=1 $(PYTHON) tools/install.py install '$(TARNAME)' '/'
12451cb0ef41Sopenharmony_ci	find $(TARNAME)/ -type l | xargs $(RM)
12461cb0ef41Sopenharmony_ci	tar -cf $(TARNAME)-headers.tar $(TARNAME)
12471cb0ef41Sopenharmony_ci	$(RM) -r $(TARNAME)
12481cb0ef41Sopenharmony_ci	gzip -c -f -9 $(TARNAME)-headers.tar > $(TARNAME)-headers.tar.gz
12491cb0ef41Sopenharmony_ciifeq ($(XZ), 1)
12501cb0ef41Sopenharmony_ci	xz -c -f -$(XZ_COMPRESSION) $(TARNAME)-headers.tar > $(TARNAME)-headers.tar.xz
12511cb0ef41Sopenharmony_ciendif
12521cb0ef41Sopenharmony_ci	$(RM) $(TARNAME)-headers.tar
12531cb0ef41Sopenharmony_ci
12541cb0ef41Sopenharmony_ci.PHONY: tar-headers
12551cb0ef41Sopenharmony_citar-headers: $(TARBALL)-headers ## Build the node header tarball.
12561cb0ef41Sopenharmony_ci
12571cb0ef41Sopenharmony_ci.PHONY: tar-headers-upload
12581cb0ef41Sopenharmony_citar-headers-upload: tar-headers
12591cb0ef41Sopenharmony_ci	ssh $(STAGINGSERVER) "mkdir -p nodejs/$(DISTTYPEDIR)/$(FULLVERSION)"
12601cb0ef41Sopenharmony_ci	chmod 664 $(TARNAME)-headers.tar.gz
12611cb0ef41Sopenharmony_ci	scp -p $(TARNAME)-headers.tar.gz $(STAGINGSERVER):nodejs/$(DISTTYPEDIR)/$(FULLVERSION)/$(TARNAME)-headers.tar.gz
12621cb0ef41Sopenharmony_ci	ssh $(STAGINGSERVER) "touch nodejs/$(DISTTYPEDIR)/$(FULLVERSION)/$(TARNAME)-headers.tar.gz.done"
12631cb0ef41Sopenharmony_ciifeq ($(XZ), 1)
12641cb0ef41Sopenharmony_ci	chmod 664 $(TARNAME)-headers.tar.xz
12651cb0ef41Sopenharmony_ci	scp -p $(TARNAME)-headers.tar.xz $(STAGINGSERVER):nodejs/$(DISTTYPEDIR)/$(FULLVERSION)/$(TARNAME)-headers.tar.xz
12661cb0ef41Sopenharmony_ci	ssh $(STAGINGSERVER) "touch nodejs/$(DISTTYPEDIR)/$(FULLVERSION)/$(TARNAME)-headers.tar.xz.done"
12671cb0ef41Sopenharmony_ciendif
12681cb0ef41Sopenharmony_ci
12691cb0ef41Sopenharmony_ci$(BINARYTAR): release-only
12701cb0ef41Sopenharmony_ci	$(RM) -r $(BINARYNAME)
12711cb0ef41Sopenharmony_ci	$(RM) -r out/deps out/Release
12721cb0ef41Sopenharmony_ci	$(PYTHON) ./configure \
12731cb0ef41Sopenharmony_ci		--prefix=/ \
12741cb0ef41Sopenharmony_ci		--dest-cpu=$(DESTCPU) \
12751cb0ef41Sopenharmony_ci		--tag=$(TAG) \
12761cb0ef41Sopenharmony_ci		--release-urlbase=$(RELEASE_URLBASE) \
12771cb0ef41Sopenharmony_ci		$(CONFIG_FLAGS) $(BUILD_RELEASE_FLAGS)
12781cb0ef41Sopenharmony_ci	$(MAKE) install DESTDIR=$(BINARYNAME) V=$(V) PORTABLE=1
12791cb0ef41Sopenharmony_ci	cp README.md $(BINARYNAME)
12801cb0ef41Sopenharmony_ci	cp LICENSE $(BINARYNAME)
12811cb0ef41Sopenharmony_ciifeq ("$(wildcard $(CHANGELOG))","")
12821cb0ef41Sopenharmony_ci	cp CHANGELOG.md $(BINARYNAME)
12831cb0ef41Sopenharmony_cielse
12841cb0ef41Sopenharmony_ci	cp $(CHANGELOG) $(BINARYNAME)/CHANGELOG.md
12851cb0ef41Sopenharmony_ciendif
12861cb0ef41Sopenharmony_ciifeq ($(OSTYPE),darwin)
12871cb0ef41Sopenharmony_ci	SIGN="$(CODESIGN_CERT)" PKGDIR="$(BINARYNAME)" sh tools/osx-codesign.sh
12881cb0ef41Sopenharmony_ciendif
12891cb0ef41Sopenharmony_ci	tar -cf $(BINARYNAME).tar $(BINARYNAME)
12901cb0ef41Sopenharmony_ci	$(RM) -r $(BINARYNAME)
12911cb0ef41Sopenharmony_ci	gzip -c -f -9 $(BINARYNAME).tar > $(BINARYNAME).tar.gz
12921cb0ef41Sopenharmony_ciifeq ($(XZ), 1)
12931cb0ef41Sopenharmony_ci	xz -c -f -$(XZ_COMPRESSION) $(BINARYNAME).tar > $(BINARYNAME).tar.xz
12941cb0ef41Sopenharmony_ciendif
12951cb0ef41Sopenharmony_ci	$(RM) $(BINARYNAME).tar
12961cb0ef41Sopenharmony_ci
12971cb0ef41Sopenharmony_ci.PHONY: binary
12981cb0ef41Sopenharmony_ci# This requires NODE_VERSION_IS_RELEASE defined as 1 in src/node_version.h.
12991cb0ef41Sopenharmony_cibinary: $(BINARYTAR) ## Build release binary tarballs.
13001cb0ef41Sopenharmony_ci
13011cb0ef41Sopenharmony_ci.PHONY: binary-upload
13021cb0ef41Sopenharmony_ci# Note: this is strictly for release builds on release machines only.
13031cb0ef41Sopenharmony_cibinary-upload: binary
13041cb0ef41Sopenharmony_ci	ssh $(STAGINGSERVER) "mkdir -p nodejs/$(DISTTYPEDIR)/$(FULLVERSION)"
13051cb0ef41Sopenharmony_ci	chmod 664 $(TARNAME)-$(OSTYPE)-$(ARCH).tar.gz
13061cb0ef41Sopenharmony_ci	scp -p $(TARNAME)-$(OSTYPE)-$(ARCH).tar.gz $(STAGINGSERVER):nodejs/$(DISTTYPEDIR)/$(FULLVERSION)/$(TARNAME)-$(OSTYPE)-$(ARCH).tar.gz
13071cb0ef41Sopenharmony_ci	ssh $(STAGINGSERVER) "touch nodejs/$(DISTTYPEDIR)/$(FULLVERSION)/$(TARNAME)-$(OSTYPE)-$(ARCH).tar.gz.done"
13081cb0ef41Sopenharmony_ciifeq ($(XZ), 1)
13091cb0ef41Sopenharmony_ci	chmod 664 $(TARNAME)-$(OSTYPE)-$(ARCH).tar.xz
13101cb0ef41Sopenharmony_ci	scp -p $(TARNAME)-$(OSTYPE)-$(ARCH).tar.xz $(STAGINGSERVER):nodejs/$(DISTTYPEDIR)/$(FULLVERSION)/$(TARNAME)-$(OSTYPE)-$(ARCH).tar.xz
13111cb0ef41Sopenharmony_ci	ssh $(STAGINGSERVER) "touch nodejs/$(DISTTYPEDIR)/$(FULLVERSION)/$(TARNAME)-$(OSTYPE)-$(ARCH).tar.xz.done"
13121cb0ef41Sopenharmony_ciendif
13131cb0ef41Sopenharmony_ci
13141cb0ef41Sopenharmony_ci.PHONY: bench-all
13151cb0ef41Sopenharmony_ci.PHONY: bench
13161cb0ef41Sopenharmony_cibench bench-all: bench-addons-build
13171cb0ef41Sopenharmony_ci	$(warning Please use benchmark/run.js or benchmark/compare.js to run the benchmarks.)
13181cb0ef41Sopenharmony_ci
13191cb0ef41Sopenharmony_ci# Build required addons for benchmark before running it.
13201cb0ef41Sopenharmony_ci.PHONY: bench-addons-build
13211cb0ef41Sopenharmony_cibench-addons-build: | $(NODE_EXE) benchmark/napi/.buildstamp
13221cb0ef41Sopenharmony_ci
13231cb0ef41Sopenharmony_ci.PHONY: bench-addons-clean
13241cb0ef41Sopenharmony_ci.NOTPARALLEL: bench-addons-clean
13251cb0ef41Sopenharmony_cibench-addons-clean:
13261cb0ef41Sopenharmony_ci	$(RM) -r benchmark/napi/*/build
13271cb0ef41Sopenharmony_ci	$(RM) benchmark/napi/.buildstamp
13281cb0ef41Sopenharmony_ci
13291cb0ef41Sopenharmony_ci.PHONY: lint-md-rollup
13301cb0ef41Sopenharmony_cilint-md-rollup:
13311cb0ef41Sopenharmony_ci	$(RM) tools/.*mdlintstamp
13321cb0ef41Sopenharmony_ci	cd tools/lint-md && npm ci && npm run build
13331cb0ef41Sopenharmony_ci
13341cb0ef41Sopenharmony_ci.PHONY: lint-md-clean
13351cb0ef41Sopenharmony_ci.NOTPARALLEL: lint-md-clean
13361cb0ef41Sopenharmony_cilint-md-clean:
13371cb0ef41Sopenharmony_ci	$(RM) -r tools/lint-md/node_modules
13381cb0ef41Sopenharmony_ci	$(RM) tools/.*mdlintstamp
13391cb0ef41Sopenharmony_ci
13401cb0ef41Sopenharmony_ci.PHONY: lint-md-build
13411cb0ef41Sopenharmony_cilint-md-build:
13421cb0ef41Sopenharmony_ci	$(warning Deprecated no-op target 'lint-md-build')
13431cb0ef41Sopenharmony_ci
13441cb0ef41Sopenharmony_ciifeq ("$(wildcard tools/.mdlintstamp)","")
13451cb0ef41Sopenharmony_ciLINT_MD_NEWER =
13461cb0ef41Sopenharmony_cielse
13471cb0ef41Sopenharmony_ciLINT_MD_NEWER = -newer tools/.mdlintstamp
13481cb0ef41Sopenharmony_ciendif
13491cb0ef41Sopenharmony_ci
13501cb0ef41Sopenharmony_ciLINT_MD_TARGETS = doc src lib benchmark test tools/doc tools/icu $(wildcard *.md)
13511cb0ef41Sopenharmony_ciLINT_MD_FILES = $(shell $(FIND) $(LINT_MD_TARGETS) -type f \
13521cb0ef41Sopenharmony_ci	! -path '*node_modules*' ! -path 'test/fixtures/*' -name '*.md' \
13531cb0ef41Sopenharmony_ci	$(LINT_MD_NEWER))
13541cb0ef41Sopenharmony_cirun-lint-md = tools/lint-md/lint-md.mjs $(LINT_MD_FILES)
13551cb0ef41Sopenharmony_ci# Lint all changed markdown files maintained by us
13561cb0ef41Sopenharmony_citools/.mdlintstamp: $(LINT_MD_FILES)
13571cb0ef41Sopenharmony_ci	$(info Running Markdown linter...)
13581cb0ef41Sopenharmony_ci	@$(call available-node,$(run-lint-md))
13591cb0ef41Sopenharmony_ci	@touch $@
13601cb0ef41Sopenharmony_ci
13611cb0ef41Sopenharmony_ci.PHONY: lint-md
13621cb0ef41Sopenharmony_ci# Lints the markdown documents maintained by us in the codebase.
13631cb0ef41Sopenharmony_cilint-md: lint-js-doc | tools/.mdlintstamp
13641cb0ef41Sopenharmony_ci
13651cb0ef41Sopenharmony_cirun-format-md = tools/lint-md/lint-md.mjs --format $(LINT_MD_FILES)
13661cb0ef41Sopenharmony_ci.PHONY: format-md
13671cb0ef41Sopenharmony_ci# Formats the markdown documents maintained by us in the codebase.
13681cb0ef41Sopenharmony_ciformat-md:
13691cb0ef41Sopenharmony_ci	@$(call available-node,$(run-format-md))
13701cb0ef41Sopenharmony_ci
13711cb0ef41Sopenharmony_ci
13721cb0ef41Sopenharmony_ci
13731cb0ef41Sopenharmony_ciLINT_JS_TARGETS = .eslintrc.js benchmark doc lib test tools
13741cb0ef41Sopenharmony_ci
13751cb0ef41Sopenharmony_cirun-lint-js = tools/node_modules/eslint/bin/eslint.js --cache \
13761cb0ef41Sopenharmony_ci	--max-warnings=0 --report-unused-disable-directives $(LINT_JS_TARGETS)
13771cb0ef41Sopenharmony_cirun-lint-js-fix = $(run-lint-js) --fix
13781cb0ef41Sopenharmony_ci
13791cb0ef41Sopenharmony_ci.PHONY: lint-js-fix
13801cb0ef41Sopenharmony_cilint-js-fix:
13811cb0ef41Sopenharmony_ci	@$(call available-node,$(run-lint-js-fix))
13821cb0ef41Sopenharmony_ci
13831cb0ef41Sopenharmony_ci.PHONY: lint-js
13841cb0ef41Sopenharmony_ci.PHONY: lint-js-doc
13851cb0ef41Sopenharmony_ci# Note that on the CI `lint-js-ci` is run instead.
13861cb0ef41Sopenharmony_ci# Lints the JavaScript code with eslint.
13871cb0ef41Sopenharmony_cilint-js-doc: LINT_JS_TARGETS=doc
13881cb0ef41Sopenharmony_cilint-js lint-js-doc:
13891cb0ef41Sopenharmony_ci	@if [ "$(shell $(node_use_openssl))" != "true" ]; then \
13901cb0ef41Sopenharmony_ci		echo "Skipping $@ (no crypto)"; \
13911cb0ef41Sopenharmony_ci	else \
13921cb0ef41Sopenharmony_ci		echo "Running JS linter..."; \
13931cb0ef41Sopenharmony_ci		$(call available-node,$(run-lint-js)) \
13941cb0ef41Sopenharmony_ci	fi
13951cb0ef41Sopenharmony_ci
13961cb0ef41Sopenharmony_cijslint: lint-js
13971cb0ef41Sopenharmony_ci	$(warning Please use lint-js instead of jslint)
13981cb0ef41Sopenharmony_ci
13991cb0ef41Sopenharmony_cirun-lint-js-ci = tools/node_modules/eslint/bin/eslint.js \
14001cb0ef41Sopenharmony_ci  --max-warnings=0 --report-unused-disable-directives -f tap \
14011cb0ef41Sopenharmony_ci	-o test-eslint.tap $(LINT_JS_TARGETS)
14021cb0ef41Sopenharmony_ci
14031cb0ef41Sopenharmony_ci.PHONY: lint-js-ci
14041cb0ef41Sopenharmony_ci# On the CI the output is emitted in the TAP format.
14051cb0ef41Sopenharmony_cilint-js-ci:
14061cb0ef41Sopenharmony_ci	$(info Running JS linter...)
14071cb0ef41Sopenharmony_ci	@$(call available-node,$(run-lint-js-ci))
14081cb0ef41Sopenharmony_ci
14091cb0ef41Sopenharmony_cijslint-ci: lint-js-ci
14101cb0ef41Sopenharmony_ci	$(warning Please use lint-js-ci instead of jslint-ci)
14111cb0ef41Sopenharmony_ci
14121cb0ef41Sopenharmony_ciLINT_CPP_ADDON_DOC_FILES_GLOB = test/addons/??_*/*.cc test/addons/??_*/*.h
14131cb0ef41Sopenharmony_ciLINT_CPP_ADDON_DOC_FILES = $(wildcard $(LINT_CPP_ADDON_DOC_FILES_GLOB))
14141cb0ef41Sopenharmony_ciLINT_CPP_EXCLUDE ?=
14151cb0ef41Sopenharmony_ciLINT_CPP_EXCLUDE += src/node_root_certs.h
14161cb0ef41Sopenharmony_ciLINT_CPP_EXCLUDE += $(LINT_CPP_ADDON_DOC_FILES)
14171cb0ef41Sopenharmony_ci# These files were copied more or less verbatim from V8.
14181cb0ef41Sopenharmony_ciLINT_CPP_EXCLUDE += src/tracing/trace_event.h src/tracing/trace_event_common.h
14191cb0ef41Sopenharmony_ci
14201cb0ef41Sopenharmony_ciLINT_CPP_FILES = $(filter-out $(LINT_CPP_EXCLUDE), $(wildcard \
14211cb0ef41Sopenharmony_ci	benchmark/napi/*/*.cc \
14221cb0ef41Sopenharmony_ci	src/*.c \
14231cb0ef41Sopenharmony_ci	src/*.cc \
14241cb0ef41Sopenharmony_ci	src/*.h \
14251cb0ef41Sopenharmony_ci	src/*/*.c \
14261cb0ef41Sopenharmony_ci	src/*/*.cc \
14271cb0ef41Sopenharmony_ci	src/*/*.h \
14281cb0ef41Sopenharmony_ci	test/addons/*/*.cc \
14291cb0ef41Sopenharmony_ci	test/addons/*/*.h \
14301cb0ef41Sopenharmony_ci	test/cctest/*.cc \
14311cb0ef41Sopenharmony_ci	test/cctest/*.h \
14321cb0ef41Sopenharmony_ci	test/embedding/*.cc \
14331cb0ef41Sopenharmony_ci	test/embedding/*.h \
14341cb0ef41Sopenharmony_ci	test/fixtures/*.c \
14351cb0ef41Sopenharmony_ci	test/js-native-api/*/*.cc \
14361cb0ef41Sopenharmony_ci	test/node-api/*/*.cc \
14371cb0ef41Sopenharmony_ci	tools/icu/*.cc \
14381cb0ef41Sopenharmony_ci	tools/icu/*.h \
14391cb0ef41Sopenharmony_ci	tools/code_cache/*.cc \
14401cb0ef41Sopenharmony_ci	tools/code_cache/*.h \
14411cb0ef41Sopenharmony_ci	tools/snapshot/*.cc \
14421cb0ef41Sopenharmony_ci	tools/snapshot/*.h \
14431cb0ef41Sopenharmony_ci	))
14441cb0ef41Sopenharmony_ci
14451cb0ef41Sopenharmony_ciFORMAT_CPP_FILES ?=
14461cb0ef41Sopenharmony_ciFORMAT_CPP_FILES += $(LINT_CPP_FILES)
14471cb0ef41Sopenharmony_ci# C source codes.
14481cb0ef41Sopenharmony_ciFORMAT_CPP_FILES += $(wildcard \
14491cb0ef41Sopenharmony_ci	benchmark/napi/*/*.c \
14501cb0ef41Sopenharmony_ci	test/js-native-api/*.h \
14511cb0ef41Sopenharmony_ci	test/js-native-api/*/*.c \
14521cb0ef41Sopenharmony_ci	test/js-native-api/*/*.h \
14531cb0ef41Sopenharmony_ci	test/node-api/*/*.c \
14541cb0ef41Sopenharmony_ci	test/node-api/*/*.h \
14551cb0ef41Sopenharmony_ci	)
14561cb0ef41Sopenharmony_ci
14571cb0ef41Sopenharmony_ci# Code blocks don't have newline at the end,
14581cb0ef41Sopenharmony_ci# and the actual filename is generated so it won't match header guards
14591cb0ef41Sopenharmony_ciADDON_DOC_LINT_FLAGS=-whitespace/ending_newline,-build/header_guard
14601cb0ef41Sopenharmony_ci
14611cb0ef41Sopenharmony_ci.PHONY: format-cpp-build
14621cb0ef41Sopenharmony_ciformat-cpp-build:
14631cb0ef41Sopenharmony_ci	cd tools/clang-format && $(call available-node,$(run-npm-ci))
14641cb0ef41Sopenharmony_ci
14651cb0ef41Sopenharmony_ci.PHONY: format-cpp-clean
14661cb0ef41Sopenharmony_ci.NOTPARALLEL: format-cpp-clean
14671cb0ef41Sopenharmony_ciformat-cpp-clean:
14681cb0ef41Sopenharmony_ci	$(RM) -r tools/clang-format/node_modules
14691cb0ef41Sopenharmony_ci
14701cb0ef41Sopenharmony_ciCLANG_FORMAT_START ?= HEAD
14711cb0ef41Sopenharmony_ci.PHONY: format-cpp
14721cb0ef41Sopenharmony_ci# To format staged changes:
14731cb0ef41Sopenharmony_ci#  $ make format-cpp
14741cb0ef41Sopenharmony_ci# To format HEAD~1...HEAD (latest commit):
14751cb0ef41Sopenharmony_ci#  $ CLANG_FORMAT_START=`git rev-parse HEAD~1` make format-cpp
14761cb0ef41Sopenharmony_ci# To format diff between main and current branch head (main...HEAD):
14771cb0ef41Sopenharmony_ci#  $ CLANG_FORMAT_START=main make format-cpp
14781cb0ef41Sopenharmony_ciformat-cpp: ## Format C++ diff from $CLANG_FORMAT_START to current changes
14791cb0ef41Sopenharmony_ciifneq ("","$(wildcard tools/clang-format/node_modules/)")
14801cb0ef41Sopenharmony_ci	$(info Formatting C++ diff from $(CLANG_FORMAT_START)..)
14811cb0ef41Sopenharmony_ci	@$(PYTHON) tools/clang-format/node_modules/.bin/git-clang-format \
14821cb0ef41Sopenharmony_ci		--binary=tools/clang-format/node_modules/.bin/clang-format \
14831cb0ef41Sopenharmony_ci		--style=file \
14841cb0ef41Sopenharmony_ci		$(CLANG_FORMAT_START) -- \
14851cb0ef41Sopenharmony_ci		$(FORMAT_CPP_FILES)
14861cb0ef41Sopenharmony_cielse
14871cb0ef41Sopenharmony_ci	$(info Required tooling for C++ code formatting is not installed.)
14881cb0ef41Sopenharmony_ci	$(info To install (requires internet access) run: $$ make format-cpp-build)
14891cb0ef41Sopenharmony_ciendif
14901cb0ef41Sopenharmony_ci
14911cb0ef41Sopenharmony_ciifeq ($(V),1)
14921cb0ef41Sopenharmony_ciCPPLINT_QUIET =
14931cb0ef41Sopenharmony_cielse
14941cb0ef41Sopenharmony_ciCPPLINT_QUIET = --quiet
14951cb0ef41Sopenharmony_ciendif
14961cb0ef41Sopenharmony_ci.PHONY: lint-cpp
14971cb0ef41Sopenharmony_ci# Lints the C++ code with cpplint.py and checkimports.py.
14981cb0ef41Sopenharmony_cilint-cpp: tools/.cpplintstamp
14991cb0ef41Sopenharmony_ci
15001cb0ef41Sopenharmony_citools/.cpplintstamp: $(LINT_CPP_FILES)
15011cb0ef41Sopenharmony_ci	$(info Running C++ linter...)
15021cb0ef41Sopenharmony_ci	@$(PYTHON) tools/cpplint.py $(CPPLINT_QUIET) $?
15031cb0ef41Sopenharmony_ci	@$(PYTHON) tools/checkimports.py $?
15041cb0ef41Sopenharmony_ci	@touch $@
15051cb0ef41Sopenharmony_ci
15061cb0ef41Sopenharmony_ci.PHONY: lint-addon-docs
15071cb0ef41Sopenharmony_cilint-addon-docs: tools/.doclintstamp
15081cb0ef41Sopenharmony_ci
15091cb0ef41Sopenharmony_citools/.doclintstamp: test/addons/.docbuildstamp
15101cb0ef41Sopenharmony_ci	$(info Running C++ linter on addon docs...)
15111cb0ef41Sopenharmony_ci	@$(PYTHON) tools/cpplint.py $(CPPLINT_QUIET) --filter=$(ADDON_DOC_LINT_FLAGS) \
15121cb0ef41Sopenharmony_ci		$(LINT_CPP_ADDON_DOC_FILES_GLOB)
15131cb0ef41Sopenharmony_ci	@touch $@
15141cb0ef41Sopenharmony_ci
15151cb0ef41Sopenharmony_cicpplint: lint-cpp
15161cb0ef41Sopenharmony_ci	$(warning Please use lint-cpp instead of cpplint)
15171cb0ef41Sopenharmony_ci
15181cb0ef41Sopenharmony_ci.PHONY: lint-py-build
15191cb0ef41Sopenharmony_ci# python -m pip install ruff
15201cb0ef41Sopenharmony_ci# Try with '--system' if it fails without; the system may have set '--user'
15211cb0ef41Sopenharmony_cilint-py-build:
15221cb0ef41Sopenharmony_ci	$(info Pip installing ruff on $(shell $(PYTHON) --version)...)
15231cb0ef41Sopenharmony_ci	$(PYTHON) -m pip install --upgrade --target tools/pip/site-packages ruff==0.0.272 || \
15241cb0ef41Sopenharmony_ci		$(PYTHON) -m pip install --upgrade --system --target tools/pip/site-packages ruff==0.0.272
15251cb0ef41Sopenharmony_ci
15261cb0ef41Sopenharmony_ci.PHONY: lint-py
15271cb0ef41Sopenharmony_ciifneq ("","$(wildcard tools/pip/site-packages/ruff)")
15281cb0ef41Sopenharmony_ci# Lint the Python code with ruff.
15291cb0ef41Sopenharmony_cilint-py:
15301cb0ef41Sopenharmony_ci	tools/pip/site-packages/bin/ruff --version
15311cb0ef41Sopenharmony_ci	tools/pip/site-packages/bin/ruff .
15321cb0ef41Sopenharmony_cielse
15331cb0ef41Sopenharmony_cilint-py:
15341cb0ef41Sopenharmony_ci	$(warning Python linting with ruff is not available)
15351cb0ef41Sopenharmony_ci	$(warning Run 'make lint-py-build')
15361cb0ef41Sopenharmony_ciendif
15371cb0ef41Sopenharmony_ci
15381cb0ef41Sopenharmony_ci.PHONY: lint-yaml-build
15391cb0ef41Sopenharmony_ci# python -m pip install yamllint
15401cb0ef41Sopenharmony_ci# Try with '--system' if it fails without; the system may have set '--user'
15411cb0ef41Sopenharmony_cilint-yaml-build:
15421cb0ef41Sopenharmony_ci	$(info Pip installing yamllint on $(shell $(PYTHON) --version)...)
15431cb0ef41Sopenharmony_ci	$(PYTHON) -m pip install --upgrade -t tools/pip/site-packages yamllint || \
15441cb0ef41Sopenharmony_ci		$(PYTHON) -m pip install --upgrade --system -t tools/pip/site-packages yamllint
15451cb0ef41Sopenharmony_ci
15461cb0ef41Sopenharmony_ci.PHONY: lint-yaml
15471cb0ef41Sopenharmony_ci# Lints the YAML files with yamllint.
15481cb0ef41Sopenharmony_cilint-yaml:
15491cb0ef41Sopenharmony_ci	@if [ -d "tools/pip/site-packages/yamllint" ]; then \
15501cb0ef41Sopenharmony_ci			PYTHONPATH=tools/pip $(PYTHON) -m yamllint .; \
15511cb0ef41Sopenharmony_ci	else \
15521cb0ef41Sopenharmony_ci		echo 'YAML linting with yamllint is not available'; \
15531cb0ef41Sopenharmony_ci		echo "Run 'make lint-yaml-build'"; \
15541cb0ef41Sopenharmony_ci	fi
15551cb0ef41Sopenharmony_ci
15561cb0ef41Sopenharmony_ci.PHONY: lint
15571cb0ef41Sopenharmony_ci.PHONY: lint-ci
15581cb0ef41Sopenharmony_ciifneq ("","$(wildcard tools/node_modules/eslint/)")
15591cb0ef41Sopenharmony_cilint: ## Run JS, C++, MD and doc linters.
15601cb0ef41Sopenharmony_ci	@EXIT_STATUS=0 ; \
15611cb0ef41Sopenharmony_ci	$(MAKE) lint-js || EXIT_STATUS=$$? ; \
15621cb0ef41Sopenharmony_ci	$(MAKE) lint-cpp || EXIT_STATUS=$$? ; \
15631cb0ef41Sopenharmony_ci	$(MAKE) lint-addon-docs || EXIT_STATUS=$$? ; \
15641cb0ef41Sopenharmony_ci	$(MAKE) lint-md || EXIT_STATUS=$$? ; \
15651cb0ef41Sopenharmony_ci	$(MAKE) lint-yaml || EXIT_STATUS=$$? ; \
15661cb0ef41Sopenharmony_ci	exit $$EXIT_STATUS
15671cb0ef41Sopenharmony_ciCONFLICT_RE=^>>>>>>> [[:xdigit:]]+|^<<<<<<< [[:alpha:]]+
15681cb0ef41Sopenharmony_ci
15691cb0ef41Sopenharmony_ci# Related CI job: node-test-linter
15701cb0ef41Sopenharmony_cilint-ci: lint-js-ci lint-cpp lint-py lint-md lint-addon-docs lint-yaml-build lint-yaml
15711cb0ef41Sopenharmony_ci	@if ! ( grep -IEqrs "$(CONFLICT_RE)" --exclude="error-message.js" --exclude="merge-conflict.json" benchmark deps doc lib src test tools ) \
15721cb0ef41Sopenharmony_ci		&& ! ( $(FIND) . -maxdepth 1 -type f | xargs grep -IEqs "$(CONFLICT_RE)" ); then \
15731cb0ef41Sopenharmony_ci		exit 0 ; \
15741cb0ef41Sopenharmony_ci	else \
15751cb0ef41Sopenharmony_ci		echo "" >&2 ; \
15761cb0ef41Sopenharmony_ci		echo "Conflict marker detected in one or more files. Please fix them first." >&2 ; \
15771cb0ef41Sopenharmony_ci		exit 1 ; \
15781cb0ef41Sopenharmony_ci	fi
15791cb0ef41Sopenharmony_cielse
15801cb0ef41Sopenharmony_cilint lint-ci:
15811cb0ef41Sopenharmony_ci	$(info Linting is not available through the source tarball.)
15821cb0ef41Sopenharmony_ci	$(info Use the git repo instead: $$ git clone https://github.com/nodejs/node.git)
15831cb0ef41Sopenharmony_ciendif
15841cb0ef41Sopenharmony_ci
15851cb0ef41Sopenharmony_ci.PHONY: lint-clean
15861cb0ef41Sopenharmony_cilint-clean:
15871cb0ef41Sopenharmony_ci	$(RM) tools/.*lintstamp
15881cb0ef41Sopenharmony_ci	$(RM) .eslintcache
15891cb0ef41Sopenharmony_ci
15901cb0ef41Sopenharmony_ciHAS_DOCKER ?= $(shell command -v docker > /dev/null 2>&1; [ $$? -eq 0 ] && echo 1 || echo 0)
15911cb0ef41Sopenharmony_ci
15921cb0ef41Sopenharmony_ci.PHONY: gen-openssl
15931cb0ef41Sopenharmony_ciifeq ($(HAS_DOCKER), 1)
15941cb0ef41Sopenharmony_ciDOCKER_COMMAND ?= docker run -it -v $(PWD):/node
15951cb0ef41Sopenharmony_ciIS_IN_WORKTREE = $(shell grep '^gitdir: ' $(PWD)/.git 2>/dev/null)
15961cb0ef41Sopenharmony_ciGIT_WORKTREE_COMMON = $(shell git rev-parse --git-common-dir)
15971cb0ef41Sopenharmony_ciDOCKER_COMMAND += $(if $(IS_IN_WORKTREE), -v $(GIT_WORKTREE_COMMON):$(GIT_WORKTREE_COMMON))
15981cb0ef41Sopenharmony_cigen-openssl: ## Generate platform dependent openssl files (requires docker)
15991cb0ef41Sopenharmony_ci	docker build -t node-openssl-builder deps/openssl/config/
16001cb0ef41Sopenharmony_ci	$(DOCKER_COMMAND) node-openssl-builder make -C deps/openssl/config
16011cb0ef41Sopenharmony_cielse
16021cb0ef41Sopenharmony_cigen-openssl:
16031cb0ef41Sopenharmony_ci	$(error No docker command, cannot continue)
16041cb0ef41Sopenharmony_ciendif
1605