Skip to content

Commit

Permalink
build: use make functions instead of echo
Browse files Browse the repository at this point in the history
PR-URL: #35707
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Richard Lau <rlau@redhat.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
  • Loading branch information
aduh95 authored and BethGriggs committed Dec 15, 2020
1 parent 7c089ad commit 6c61b93
Showing 1 changed file with 31 additions and 43 deletions.
74 changes: 31 additions & 43 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ $(NODE_G_EXE): config.gypi out/Debug/build.ninja
if [ ! -r $@ -o ! -L $@ ]; then ln -fs out/Debug/$(NODE_EXE) $@; fi
else
$(NODE_EXE) $(NODE_G_EXE):
echo This Makefile currently only supports building with 'make' or 'ninja'
$(warning This Makefile currently only supports building with 'make' or 'ninja')
endif
endif

Expand All @@ -133,12 +133,9 @@ CONFIG_FLAGS += --debug
endif

.PHONY: with-code-cache
with-code-cache:
echo "'with-code-cache' target is a noop"

.PHONY: test-code-cache
test-code-cache: with-code-cache
echo "'test-code-cache' target is a noop"
with-code-cache test-code-cache:
$(warning '$@' target is a noop)

out/Makefile: config.gypi common.gypi node.gyp \
deps/uv/uv.gyp deps/llhttp/llhttp.gyp deps/zlib/zlib.gyp \
Expand Down Expand Up @@ -468,7 +465,7 @@ benchmark/napi/.buildstamp: $(ADDONS_PREREQS) \

