forked from charlieparkes/build-harness
-
Notifications
You must be signed in to change notification settings - Fork 6
/
Makefile.helpers
73 lines (58 loc) · 1.69 KB
/
Makefile.helpers
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#
# Helpers - stuff that's shared between make files
#
EDITOR ?= vim
SHELL = /bin/bash
SHELL_UID := $(shell ls -id . | cut -d' ' -f1)_$(shell id -u)
DEFAULT_HELP_TARGET ?= help/short
HELP_FILTER ?= .*
green = $(shell echo -e '\x1b[32;01m$1\x1b[0m')
yellow = $(shell echo -e '\x1b[33;01m$1\x1b[0m')
red = $(shell echo -e '\x1b[33;31m$1\x1b[0m')
# Ensures that a variable is defined
define assert-set
@[ -n "$($1)" ] || (echo "$(1) not defined in $(@)"; exit 1)
endef
# Ensures that a variable is undefined
define assert-unset
@[ -z "$($1)" ] || (echo "$(1) should not be defined in $(@)"; exit 1)
endef
# Print a variable
define print-var
@echo "$(1)=$($1)"
endef
define python-version
$(shell python -c 'import platform; print(platform.python_version())' 2>/dev/null)
endef
default:: $(DEFAULT_HELP_TARGET)
@exit 0
## Help screen
help:
@printf "Available targets:\n\n"
@$(SELF) -s help/generate | grep -E "\w($(HELP_FILTER))"
## Display help for all targets
help/all:
@printf "Available targets:\n\n"
@$(SELF) -s help/generate
## This help short screen
help/short:
@printf "Available targets:\n\n"
@$(SELF) -s help/generate MAKEFILE_LIST="Makefile $(BUILD_HARNESS_PATH)/Makefile.helpers"
# Generate help output from MAKEFILE_LIST
help/generate:
@awk '/^[a-zA-Z\-\_0-9%:\\\/]+:/ { \
helpMessage = match(lastLine, /^## (.*)/); \
if (helpMessage) { \
helpCommand = $$1; \
helpMessage = substr(lastLine, RSTART + 3, RLENGTH); \
gsub("\\\\", "", helpCommand); \
gsub(":+$$", "", helpCommand); \
printf " \x1b[32;01m%-35s\x1b[0m %s\n", helpCommand, helpMessage; \
} \
} \
{ lastLine = $$0 }' $(MAKEFILE_LIST) | sort -u
@printf "\n"
reports/:
mkdir -p $@
qa_reports/:
mkdir -p $@