warn if "make update" was not executed
and warn if Make's parallelism is not enabled
This commit is contained in:
parent
059d8151c5
commit
e2de003ce6
12
README.md
12
README.md
|
@ -144,6 +144,18 @@ Link PCRE, defaults to 1.
|
|||
|
||||
Internal target that creates the directory with the same name.
|
||||
|
||||
### sanity-checks
|
||||
|
||||
Internal target used to check that a C compiler is installed.
|
||||
|
||||
### warn-update
|
||||
|
||||
Internal target that checks if `make update` was executed for the current Git commit.
|
||||
|
||||
### warn-jobs
|
||||
|
||||
Internal target that checks if Make's parallelism was enabled by specifying the number of jobs.
|
||||
|
||||
### deps-common
|
||||
|
||||
Internal target that needs to be a dependency for a custom "deps" target which,
|
||||
|
|
|
@ -7,6 +7,8 @@
|
|||
|
||||
.PHONY: \
|
||||
sanity-checks \
|
||||
warn-update \
|
||||
warn-jobs \
|
||||
deps-common \
|
||||
build-nim \
|
||||
update-common \
|
||||
|
@ -36,9 +38,24 @@ build:
|
|||
sanity-checks:
|
||||
which $(CC) &>/dev/null || { echo "C compiler ($(CC)) not installed. Aborting."; exit 1; }
|
||||
|
||||
#- runs only the first time and after `make update`, so have "normal"
|
||||
# (timestamp-checked) prerequisites here
|
||||
deps-common: sanity-checks $(NIMBLE_DIR)
|
||||
#- check if "make update" was executed
|
||||
warn-update:
|
||||
if [[ -e $(UPDATE_TIMESTAMP) ]]; then \
|
||||
if [[ $$(cat $(UPDATE_TIMESTAMP)) -ne $$($(GET_CURRENT_COMMIT_TIMESTAMP)) ]]; then \
|
||||
echo -e "\n\"$$(basename "$(MAKE)") update\" was not executed for the current Git commit! The resulting build is unsupported.\n"; \
|
||||
fi; \
|
||||
fi
|
||||
|
||||
#- check if we're enabling multiple jobs - https://stackoverflow.com/a/48865939
|
||||
warn-jobs:
|
||||
+ if [[ ! "${MAKEFLAGS}" =~ --jobserver[^=]+= ]]; then \
|
||||
NPROC=$$($(NPROC_CMD)); \
|
||||
if [[ $${NPROC} -gt 1 ]]; then \
|
||||
echo -e "\nTip of the day: this will probably build faster if you use \"$$(basename "$(MAKE)") -j$${NPROC} ...\".\n"; \
|
||||
fi; \
|
||||
fi
|
||||
|
||||
deps-common: | sanity-checks warn-update warn-jobs $(NIMBLE_DIR)
|
||||
# - don't build our Nim target if it's not going to be used
|
||||
ifeq ($(USE_SYSTEM_NIM), 0)
|
||||
deps-common: $(NIM_BINARY)
|
||||
|
@ -66,6 +83,7 @@ build-nim: | sanity-checks
|
|||
#- initialises and updates the Git submodules
|
||||
#- hard-resets the working copies of submodules
|
||||
#- deletes "nimcache" directories
|
||||
#- updates ".update.timestamp"
|
||||
#- deletes the ".nimble" dir and executes the "deps" target
|
||||
#- allows parallel building with the '+' prefix
|
||||
#- rebuilds the Nim compiler if the corresponding submodule is updated
|
||||
|
@ -77,6 +95,7 @@ update-common: | sanity-checks
|
|||
git submodule update --init --recursive
|
||||
git submodule foreach --quiet --recursive 'git reset --quiet --hard'
|
||||
find . -type d -name nimcache -print0 | xargs -0 rm -rf
|
||||
$(GET_CURRENT_COMMIT_TIMESTAMP) > $(UPDATE_TIMESTAMP)
|
||||
rm -rf $(NIMBLE_DIR)
|
||||
+ "$(MAKE)" --no-print-directory deps
|
||||
ifeq ($(USE_SYSTEM_NIM), 0)
|
||||
|
|
|
@ -66,33 +66,46 @@ GIT_STATUS := git status
|
|||
#- duplicated in "env.sh" for the env var with the same name
|
||||
NIMBLE_DIR := vendor/.nimble
|
||||
REPOS_DIR := vendor
|
||||
|
||||
ifeq ($(OS), Windows_NT)
|
||||
PWD := pwd -W
|
||||
EXE_SUFFIX := .exe
|
||||
# available since Git 2.9.4
|
||||
GIT_TIMESTAMP_ARG := --date=unix
|
||||
else
|
||||
PWD := pwd
|
||||
EXE_SUFFIX :=
|
||||
# available since Git 2.7.0
|
||||
GIT_TIMESTAMP_ARG := --date=format-local:%s
|
||||
endif
|
||||
|
||||
ifeq ($(shell uname), Darwin)
|
||||
# md5sum - macOS is a special case
|
||||
MD5SUM := md5 -r
|
||||
NPROC_CMD := sysctl -n hw.logicalcpu
|
||||
else
|
||||
MD5SUM := md5sum
|
||||
NPROC_CMD := nproc
|
||||
endif
|
||||
|
||||
GET_CURRENT_COMMIT_TIMESTAMP := git log --pretty=format:%cd -n 1 $(GIT_TIMESTAMP_ARG)
|
||||
UPDATE_TIMESTAMP := .update.timestamp
|
||||
|
||||
ifeq ($(BUILD_SYSTEM_DIR),)
|
||||
$(error You need to define BUILD_SYSTEM_DIR before including this file)
|
||||
endif
|
||||
|
||||
# we want a "recursively expanded" (delayed interpolation) variable here, so we can set CMD in rule recipes
|
||||
RUN_CMD_IN_ALL_REPOS = git submodule foreach --recursive --quiet 'echo -e "\n\e[32m$$name:\e[39m"; $(CMD)'; echo -e "\n\e[32m$$($(PWD)):\e[39m"; $(CMD)
|
||||
|
||||
# absolute path, since it will be run at various subdirectory depths
|
||||
ENV_SCRIPT := "$(CURDIR)/$(BUILD_SYSTEM_DIR)/scripts/env.sh"
|
||||
|
||||
# duplicated in "env.sh" to prepend NIM_DIR/bin to PATH
|
||||
NIM_DIR := $(BUILD_SYSTEM_DIR)/vendor/Nim
|
||||
|
||||
ifeq ($(OS), Windows_NT)
|
||||
EXE_SUFFIX := .exe
|
||||
else
|
||||
EXE_SUFFIX :=
|
||||
endif
|
||||
NIM_BINARY := $(NIM_DIR)/bin/nim$(EXE_SUFFIX)
|
||||
# md5sum - macOS is a special case
|
||||
ifeq ($(shell uname), Darwin)
|
||||
MD5SUM := md5 -r
|
||||
else
|
||||
MD5SUM := md5sum
|
||||
endif
|
||||
|
||||
# AppVeyor/Travis cache of $(NIM_DIR)/bin
|
||||
CI_CACHE :=
|
||||
|
||||
|
|
Loading…
Reference in New Issue