.PHONY: clear-stalled
clear-stalled:
@echo "Clean up any leftover processes but don't error if found."
$(info Clean up any leftover processes but don't error if found.)
ps awwx | grep Release/node | grep -v grep | cat
@PS_OUT=`ps awwx | grep Release/node | grep -v grep | awk '{print $$1}'`; \
if [ "$${PS_OUT}" ]; then \
Expand Down Expand Up @@ -519,7 +516,7 @@ test-ci-js: | clear-stalled
$(PYTHON) tools/test.py $(PARALLEL_ARGS) -p tap --logfile test.tap \
--mode=$(BUILDTYPE_LOWER) --flaky-tests=$(FLAKY_TESTS) \
$(TEST_CI_ARGS) $(CI_JS_SUITES)
@echo "Clean up any leftover processes, error if found."
$(info Clean up any leftover processes, error if found.)
ps awwx | grep Release/node | grep -v grep | cat
@PS_OUT=`ps awwx | grep Release/node | grep -v grep | awk '{print $$1}'`; \
if [ "$${PS_OUT}" ]; then \
Expand All @@ -535,7 +532,7 @@ test-ci: | clear-stalled bench-addons-build build-addons build-js-native-api-tes
--mode=$(BUILDTYPE_LOWER) --flaky-tests=$(FLAKY_TESTS) \
$(TEST_CI_ARGS) $(CI_JS_SUITES) $(CI_NATIVE_SUITES) $(CI_DOC)
out/Release/embedtest 'require("./test/embedding/test-embedding.js")'
@echo "Clean up any leftover processes, error if found."
$(info Clean up any leftover processes, error if found.)
ps awwx | grep Release/node | grep -v grep | cat
@PS_OUT=`ps awwx | grep Release/node | grep -v grep | awk '{print $$1}'`; \
if [ "$${PS_OUT}" ]; then \
Expand Down Expand Up @@ -672,7 +669,7 @@ test-v8: v8 ## Runs the V8 test suite on deps/v8.
--mode=$(BUILDTYPE_LOWER) $(V8_TEST_OPTIONS) \
mjsunit cctest debugger inspector message preparser \
$(TAP_V8)
@echo Testing hash seed
$(info Testing hash seed)
$(MAKE) test-hash-seed

test-v8-intl: v8
Expand All @@ -692,9 +689,8 @@ test-v8-all: test-v8 test-v8-intl test-v8-benchmarks test-v8-updates
# runs all v8 tests
else
test-v8 test-v8-intl test-v8-benchmarks test-v8-all:
@echo "Testing v8 is not available through the source tarball."
@echo "Use the git repo instead:" \
"$ git clone https://github.com/nodejs/node.git"
$(warning Testing V8 is not available through the source tarball.)
$(warning Use the git repo instead: $$ git clone https://github.com/nodejs/node.git)
endif

apidoc_dirs = out/doc out/doc/api out/doc/api/assets
Expand Down Expand Up @@ -929,14 +925,13 @@ MACOSOUTDIR=out/macos

ifeq ($(SKIP_XZ), 1)
check-xz:
@echo "SKIP_XZ=1 supplied, skipping .tar.xz creation"
$(info SKIP_XZ=1 supplied, skipping .tar.xz creation)
else
ifeq ($(HAS_XZ), 1)
check-xz:
else
check-xz:
@echo "No xz command, cannot continue"
@exit 1
$(error No xz command, cannot continue)
endif
endif

Expand Down Expand Up @@ -1169,12 +1164,9 @@ ifeq ($(XZ), 1)
endif

.PHONY: bench-all
bench-all: bench-addons-build
@echo "Please use benchmark/run.js or benchmark/compare.js to run the benchmarks."

.PHONY: bench
bench: bench-addons-build
@echo "Please use benchmark/run.js or benchmark/compare.js to run the benchmarks."
bench bench-all: bench-addons-build
$(warning Please use benchmark/run.js or benchmark/compare.js to run the benchmarks.)

# Build required addons for benchmark before running it.
.PHONY: bench-addons-build
Expand All @@ -1198,7 +1190,7 @@ lint-md-clean:

.PHONY: lint-md-build
lint-md-build:
$(warning "Deprecated no-op target 'lint-md-build'")
$(warning Deprecated no-op target 'lint-md-build')

ifeq ("$(wildcard tools/.mdlintstamp)","")
LINT_MD_NEWER =
Expand All @@ -1213,7 +1205,7 @@ LINT_MD_FILES = $(shell $(FIND) $(LINT_MD_TARGETS) -type f \
run-lint-md = tools/lint-md.js -q -f --no-stdout $(LINT_MD_FILES)
# Lint all changed markdown files maintained by us
tools/.mdlintstamp: $(LINT_MD_FILES)
@echo "Running Markdown linter..."
$(info Running Markdown linter...)
@$(call available-node,$(run-lint-md))
@touch $@

Expand Down Expand Up @@ -1244,7 +1236,7 @@ lint-js:
fi

jslint: lint-js
@echo "Please use lint-js instead of jslint"
$(warning Please use lint-js instead of jslint)

run-lint-js-ci = tools/node_modules/eslint/bin/eslint.js \
--report-unused-disable-directives --ext=.js,.mjs,.md -f tap \
Expand All @@ -1253,11 +1245,11 @@ run-lint-js-ci = tools/node_modules/eslint/bin/eslint.js \
.PHONY: lint-js-ci
# On the CI the output is emitted in the TAP format.
lint-js-ci:
@echo "Running JS linter..."
$(info Running JS linter...)
@$(call available-node,$(run-lint-js-ci))

jslint-ci: lint-js-ci
@echo "Please use lint-js-ci instead of jslint-ci"
$(warning Please use lint-js-ci instead of jslint-ci)

LINT_CPP_ADDON_DOC_FILES_GLOB = test/addons/??_*/*.cc test/addons/??_*/*.h
LINT_CPP_ADDON_DOC_FILES = $(wildcard $(LINT_CPP_ADDON_DOC_FILES_GLOB))
Expand Down Expand Up @@ -1314,15 +1306,15 @@ CLANG_FORMAT_START ?= HEAD
# $ CLANG_FORMAT_START=master make format-cpp
format-cpp: ## Format C++ diff from $CLANG_FORMAT_START to current changes
ifneq ("","$(wildcard tools/clang-format/node_modules/)")
@echo "Formatting C++ diff from $(CLANG_FORMAT_START).."
$(info Formatting C++ diff from $(CLANG_FORMAT_START)..)
@$(PYTHON) tools/clang-format/node_modules/.bin/git-clang-format \
--binary=tools/clang-format/node_modules/.bin/clang-format \
--style=file \
$(CLANG_FORMAT_START) -- \
$(LINT_CPP_FILES)
else
@echo "clang-format is not installed."
@echo "To install (requires internet access) run: $ make format-cpp-build"
$(info clang-format is not installed.)
$(info To install (requires internet access) run: $$ make format-cpp-build)
endif

ifeq ($(V),1)
Expand All @@ -1335,7 +1327,7 @@ endif
lint-cpp: tools/.cpplintstamp

tools/.cpplintstamp: $(LINT_CPP_FILES)
@echo "Running C++ linter..."
$(info Running C++ linter...)
@$(PYTHON) tools/cpplint.py $(CPPLINT_QUIET) $?
@$(PYTHON) tools/checkimports.py $?
@touch $@
Expand All @@ -1344,19 +1336,19 @@ tools/.cpplintstamp: $(LINT_CPP_FILES)
lint-addon-docs: tools/.doclintstamp

tools/.doclintstamp: test/addons/.docbuildstamp
@echo "Running C++ linter on addon docs..."
$(info Running C++ linter on addon docs...)
@$(PYTHON) tools/cpplint.py $(CPPLINT_QUIET) --filter=$(ADDON_DOC_LINT_FLAGS) \
$(LINT_CPP_ADDON_DOC_FILES_GLOB)
@touch $@

cpplint: lint-cpp
@echo "Please use lint-cpp instead of cpplint"
$(warning Please use lint-cpp instead of cpplint)

.PHONY: lint-py-build
# python -m pip install flake8
# Try with '--system' is to overcome systems that blindly set '--user'
lint-py-build:
@echo "Pip installing flake8 linter on $(shell $(PYTHON) --version)..."
$(info Pip installing flake8 linter on $(shell $(PYTHON) --version)...)
$(PYTHON) -m pip install --upgrade -t tools/pip/site-packages flake8 || \
$(PYTHON) -m pip install --upgrade --system -t tools/pip/site-packages flake8

Expand All @@ -1368,8 +1360,8 @@ lint-py:
PYTHONPATH=tools/pip $(PYTHON) -m flake8 --count --show-source --statistics .
else
lint-py:
@echo "Python linting with flake8 is not avalible"
@echo "Run 'make lint-py-build'"
$(warning Python linting with flake8 is not avalible)
$(warning Run 'make lint-py-build')
endif

.PHONY: lint
Expand All @@ -1395,12 +1387,9 @@ lint-ci: lint-js-ci lint-cpp lint-py lint-md lint-addon-docs
exit 1 ; \
fi
else
lint:
@echo "Linting is not available through the source tarball."
@echo "Use the git repo instead:" \
"$ git clone https://github.com/nodejs/node.git"

lint-ci: lint
lint lint-ci:
$(info Linting is not available through the source tarball.)
$(info Use the git repo instead: $$ git clone https://github.com/nodejs/node.git)
endif

.PHONY: lint-clean
Expand All @@ -1420,6 +1409,5 @@ gen-openssl: ## Generate platform dependent openssl files (requires docker)
$(DOCKER_COMMAND) node-openssl-builder make -C deps/openssl/config
else
gen-openssl:
@echo "No docker command, cannot continue"
@exit 1
$(error No docker command, cannot continue)
endif

0 comments on commit 6c61b93

Please sign in to comment.