-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
61 lines (45 loc) · 1.06 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
# Makefile for Go project
# Go parameters
GOCMD=go
GOBUILD=$(GOCMD) build
GOCLEAN=$(GOCMD) clean
GOTEST=$(GOCMD) test
GOVENDOR=$(GOCMD) mod vendor
# Directories
BINDIR=bin
SRCDIR=cmd
PROTO_DIR=pkg/proto
PKGDIR=pkg
PACKAGEDIR=package
PACKAGEFILE=$(PACKAGEDIR)/my_project.tar.gz
# Linter
LINTER=golangci-lint
# Executable names
CLIENT_EXEC=$(BINDIR)/client
SERVER_EXEC=$(BINDIR)/server
# Protobuf
PROTOC=protoc
PROTO_SRC=$(PROTO_DIR)/*.proto
PROTO_GEN=$(PROTO_DIR)/*.pb.go
# Targets
all: build
build: proto $(CLIENT_EXEC) $(SERVER_EXEC)
$(CLIENT_EXEC): $(SRCDIR)/client/main.go
$(GOBUILD) -o $(CLIENT_EXEC) ./$(SRCDIR)/client
$(SERVER_EXEC): $(SRCDIR)/server/main.go
$(GOBUILD) -o $(SERVER_EXEC) ./$(SRCDIR)/server
lint:
$(LINTER) run
test:
$(GOTEST) ./...
clean:
$(GOCLEAN)
rm -rf $(BINDIR) $(PROTO_GEN) $(PACKAGEDIR)
vendor:
$(GOVENDOR)
proto: $(PROTO_SRC)
$(PROTOC) --go_out=$(PROTO_DIR) --go-grpc_out=$(PROTO_DIR) $(PROTO_SRC)
package: build
mkdir -p $(PACKAGEDIR)
tar -czvf $(PACKAGEFILE) $(BINDIR)
.PHONY: all build clean test lint vendor proto package