This repository has been archived by the owner on Jan 31, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathMakefile
133 lines (110 loc) · 3.37 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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
# modified version of https://gist.github.com/kwilczynski/ab451a357fa59b9377b7d946e557ee79
SHELL := /bin/bash
TARGET := slack-to-telegram
VERSION := $(shell cat VERSION)
OS := darwin linux windows freebsd
ARCH := amd64
.PHONY: \
help \
default \
clean \
clean-artifacts \
clean-vendor \
tools \
deps \
test \
coverage \
vet \
errors \
fmt \
env \
build \
build-all \
doc \
check \
version
all: fmt vet build-all
help:
@echo 'Usage: make <OPTIONS> ... <TARGETS>'
@echo ''
@echo 'Available targets are:'
@echo ''
@echo ' help Show this help screen.'
@echo ' clean Remove binaries, artifacts and releases.'
@echo ' clean-artifacts Remove build artifacts only.'
@echo ' clean-vendor Remove content of the vendor directory.'
@echo ' tools Install tools needed by the project.'
@echo ' deps Download and install build time dependencies.'
@echo ' test Run unit tests.'
@echo ' coverage Report code tests coverage.'
@echo ' vet Run go vet.'
@echo ' fmt Run go fmt.'
@echo ' env Display Go environment.'
@echo ' build Build project for current platform.'
@echo ' build-all Build project for all supported platforms.'
@echo ' doc Start Go documentation server on port 8080.'
@echo ' check Verify compiled binary.'
@echo ' version Display Go version.'
@echo ''
@echo 'Targets run by default are: imports, fmt, vet, errors and build.'
@echo ''
print-%:
@echo $* = $($*)
clean: clean-artifacts
go clean -i ./...
rm -vf $(CURDIR)/coverage.*
clean-artifacts:
rm -Rf artifacts
clean-vendor:
find $(CURDIR)/vendor -type d -print0 2>/dev/null | xargs -0 rm -Rf
clean-all: clean clean-artifacts clean-vendor
tools:
go get github.com/axw/gocov/gocov
go get github.com/matm/gocov-html
go get github.com/tools/godep
go get github.com/mitchellh/gox
deps:
dep ensure
test:
go test -v ./...
coverage:
gocov test ./... > $(CURDIR)/coverage.out 2>/dev/null
gocov report $(CURDIR)/coverage.out
if test -z "$$CI"; then \
gocov-html $(CURDIR)/coverage.out > $(CURDIR)/coverage.html; \
if which open &>/dev/null; then \
open $(CURDIR)/coverage.html; \
fi; \
fi
vet:
go vet -v ./...
fmt:
go fmt ./...
env:
@go env
build:
go build -race -ldflags "-X main.version=$(VERSION)" -v -o "$(TARGET)" .
build-all:
mkdir -v -p $(CURDIR)/artifacts/$(VERSION)
gox -verbose -ldflags "-X main.version=$(VERSION)" \
-os "$(OS)" -arch "$(ARCH)" \
-output "$(CURDIR)/artifacts/$(VERSION)/{{.OS}}/$(TARGET)" .
cp -v -f \
$(CURDIR)/artifacts/$(VERSION)/$$(go env GOOS)/$(TARGET) .
doc:
godoc -http=:8080 -index
check:
@test -x $(CURDIR)/$(TARGET) || exit 1
if $(CURDIR)/$(TARGET) --version | grep -qF '$(VERSION)'; then \
echo "$(CURDIR)/$(TARGET): OK"; \
else \
exit 1; \
fi
version:
@go version
zip: all
mkdir -p artifacts/zips
zip -r artifacts/zips/slack-to-telegram-osx-${VERSION}.zip artifacts/$(VERSION)/darwin/$(TARGET)
zip -r artifacts/zips/slack-to-telegram-windows-${VERSION}.zip artifacts/$(VERSION)/windows/$(TARGET).exe
zip -r artifacts/zips/slack-to-telegram-linux-${VERSION}.zip artifacts/$(VERSION)/linux/$(TARGET)
zip -r artifacts/zips/slack-to-telegram-freebsd-${VERSION}.zip artifacts/$(VERSION)/freebsd/$(TARGET)