-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
112 lines (76 loc) · 2.35 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
include ./MANIFEST
include ./scripts/release.mk
DATE := $(shell date | sed 's/\ /_/g')
GOPATH ?= $$PWD/../../../..
GOOS ?= linux
SERVER_SWAGGER_FILE=api/server.yml
CLIENT_SWAGGER_FILE=api/client.yml
PKGS := $(shell go list ./... | grep -vF /vendor/)
JUPITER_PACKAGE=github.com/home-IoT/jupiter/internal/jupiter
# --- Repo
initialize: clean swagger-gen
dep init
$(MAKE) go-dep
clean:
mkdir -p bin
rm -rf ./bin/*
rm -rf ./pkg/*
# --- Tools
get-tools:
go get -u github.com/golang/lint/golint
curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh
# --- Swagger
get-swagger:
go get -u github.com/go-swagger/go-swagger/cmd/swagger
swagger-serve:
swagger serve $(SERVER_SWAGGER_FILE)
swagger-validate:
swagger validate $(SERVER_SWAGGER_FILE)
swagger-gen: swagger-gen-server swagger-gen-client
swagger-gen-server: clean
swagger generate server -f $(SERVER_SWAGGER_FILE) -t server -A jupiter
swagger-gen-client: clean
swagger generate client -f $(CLIENT_SWAGGER_FILE) -t client -A jupiter
# --- Common Go
go-dep:
dep ensure
go-dep-status:
dep status
go-dep-clean: clean
mkdir -p ./bin
rm -rf ./vendor/*
dep ensure
go-fmt:
@go fmt $(PKGS)
go-validate:
@echo go vet
@go vet $(PKGS)
@echo golint
@golint -set_exit_status $(PKGS)
# --- Jupiter Server
go-build-linux:
@echo "build linux binary"
$(MAKE) go-build GOOS=linux GOARCH=amd64 TARGET=$(PROJECT)-linux-amd64
go-build-pi:
@echo "build linux binary for raspberry pi"
$(MAKE) go-build GOOS=linux GOARCH=arm GOARM=7 TARGET=$(PROJECT)-linux-arm7
go-build-windows:
@echo "build windows binary"
$(MAKE) go-build GOOS=windows GOARCH=386 TARGET=$(PROJECT)-windows-386.exe
go-build-mac:
@echo "build Mac binary"
$(MAKE) go-build GOOS=darwin GOARCH=amd64 TARGET=$(PROJECT)-darwin-amd64
TARGET ?= $(PROJECT)
go-build:
go build -ldflags="-X $(JUPITER_PACKAGE).GitRevision=$(shell git rev-parse HEAD) -X $(JUPITER_PACKAGE).BuildVersion=$(VERSION) -X $(JUPITER_PACKAGE).BuildTime=$(DATE)" -i -o ./bin/$(TARGET) server/cmd/jupiter-server/main.go
go-build-all: go-build-pi go-build-linux go-build-windows go-build-mac
run: go-build
./bin/$(TARGET) --port 8080 -c configs/test.yml
# --- Release
go-release-all: clean
$(MAKE) go-build-all
mkdir -p ./release
rm -rf ./release/*
chmod +x bin/*
cp ./bin/* ./release
for bf in ./release/*; do shasum -a 256 "$$bf" > "$$bf".sha256; done