-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
60 lines (47 loc) · 1.21 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
BIN = ~/go/bin
VERSION ?= DEV
COMMIT=$(shell git rev-parse HEAD)
BRANCH=$(shell git rev-parse --abbrev-ref HEAD)
GOPATH=$(shell go env GOPATH)
LDFLAGS = -ldflags "-X main.VERSION=${VERSION} -X main.COMMIT=${COMMIT} -X main.BRANCH=${BRANCH}"
ARCH_OPT = CGO_ENABLED=0
ifeq ($(OS),Windows_NT)
BINARY = go-foosball.exe
ARCH_OPT := ${ARCH_OPT} GOOS=windows
else
UNAME_S := $(shell uname -s)
ifeq ($(UNAME_S),Linux)
ARCH_OPT := ${ARCH_OPT} GOOS=linux
BINARY = go-foosball-linux
endif
ifeq ($(UNAME_S),Darwin)
ARCH_OPT := ${ARCH_OPT} GOOS=darwin
BINARY = go-foosball-darwin
endif
ifneq ($(strip $(GOARCH)),)
ARCH_OPT := ${ARCH_OPT} GOARCH=${GOARCH}
BINARY := ${BINARY}-${GOARCH}
endif
ifneq ($(strip $(GOARM)),)
ARCH_OPT := ${ARCH_OPT} GOARM=${GOARM}
endif
endif
.PHONY: client clean
all: test vet build
swagger:
$(GOPATH)/bin/swag init
format:
$(GOPATH)/bin/swag fmt
build:
${ARCH_OPT} go build ${LDFLAGS} -o ${BINARY}
test:
go test -cover ./...
vet:
go vet ./...
client:
cd client; pnpm install; pnpm build
clean:
go clean
go mod tidy
$(shell if [ ! -d "./client/build" ]; then mkdir -p ./client/build; fi)
$(shell if [ ! -f "./client/build/test.html" ]; then touch ./client/build/test.html; fi)