-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathMakefile.ext
68 lines (55 loc) · 2.65 KB
/
Makefile.ext
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
LDFLAGS := -X main.Config=$(CURDIR)/config
# extend clean up debug directories created by vscode.
clean::
find -name "__debug_bin*" -exec rm -vrf {} \;;
#@ bump version and update Makefiles to reflect change.
bump:: version-bump
version-bump version-bump-reset:: install
@VERSION="$$(cat VERSION)"; \
sed -i -e "s#\(github.com[/:]tkrop/go-make@v\)[^ ]*#\1$${VERSION}#" \
Makefile config/Makefile config/Makefile.base; \
# customize commit target with config file synchronization check.
commit:: sync-check
#@ check all config files to be synchronized with config directory.
sync-check::
@for FILE in $$(find config -type f ! -name "Makefile.vars" ! -name "Makefile"); do \
if [ -f "$${FILE#*/}" ] && [ -n "$$(diff "$${FILE}" "$${FILE#*/}")" ]; then \
echo "error: $${FILE} (not synchronized)" > "/dev/stderr"; exit -1; \
fi; \
done;
#@ sync all config files with their respective Makefile.
sync::
@for FILE in $$(find config -type f ! -name "Makefile.vars"); do \
if [ -f "$${FILE#*/}" ] && [ -n "$$(diff "$${FILE}" "$${FILE#*/}")" ]; then \
echo "sync: $${FILE#*/} => $${FILE}"; cp "$${FILE#*/}" "$${FILE}"; \
fi; \
done;
## Experiment:
#@ test function for git message creation.
test-git-message:: test-git-message-fix
$(addprefix test-git-message-,$(COMMIT_CONVENTION)):: test-git-message-%:
@MESSAGE="$(RUNARGS)"; $(call git-message,$*,1); echo "$${MESSAGE}";
#@ test function for go package version evaluation.
test-check-version::
@$(call go-check-version,go-make,$(RUNARGS),)
#@ test function for test argument evaluation.
test-args::
@$(call test-args,$(RUNARGS))
# TODO: fix ordering issue.
test-test-args::
@ACTUAL=($$(make -f Makefile.base test-args scope:all cmd/TestCmd)) && \
EXPECTED=("-coverpkg=./..." "./cmd" "-run" "TestCmd") && \
DIFF="$$(diff <(echo "$${ACTUAL[*]}") <(echo "$${EXPECTED[*]}"))" && \
ACTUAL=($$(make -f Makefile.base test-args scope:all internal/make)) && \
EXPECTED=("-coverpkg=./..." "./internal/make") && \
DIFF="$$(diff <(echo "$${ACTUAL[*]}") <(echo "$${EXPECTED[*]}"))" && \
ACTUAL=($$(make -f Makefile.base test-args internal/make/make_test.go)) && \
EXPECTED=($$(find ./internal/make -name "*.go" | sort -u)) && \
DIFF="$$(diff <(echo "$${ACTUAL[*]}") <(echo "$${EXPECTED[*]}"))" && \
echo "info: test-args finished successful!!" || echo "$${DIFF}";
# Not sure whether this helps - showing allways diff in timings.
test-compat::
@ACTUAL="$$(make --makefile=$(GOMAKE_MAKEFILE) test-self 2>&1)" && \
COMPAT="$$(BASH_COMPAT=3.2 make --makefile=$(GOMAKE_MAKEFILE) test-self 2>&1)" && \
DIFF="$$(diff <(echo "$${ACTUAL}") <(echo "$${COMPAT}"))" && \
echo "info: test-compat finished successful!!" || echo "$${DIFF}";