forked from dan-v/rattlesnakeos-stack
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
91 lines (74 loc) · 2.4 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
# modified version of https://gist.github.com/kwilczynski/ab451a357fa59b9377b7d946e557ee79
SHELL := /bin/bash
TARGET := rattlesnakeos-stack
VERSION := $(shell cat VERSION)
OS := darwin linux windows
ARCH := amd64
PKGS := $(shell go list ./internal/... ./cmd...)
.PHONY: \
help \
clean \
tools \
deps \
test \
vet \
lint \
fmt \
build \
build-all \
version
all: fmt lint vet shellcheck test 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 ' tools Install tools needed by the project.'
@echo ' deps Download and install build time dependencies.'
@echo ' test Run unit tests.'
@echo ' vet Run go vet.'
@echo ' lint Run golint.'
@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 ''
print-%:
@echo $* = $($*)
clean:
rm -Rf build
tools:
go get golang.org/x/lint/golint
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:
go mod tidy
test:
go test ${PKGS}
vet:
go vet ${PKGS}
lint:
golint ${PKGS}
golangci-lint run cmd/... internal/... || true
fmt:
go fmt ${PKGS}
shellcheck:
shellcheck --severity=warning templates/build.sh || true
build:
go build -race -ldflags "-X github.com/dan-v/rattlesnakeos-stack/cli.version=$(VERSION)" -v -o "$(TARGET)" .
build-all:
mkdir -v -p $(CURDIR)/build/$(VERSION)
gox -verbose -ldflags "-X github.com/dan-v/rattlesnakeos-stack/cli.version=$(VERSION)" \
-os "$(OS)" -arch "$(ARCH)" \
-output "$(CURDIR)/build/$(VERSION)/{{.OS}}/$(TARGET)" .
cp -v -f \
$(CURDIR)/build/$(VERSION)/$$(go env GOOS)/$(TARGET) .
zip: all
mkdir -p build/zips
pushd build/$(VERSION)/darwin && zip -r ../../../build/zips/rattlesnakeos-stack-osx-${VERSION}.zip $(TARGET) && popd
pushd build/$(VERSION)/windows && zip -r ../../../build/zips/rattlesnakeos-stack-windows-${VERSION}.zip $(TARGET).exe && popd
pushd build/$(VERSION)/linux && zip -r ../../../build/zips/rattlesnakeos-stack-linux-${VERSION}.zip $(TARGET) && popd