From 58a667c8840fe286552b41ef8687770c601ed8bf Mon Sep 17 00:00:00 2001 From: Gibson Fahnestock Date: Sun, 26 Nov 2017 14:41:56 +0000 Subject: [PATCH] build: add a `make help` option for common targets PR-URL: https://github.com/nodejs/node/pull/17323 Reviewed-By: Jon Moss Reviewed-By: James M Snell Reviewed-By: Ben Noordhuis Reviewed-By: Richard Lau Reviewed-By: Anna Henningsen Reviewed-By: Evan Lucas Reviewed-By: Refael Ackermann Reviewed-By: Colin Ihrig Reviewed-By: Joyee Cheung --- Makefile | 35 +++++++++++++++++++++-------------- 1 file changed, 21 insertions(+), 14 deletions(-) diff --git a/Makefile b/Makefile index e03b55dcf02624..d2a665ca29af66 100644 --- a/Makefile +++ b/Makefile @@ -63,11 +63,17 @@ V ?= 1 # BUILDTYPE=Debug builds both release and debug builds. If you want to compile # just the debug build, run `make -C out BUILDTYPE=Debug` instead. ifeq ($(BUILDTYPE),Release) -all: out/Makefile $(NODE_EXE) +all: out/Makefile $(NODE_EXE) ## Default target, builds node in out/Release/node. else all: out/Makefile $(NODE_EXE) $(NODE_G_EXE) endif +# To add a target to the help, add a double comment (##) on the target line. +help: ## Print help for targets with comments. + @printf "For more targets and info see the comments in the Makefile.\n\n" + @grep -E '^[a-zA-Z0-9._-]+:.*?## .*$$' Makefile | sort | \ + awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-15s\033[0m %s\n", $$1, $$2}' + # The .PHONY is needed to ensure that we recursively use the out/Makefile # to check for changes. .PHONY: $(NODE_EXE) $(NODE_G_EXE) @@ -94,13 +100,13 @@ out/Makefile: common.gypi deps/uv/uv.gyp deps/http_parser/http_parser.gyp \ config.gypi: configure $(error Missing or stale $@, please run ./$<) -install: all +install: all ## Installs node into $PREFIX (default=/usr/local). $(PYTHON) tools/install.py $@ '$(DESTDIR)' '$(PREFIX)' -uninstall: +uninstall: ## Uninstalls node from $PREFIX (default=/usr/local). $(PYTHON) tools/install.py $@ '$(DESTDIR)' '$(PREFIX)' -clean: +clean: ## Remove build artifacts. $(RM) -r out/Makefile $(NODE_EXE) $(NODE_G_EXE) out/$(BUILDTYPE)/$(NODE_EXE) \ out/$(BUILDTYPE)/node.exp @if [ -d out ]; then find out/ -name '*.o' -o -name '*.a' -o -name '*.d' | xargs $(RM) -r; fi @@ -145,7 +151,7 @@ coverage-clean: # For C++ coverage reporting, this needs to be run in conjunction with configure # --coverage. html coverage reports will be created under coverage/ -coverage: coverage-test +coverage: coverage-test ## Run the tests and generate a coverage report. coverage-build: all mkdir -p node_modules @@ -206,7 +212,7 @@ v8: $(MAKE) -C deps/v8 $(V8_ARCH).$(BUILDTYPE_LOWER) $(V8_BUILD_OPTIONS) ifeq ($(NODE_TARGET_TYPE),static_library) -test: all +test: all ## Default test target. Runs default tests, linters, and builds docs. $(MAKE) cctest else test: all @@ -378,7 +384,7 @@ test-build: | all build-addons build-addons-napi test-build-addons-napi: all build-addons-napi -test-all: test-build test/gc/build/Release/binding.node +test-all: test-build test/gc/build/Release/binding.node ## Run everything in test/. $(PYTHON) tools/test.py --mode=debug,release test-all-valgrind: test-build @@ -457,7 +463,7 @@ test-doc: doc-only test-known-issues: all $(PYTHON) tools/test.py known_issues -test-npm: $(NODE_EXE) +test-npm: $(NODE_EXE) ## Run the npm test suite on deps/npm. $(NODE) tools/test-npm-package --install --logfile=test-npm.tap deps/npm test-node test-npm-publish: $(NODE_EXE) @@ -499,7 +505,7 @@ test-with-async-hooks: ifneq ("","$(wildcard deps/v8/tools/run-tests.py)") -test-v8: v8 +test-v8: v8 ## Runs the V8 test suite on deps/v8. # note: performs full test unless QUICKCHECK is specified deps/v8/tools/run-tests.py --arch=$(V8_ARCH) \ --mode=$(BUILDTYPE_LOWER) $(V8_TEST_OPTIONS) $(QUICKCHECK_ARG) \ @@ -865,7 +871,7 @@ ifeq ($(XZ), 0) endif $(RM) $(TARNAME).tar -tar: $(TARBALL) +tar: $(TARBALL) ## Create a source tarball. tar-upload: tar ssh $(STAGINGSERVER) "mkdir -p nodejs/$(DISTTYPEDIR)/$(FULLVERSION)" @@ -901,7 +907,7 @@ ifeq ($(XZ), 0) endif $(RM) $(TARNAME)-headers.tar -tar-headers: $(TARBALL)-headers +tar-headers: $(TARBALL)-headers ## Build the node header tarball. tar-headers-upload: tar-headers ssh $(STAGINGSERVER) "mkdir -p nodejs/$(DISTTYPEDIR)/$(FULLVERSION)" @@ -938,7 +944,7 @@ ifeq ($(XZ), 0) endif $(RM) $(BINARYNAME).tar -binary: $(BINARYTAR) +binary: $(BINARYTAR) ## Build release binary tarballs. binary-upload: binary ssh $(STAGINGSERVER) "mkdir -p nodejs/$(DISTTYPEDIR)/$(FULLVERSION)" @@ -989,7 +995,7 @@ bench-dgram: all bench-all: bench bench-misc bench-array bench-buffer bench-url bench-events bench-dgram bench-util -bench: bench-net bench-http bench-fs bench-tls +bench: bench-net bench-http bench-fs bench-tls ## Run node benchmarks. bench-ci: bench @@ -1115,7 +1121,7 @@ cpplint: lint-cpp @echo "Please use lint-cpp instead of cpplint" ifneq ("","$(wildcard tools/eslint/)") -lint: +lint: ## Run JS, C++, MD and doc linters. @EXIT_STATUS=0 ; \ $(MAKE) lint-js || EXIT_STATUS=$$? ; \ $(MAKE) lint-cpp || EXIT_STATUS=$$? ; \ @@ -1181,6 +1187,7 @@ lint-clean: docclean \ docopen \ dynamiclib \ + help \ install \ install-bin \ install-includes \