-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
68 lines (54 loc) · 1.76 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
.DEFAULT_GOAL:=build
.PHONY: build init clean compile deps get-linter get-vulncheck lint vulncheck test
GO=go
RM=rm
MV=mv
MODULE=$(awk '/^module / {print $2}' go.mod)
SOURCEDIR=./cli
SOURCES := $(shell find $(SOURCEDIR) -name '*.go')
BINARIES=binaries
VERSION:=$(shell grep -m1 "appVersion" cli/main.go | sed 's/[", ]//g' | cut -d= -f2)
suffix=$(shell grep -m1 "appVersion" cli/main.go | sed 's/[", ]//g' | cut -d= -f2 | sed 's/[0-9.]//g')
snapshot=$(shell date +%FT%T)
ifeq ($(suffix),rc)
appversion=$(VERSION)$(snapshot)
else
appversion=$(VERSION)
endif
build: clean init
@echo "Update packages"
go get -d ./...
@echo "Compilation for linux amd64"
(make compile ARCH=amd64 OS=linux)
@echo "Compilation for windows amd64"
(make compile ARCH=amd64 OS=windows EXT=.exe)
@echo "Compilation for macos"
(make compile ARCH=amd64 OS=darwin)
(make compile ARCH=arm64 OS=darwin)
@echo "Compilation for raspberry pi Raspbian 64bits"
(make compile ARCH=arm64 OS=linux)
@echo "Compilation for raspberry pi Raspbian 32bits"
(make compile ARCH=arm OS=linux GOARM=5)
@echo "Compilation for older windows"
(make compile ARCH=386 OS=windows EXT=.exe)
init:
mkdir ${BINARIES}
clean:
@echo "Cleaning project"
rm -fr ${BINARIES}/
compile:
GOOS=${OS} GOARCH=${ARCH} ${GO} build ${LDFLAGS} -o ${BINARIES}/dsk-${OS}-${ARCH}${EXT} $(SOURCEDIR)/main.go
zip ${BINARIES}/dsk-$(appversion)-${OS}-${ARCH}.zip ${BINARIES}/dsk-${OS}-${ARCH}${EXT}
deps: get-linter get-vulncheck
@echo "Getting tools..."
get-linter:
go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
get-vulncheck:
go install golang.org/x/vuln/cmd/govulncheck@latest
lint:
@echo "Lint the whole project"
golangci-lint run --timeout 5m ./...
vulncheck:
govulncheck $(MODULE)
test:
${GO} test ./... -cover