-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
53 lines (43 loc) · 1.52 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
BIN_DIR = bin
PROTO_DIR = proto
SERVER_DIR = server
CLIENT_DIR = client
SHELL := bash
SHELL_VERSION = $(shell echo $$BASH_VERSION)
UNAME := $(shell uname -s)
VERSION_AND_ARCH = $(shell uname -rm)
ifeq ($(UNAME),Darwin)
OS = macos ${VERSION_AND_ARCH}
else ifeq ($(UNAME),Linux)
OS = linux ${VERSION_AND_ARCH}
else
$(error OS not supported by this Makefile)
endif
PACKAGE = $(shell head -1 go.mod | awk '{print $$2}')
HELP_CMD = grep -E '^[a-zA-Z_-]+:.*?\#\# .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?\#\# "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
RM_F_CMD = rm -f
RM_RF_CMD = ${RM_F_CMD} -r
SERVER_BIN = ${SERVER_DIR}
CLIENT_BIN = ${CLIENT_DIR}
.DEFAULT_GOAL := help
.PHONY: greet blog calculator help
project := greet calculator blog
blog: $@ ## Generate Pbs and build for blog
$(project):
protoc -I${PROTO_DIR} --go_opt=module=${PACKAGE} --go_out=. --go-grpc_opt=module=${PACKAGE} --go-grpc_out=. ${PROTO_DIR}/*.proto
go build -o ${BIN_DIR}/${SERVER_BIN} ./${SERVER_DIR}
go build -o ${BIN_DIR}/${CLIENT_BIN} ./${CLIENT_DIR}
clean_blog: ## Clean generated files for blog
${RM_F_CMD} ${PROTO_DIR}/*.pb.go
rebuild: clean all ## Rebuild the whole project
bump: all ## Update packages version
go get -u ./...
about: ## Display info related to the build
@echo "OS: ${OS}"
@echo "Shell: ${SHELL} ${SHELL_VERSION}"
@echo "Protoc version: $(shell protoc --version)"
@echo "Go version: $(shell go version)"
@echo "Go package: ${PACKAGE}"
@echo "Openssl version: $(shell openssl version)"
help: ## Show this help
@${HELP_CMD}