-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
50 lines (40 loc) · 1.16 KB
/
Makefile
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
SRCS := $(shell find . -name '*.go')
GOFLAGS=-trimpath -ldflags "-s -w" -buildvcs=false
define goos
$(word 2,\
$(subst _, ,\
$(subst .exe, ,\
$(subst macOS,darwin,$(1)))))
endef
define goarch
$(word 3,\
$(subst _, ,\
$(subst .exe, ,\
$(subst macOS,darwin,$(1)))))
endef
build: haze
haze: $(SRCS)
go build $(GOFLAGS) .
all: build/dist/haze_linux_amd64.tar.gz \
build/dist/haze_linux_386.tar.gz \
build/dist/haze_linux_arm.tar.gz \
build/dist/haze_windows_amd64.exe.tar.gz \
build/dist/haze_windows_386.exe.tar.gz \
build/dist/haze_macOS_amd64.tar.gz \
build/dist/haze_macOS_arm64.tar.gz
build/dist/haze_%.tar.gz: build/bin/haze_%
mkdir -p build/dist/
tar --transform 's_build/bin/__;s_haze.*_haze_' \
--owner haze:1000 --group haze:1000 \
-czvf $@ README.md LICENSE $<
build/bin/haze_%: $(SRCS)
env GOOS=$(call goos,$@) GOARCH=$(call goarch,$@) go build -o $@ $(GOFLAGS) .
.PHONY: format
format:
gofmt -s -w */*go
.PHONY: vet
vet:
go vet ./...
.PHONY: test
test:
for s in $$(go list ./...); do if ! go test -failfast -v $$s; then break; fi; done | sed ''/PASS/s//$$(printf "\033[32mPASS\033[0m")/'' | sed ''/FAIL/s//$$(printf "\033[31mFAIL\033[0m")/''