build(make): Defensive make settings best practice
I've been bitten by silent failures in make many times and these settings have spared me that many times. I now use them religiously whenever possible.
This commit is contained in:
parent
2465acb451
commit
c43baf6d9a
1 changed files with 25 additions and 3 deletions
28
Makefile
28
Makefile
|
|
@ -1,7 +1,20 @@
|
||||||
|
# Defensive settings for make:
|
||||||
|
# https://tech.davis-hansson.com/p/make/
|
||||||
|
SHELL:=bash
|
||||||
|
.ONESHELL:
|
||||||
|
.SHELLFLAGS:=-eu -o pipefail -c
|
||||||
|
.SILENT:
|
||||||
|
.DELETE_ON_ERROR:
|
||||||
|
MAKEFLAGS+=--warn-undefined-variables
|
||||||
|
MAKEFLAGS+=--no-builtin-rules
|
||||||
|
export PS1?=$$
|
||||||
|
# Prefix echoed recipe commands with the recipe line number for debugging:
|
||||||
|
export PS4?=:$$LINENO+
|
||||||
|
|
||||||
# Get version related variables
|
# Get version related variables
|
||||||
export DATE=$(shell date +'%Y.%m.%d')
|
export DATE:=$(shell date +'%Y.%m.%d')
|
||||||
export DATE_COMMIT_COUNT=$(shell git rev-list --count HEAD --since="$(DATE) 00:00:00")
|
export DATE_COMMIT_COUNT:=$(shell git rev-list --count HEAD --since="$(DATE) 00:00:00")
|
||||||
export COMMIT_HASH=$(shell git rev-parse --short HEAD)
|
export COMMIT_HASH:=$(shell git rev-parse --short HEAD)
|
||||||
|
|
||||||
# Set Local version to YYYY.MM.DD-<hash>
|
# Set Local version to YYYY.MM.DD-<hash>
|
||||||
export LOCAL_VERSION="$(DATE)+$(COMMIT_HASH)"
|
export LOCAL_VERSION="$(DATE)+$(COMMIT_HASH)"
|
||||||
|
|
@ -13,6 +26,15 @@ else
|
||||||
export PYPI_VERSION="$(DATE).post$(DATE_COMMIT_COUNT)"
|
export PYPI_VERSION="$(DATE).post$(DATE_COMMIT_COUNT)"
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
# Finished with `$(shell)`, echo recipe commands going forward
|
||||||
|
.SHELLFLAGS+= -x
|
||||||
|
|
||||||
|
|
||||||
|
### Top-level targets:
|
||||||
|
|
||||||
|
.PHONY: all
|
||||||
|
all: check_lint docs docker docker_ubuntu docker_gui
|
||||||
|
|
||||||
lint:
|
lint:
|
||||||
python3 -m isort .
|
python3 -m isort .
|
||||||
python3 -m black .
|
python3 -m black .
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue