-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
61 lines (54 loc) · 1.75 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
include .version
export
# Go parameters
PROJECT_NAME=PIAAS
GOCMD=go
GOBUILD=$(GOCMD) build
GOCLEAN=$(GOCMD) clean
GOTEST=$(GOCMD) test
GOGET=$(GOCMD) get
BINARY_NAME=piaas
TESTMODE?=all
LDFLAGS=-ldflags "-X main.version=$(VERSION)"
all: test build-all
build:
cd main && CGO_ENABLED=1 GOOS=darwin GOARCH=amd64 $(GOBUILD) $(LDFLAGS) -o ../dist/darwin_amd64/$(BINARY_NAME) -v && cd ..
chmod a+x dist/darwin_amd64/$(BINARY_NAME)
@echo " Built darwin-amd64"
test: test$(TESTMODE)
testall:
$(GOTEST) -v ./...
testdebug:
$(GOTEST) -v ./... -args -debug
tests: tests$(TESTMODE)
testsall:
$(GOTEST) -v ./... -count=10
testsdebug:
$(GOTEST) -v ./... -count=10 -args -debug
clean:
$(GOCLEAN)
rm -rf dist
run: build
./dist/darwin_amd64/$(BINARY_NAME) sync cent -debug
cover:
go test ./... -cover
deps:
$(GOGET) github.com/markbates/goth
$(GOGET) github.com/markbates/pop
# Build on all supported platforms
build-all: build build-linux build-windows
@echo "\n$(PROJECT_NAME) version: $(VERSION) was built.\n"
# Cross compilation on linux
build-linux:
cd main && CGO_ENABLED=0 GOOS=linux GOARCH=amd64 $(GOBUILD) $(LDFLAGS) -o ../dist/linux_amd64/$(BINARY_NAME) -v && cd ..
chmod a+x dist/linux_amd64/$(BINARY_NAME)
@echo " Built linux-amd64"
build-windows:
cd main && CGO_ENABLED=0 GOOS=windows GOARCH=amd64 $(GOBUILD) $(LDFLAGS) -o ../dist/windows_amd64/$(BINARY_NAME).exe -v && cd ..
chmod a+x dist/windows_amd64/$(BINARY_NAME).exe
@echo " Built windows-amd64"
# Create a new release for publish
release: clean test$(TESTMODE) build-all
cd dist/darwin_amd64 && zip piaas-darwin-amd64-$(VERSION).zip * && cd ..
cd dist/linux_amd64 && zip piaas-linux-amd64-$(VERSION).zip * && cd ..
cd dist/windows_amd64 && zip piaas-windows-amd64-$(VERSION).zip * && cd ..