-
-
Notifications
You must be signed in to change notification settings - Fork 74
/
Makefile
83 lines (57 loc) · 1.68 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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
SHELL=/bin/sh
CMD=./cmd/slackdump
OUTPUT=slackdump
EXECUTABLE=slackdump
BUILD=$(shell git describe --tags)
COMMIT=$(shell git rev-parse --short HEAD)
ifeq ($(BUILD_DATE),)
BUILD_DATE=$(shell TZ=UTC date -u '+%Y-%m-%d %H:%M:%SZ')
endif
PKG=github.com/rusq/slackdump/v3
LDFLAGS="-s -w -X 'main.commit=$(COMMIT)' -X 'main.version=$(BUILD)' -X 'main.date=$(BUILD_DATE)'"
OSES=linux darwin windows
DISTFILES=README.md LICENSE
ZIPFILES=$(foreach s,$(OSES),$(OUTPUT)-$s.zip)
.PHONY: dist all test
# special guest.
$(OUTPUT)-windows.zip: EXECUTABLE=$(OUTPUT).exe
$(foreach s,$(OSES),$(eval $(OUTPUT)-$s.zip: GOOS=$s))
$(foreach s,$(OSES),$(eval $(OUTPUT)-$s.zip: $(EXECUTABLE)))
all: $(EXECUTABLE)
dist:
$(MAKE) $(ZIPFILES)
%.zip:
7z a $@ $(EXECUTABLE) $(DISTFILES)
rm $(EXECUTABLE)
$(OUTPUT).exe: GOOS=windows
$(OUTPUT).exe: $(OUTPUT)
$(OUTPUT):
GOARCH=$(GOARCH) GOOS=$(GOOS) go build -ldflags=$(LDFLAGS) -o $(EXECUTABLE) $(CMD)
x86_%:
GOARCH=amd64 go build -ldflags=$(LDFLAGS) -o $@ $(CMD)
arm_%:
GOARCH=arm64 go build -ldflags=$(LDFLAGS) -o $@ $(CMD)
clean:
-rm slackdump slackdump.exe $(wildcard *.zip)
test:
go test -race -cover ./...
aurtest:
GOFLAGS="-buildmode=pie -trimpath -ldflags=-linkmode=external -mod=readonly -modcacherw" go build -o 'deleteme' ./cmd/slackdump
rm deleteme
.PHONY: aurtest
docker_test:
docker build .
callvis:
go-callvis -group pkg,type -limit $(PKG) $(PKG)/cmd/slackdump
goreleaser:
goreleaser check
goreleaser release --snapshot --clean
tags:
gotags -R *.go > $@
generate: | install_tools
go generate ./...
.PHONY:generate
install_tools:
go install go.uber.org/mock/mockgen@latest
go install golang.org/x/tools/cmd/stringer@latest
.PHONY: install_tools