-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathmakefile
143 lines (116 loc) · 4.11 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
134
135
136
137
138
139
140
141
142
143
CC=go
RM=rm
MV=mv
SOURCEDIR=./cmd/martine/
SOURCES := $(shell find $(SOURCEDIR) -name '*.go')
ARCHITECTURE:=$(shell go env | grep GOARCH | sed 's/[", ]//g' | cut -d= -f2)
VERSION:=$(shell grep -m1 "AppVersion" ./common/app.go | sed 's/[", ]//g' | cut -d= -f2)
suffix=$(shell grep -m1 "version" $(SOURCEDIR)/*.go | sed 's/[", ]//g' | cut -d= -f2 | sed 's/[0-9.]//g')
snapshot=$(shell date +%FT%T)
UNAME := $(shell uname)
BINARY=binaries
ifeq ($(suffix),rc)
appversion=$(VERSION)$(snapshot)
else
appversion=$(VERSION)
endif
.DEFAULT_GOAL:=build-exe
clean:
$(RM) -fr ${BINARY}
mkdir ${BINARY}
build-exe:
$(RM) -fr ${BINARY}
mkdir ${BINARY}
ifeq ($(UNAME),Linux)
(make build-linux)
else
ifeq ($(UNAME), Darwin)
(make build-darwin)
else
(make build-windows)
endif
endif
package:
$(RM) -fr ${BINARY}
mkdir ${BINARY}
ifeq ($(UNAME),Linux)
(make package-linux ARCH=amd64 OS=linux)
else
ifeq ($(UNAME), Darwin)
(make package-darwin ARCH=amd64 OS=darwin)
else
(make package-windows ARCH=amd64 OS=windows EXT=.exe)
endif
endif
init:
@echo "Compilation for ${ARCH} ${OS} bits"
mkdir ${BINARY}/martine-${OS}-${ARCH}
compile:
GOOS=${OS} GOARCH=${ARCH} $(CC) build ${LDFLAGS} -o ${BINARY}/martine-${OS}-${ARCH}/martine${EXT} $(SOURCEDIR)
GOOS=${OS} GOARCH=${ARCH} $(CC) build ${LDFLAGS} -o ${BINARY}/martine-${OS}-${ARCH}/prepare_delta${EXT} ./resources/formatter/delta/prepare_delta.go
GOOS=${OS} GOARCH=${ARCH} $(CC) build ${LDFLAGS} -o ${BINARY}/martine-${OS}-${ARCH}/format_sprite${EXT} ./resources/formatter/sprites/format_sprite.go
GOOS=${OS} GOARCH=${ARCH} $(CC) build ${LDFLAGS} -o ${BINARY}/martine-${OS}-${ARCH}/format_data${EXT} ./resources/formatter/data/format_data.go
archive:
zip -r ${BINARY}/martine-$(appversion)-${OS}-${ARCH}.zip ${BINARY}/martine-${OS}-${ARCH}/* ./resources/*
build-linux:
@echo "Compilation for linux"
(make init ARCH=${ARCHITECTURE} OS=linux)
(make compile ARCH=${ARCHITECTURE} OS=linux)
(make archive ARCH=${ARCHITECTURE} OS=linux)
build-windows:
@echo "Compilation for windows"
(make init ARCH=amd64 OS=windows EXT=.exe)
(make compile ARCH=amd64 OS=windows EXT=.exe)
(make archive ARCH=amd64 OS=windows EXT=.exe)
build-darwin:
@echo "Compilation for macos"
(make init ARCH=${ARCHITECTURE} OS=darwin)
(make compile ARCH=${ARCHITECTURE} OS=darwin)
(make archive ARCH=${ARCHITECTURE} OS=darwin)
build-raspbian:
@echo "Compilation for raspberry pi Raspbian 64 bits"
(make init ARCH=arm64 OS=linux)
(make compile ARCH=arm64 OS=linux)
(make archive ARCH=arm64 OS=linux)
build-raspbian-i386:
@echo "Compilation for raspberry pi Raspbian 32 bits"
(make init ARCH=arm OS=linux GOARM=5)
(make compile ARCH=arm OS=linux GOARM=5)
(make archive ARCH=arm OS=linux GOARM=5)
build-windows-i386:
@echo "Compilation for windows 32bits"
(make init ARCH=386 OS=windows EXT=.exe)
(make compile ARCH=386 OS=windows EXT=.exe)
(make archive ARCH=386 OS=windows EXT=.exe)
package-darwin:
(make init ARCH=amd64 OS=darwin)
@echo "Compilation and packaging for darwin"
GOARCH=amd64 fyne package -os darwin -icon ../../martine-logo.png -sourceDir ${SOURCEDIR} -name martine -appVersion $(appversion)
mkdir -p ${BINARY}/martine-darwin-amd64/
cp -r martine.app ${BINARY}/martine-darwin-amd64/
(make archive ARCH=amd64 OS=darwin)
package-windows:
(make init ARCH=386 OS=windows EXT=.exe)
@echo "Compilation and packaging for windows"
fyne package -os windows -icon ../../martine-logo.png -sourceDir ${SOURCEDIR} -name martine -appVersion $(appversion)
mv martine.exe ${BINARY}/martine-${OS}-${ARCH}/
(make archive)
package-linux:
(make init)
@echo "Compilation and packaging for linux"
fyne package -os linux -icon ../../martine-logo.png -sourceDir ${SOURCEDIR} -name martine -appVersion $(appversion)
mv martine ${BINARY}/martine-${OS}-${ARCH}/
(make archive)
deps: get-linter get-vulncheck
@echo "Getting tools..."
get-linter:
$(CC) install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
get-vulncheck:
$(CC) install golang.org/x/vuln/cmd/govulncheck@latest
lint:
@echo "Lint the whole project"
golangci-lint run --timeout 5m ./...
vulncheck:
govulncheck ./...
test-unit:
$(CC) test ./... -cover