Skip to content

Commit 58a667c

Browse files
committed
build: add a make help option for common targets
PR-URL: #17323 Reviewed-By: Jon Moss <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: Richard Lau <[email protected]> Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Evan Lucas <[email protected]> Reviewed-By: Refael Ackermann <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Joyee Cheung <[email protected]>
1 parent 6deae6e commit 58a667c

File tree

1 file changed

+21
-14
lines changed

1 file changed

+21
-14
lines changed

Makefile

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -63,11 +63,17 @@ V ?= 1
6363
# BUILDTYPE=Debug builds both release and debug builds. If you want to compile
6464
# just the debug build, run `make -C out BUILDTYPE=Debug` instead.
6565
ifeq ($(BUILDTYPE),Release)
66-
all: out/Makefile $(NODE_EXE)
66+
all: out/Makefile $(NODE_EXE) ## Default target, builds node in out/Release/node.
6767
else
6868
all: out/Makefile $(NODE_EXE) $(NODE_G_EXE)
6969
endif
7070

71+
# To add a target to the help, add a double comment (##) on the target line.
72+
help: ## Print help for targets with comments.
73+
@printf "For more targets and info see the comments in the Makefile.\n\n"
74+
@grep -E '^[a-zA-Z0-9._-]+:.*?## .*$$' Makefile | sort | \
75+
awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-15s\033[0m %s\n", $$1, $$2}'
76+
7177
# The .PHONY is needed to ensure that we recursively use the out/Makefile
7278
# to check for changes.
7379
.PHONY: $(NODE_EXE) $(NODE_G_EXE)
@@ -94,13 +100,13 @@ out/Makefile: common.gypi deps/uv/uv.gyp deps/http_parser/http_parser.gyp \
94100
config.gypi: configure
95101
$(error Missing or stale $@, please run ./$<)
96102

97-
install: all
103+
install: all ## Installs node into $PREFIX (default=/usr/local).
98104
$(PYTHON) tools/install.py $@ '$(DESTDIR)' '$(PREFIX)'
99105

100-
uninstall:
106+
uninstall: ## Uninstalls node from $PREFIX (default=/usr/local).
101107
$(PYTHON) tools/install.py $@ '$(DESTDIR)' '$(PREFIX)'
102108

103-
clean:
109+
clean: ## Remove build artifacts.
104110
$(RM) -r out/Makefile $(NODE_EXE) $(NODE_G_EXE) out/$(BUILDTYPE)/$(NODE_EXE) \
105111
out/$(BUILDTYPE)/node.exp
106112
@if [ -d out ]; then find out/ -name '*.o' -o -name '*.a' -o -name '*.d' | xargs $(RM) -r; fi
@@ -145,7 +151,7 @@ coverage-clean:
145151
# For C++ coverage reporting, this needs to be run in conjunction with configure
146152
# --coverage. html coverage reports will be created under coverage/
147153

148-
coverage: coverage-test
154+
coverage: coverage-test ## Run the tests and generate a coverage report.
149155

150156
coverage-build: all
151157
mkdir -p node_modules
@@ -206,7 +212,7 @@ v8:
206212
$(MAKE) -C deps/v8 $(V8_ARCH).$(BUILDTYPE_LOWER) $(V8_BUILD_OPTIONS)
207213

208214
ifeq ($(NODE_TARGET_TYPE),static_library)
209-
test: all
215+
test: all ## Default test target. Runs default tests, linters, and builds docs.
210216
$(MAKE) cctest
211217
else
212218
test: all
@@ -378,7 +384,7 @@ test-build: | all build-addons build-addons-napi
378384

379385
test-build-addons-napi: all build-addons-napi
380386

381-
test-all: test-build test/gc/build/Release/binding.node
387+
test-all: test-build test/gc/build/Release/binding.node ## Run everything in test/.
382388
$(PYTHON) tools/test.py --mode=debug,release
383389

384390
test-all-valgrind: test-build
@@ -457,7 +463,7 @@ test-doc: doc-only
457463
test-known-issues: all
458464
$(PYTHON) tools/test.py known_issues
459465

460-
test-npm: $(NODE_EXE)
466+
test-npm: $(NODE_EXE) ## Run the npm test suite on deps/npm.
461467
$(NODE) tools/test-npm-package --install --logfile=test-npm.tap deps/npm test-node
462468

463469
test-npm-publish: $(NODE_EXE)
@@ -499,7 +505,7 @@ test-with-async-hooks:
499505

500506

501507
ifneq ("","$(wildcard deps/v8/tools/run-tests.py)")
502-
test-v8: v8
508+
test-v8: v8 ## Runs the V8 test suite on deps/v8.
503509
# note: performs full test unless QUICKCHECK is specified
504510
deps/v8/tools/run-tests.py --arch=$(V8_ARCH) \
505511
--mode=$(BUILDTYPE_LOWER) $(V8_TEST_OPTIONS) $(QUICKCHECK_ARG) \
@@ -865,7 +871,7 @@ ifeq ($(XZ), 0)
865871
endif
866872
$(RM) $(TARNAME).tar
867873

868-
tar: $(TARBALL)
874+
tar: $(TARBALL) ## Create a source tarball.
869875

870876
tar-upload: tar
871877
ssh $(STAGINGSERVER) "mkdir -p nodejs/$(DISTTYPEDIR)/$(FULLVERSION)"
@@ -901,7 +907,7 @@ ifeq ($(XZ), 0)
901907
endif
902908
$(RM) $(TARNAME)-headers.tar
903909

904-
tar-headers: $(TARBALL)-headers
910+
tar-headers: $(TARBALL)-headers ## Build the node header tarball.
905911

906912
tar-headers-upload: tar-headers
907913
ssh $(STAGINGSERVER) "mkdir -p nodejs/$(DISTTYPEDIR)/$(FULLVERSION)"
@@ -938,7 +944,7 @@ ifeq ($(XZ), 0)
938944
endif
939945
$(RM) $(BINARYNAME).tar
940946

941-
binary: $(BINARYTAR)
947+
binary: $(BINARYTAR) ## Build release binary tarballs.
942948

943949
binary-upload: binary
944950
ssh $(STAGINGSERVER) "mkdir -p nodejs/$(DISTTYPEDIR)/$(FULLVERSION)"
@@ -989,7 +995,7 @@ bench-dgram: all
989995

990996
bench-all: bench bench-misc bench-array bench-buffer bench-url bench-events bench-dgram bench-util
991997

992-
bench: bench-net bench-http bench-fs bench-tls
998+
bench: bench-net bench-http bench-fs bench-tls ## Run node benchmarks.
993999

9941000
bench-ci: bench
9951001

@@ -1115,7 +1121,7 @@ cpplint: lint-cpp
11151121
@echo "Please use lint-cpp instead of cpplint"
11161122

11171123
ifneq ("","$(wildcard tools/eslint/)")
1118-
lint:
1124+
lint: ## Run JS, C++, MD and doc linters.
11191125
@EXIT_STATUS=0 ; \
11201126
$(MAKE) lint-js || EXIT_STATUS=$$? ; \
11211127
$(MAKE) lint-cpp || EXIT_STATUS=$$? ; \
@@ -1181,6 +1187,7 @@ lint-clean:
11811187
docclean \
11821188
docopen \
11831189
dynamiclib \
1190+
help \
11841191
install \
11851192
install-bin \
11861193
install-includes \

0 commit comments

Comments
 (0)