forked from kone-net/go-chat
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
61 lines (53 loc) · 1.42 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
BINARY="chat"
# colors compatible setting
CRED:=$(shell tput setaf 1 2>/dev/null)
CGREEN:=$(shell tput setaf 2 2>/dev/null)
CYELLOW:=$(shell tput setaf 3 2>/dev/null)
CEND:=$(shell tput sgr0 2>/dev/null)
.PHONY: all
all: | fmt build
# Code format
.PHONY: fmt
fmt:
@echo "$(CGREEN)Run gofmt ...$(CEND)"
@echo "gofmt -l -s -w ..."
@ret=0 && for d in $$(go list -f '{{.Dir}}' ./... | grep -v /vendor/); do \
gofmt -l -s -w $$d/*.go || ret=$$? ; \
done ; exit $$ret
# build
.PHONY: build-darwin
build-darwin: fmt
@echo "$(CGREEN)Building for darwin ...$(CEND)"
@mkdir -p bin
CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build -o bin/${BINARY} cmd/main.go
@echo "$(CGREEN)Build Success!$(CEND)"
# build
.PHONY: build
build: fmt
@echo "$(CGREEN)Building for linux ...$(CEND)"
@mkdir -p bin
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o bin/${BINARY} cmd/main.go
@echo "$(CGREEN)Build Success!$(CEND)"
# install
install: build
@echo "$(CGREEN)Install ...$(CEND)"
go install ./...
@echo "$(CGREEN)Install Success!$(CEND)"
# clean
.PHONY: clean
clean:
@echo "$(CGREEN)Cleanup ...$(CEND)"
go clean
@rm -f bin/${BINARY}
@echo "rm -f bin/${BINARY}"
@for GOOS in darwin linux windows; do \
for GOARCH in 386 amd64; do \
rm -f bin/${BINARY}.$${GOOS}-$${GOARCH} ;\
done ;\
done
rm -f ${BINARY} coverage.* test/tmp/*
find . -name "*.log" -delete
# protoc build
.PHONY: protoc
protoc:
protoc --gogo_out=. pkg/protocol/*.proto