-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
65 lines (54 loc) · 1.27 KB
/
Copy pathMakefile
File metadata and controls
65 lines (54 loc) · 1.27 KB
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
.PHONY: help all build install lint lint-go test tidy demo
#: lint, test, and build (default)
all: lint test tidy build
define PROMPT
@echo
@echo "**********************************************************"
@echo "*"
@echo "* $(1)"
@echo "*"
@echo "**********************************************************"
@echo
endef
#: compile for the current platform
build:
$(call PROMPT, $@)
go build -o loader .
#: install the binary in $GOPATH/bin
install:
$(call PROMPT, $@)
go install
#: run all linters
lint: lint-go
#: run Go linters
lint-go:
$(call PROMPT, $@)
golangci-lint run
#: run all tests
test:
$(call PROMPT, $@)
go test -race ./...
#: tidy go.mod and go.sum
tidy:
$(call PROMPT, $@)
go mod tidy
#: run the demo tape to create the gif
demo: demo.gif
demo.gif: demo.tape build
$(call PROMPT, $@)
PS1="$$ " vhs $<
#: print Makefile targets and short descriptions
help:
@echo "make targets:\n"
@awk '/^#:[[:space:]]/ { sub(/^#:[[:space:]]*/, ""); desc=$$0; next } \
/^[[:space:]]*$$/ { next } \
/^#/ { next } \
/^[a-zA-Z][a-zA-Z0-9_.-]*:/ { \
if (desc != "") { \
split($$0, a, ":"); \
tgt=a[1]; \
gsub(/^[[:space:]]+|[[:space:]]+$$/, "", tgt); \
printf " %-18s %s\n", tgt, desc; \
desc="" \
} \
}' $(firstword $(MAKEFILE_LIST))