forked from Clement-Jean/proto-go-course
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
33 lines (28 loc) · 719 Bytes
/
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
PROTO_DIR = proto
ifeq ($(OS), Windows_NT)
OS = windows
SHELL := powershell.exe
.SHELLFLAGS := -NoProfile -Command
PACKAGE = $(shell Get-Content go.mod -head 1 | Foreach-Object { $$data = $$_ -split " "; "{0}" -f $$data[1]})
BIN = proto-go-course.exe
else
UNAME := $(shell uname -s)
ifeq ($(UNAME),Darwin)
OS = macos
else ifeq ($(UNAME),Linux)
OS = linux
else
$(error OS not supported by this Makefile)
endif
PACKAGE = $(shell head -1 go.mod | awk '{print $$2}')
BIN = proto-go-course
endif
build: generate
go build -o ${BIN} .
generate:
protoc -I${PROTO_DIR} --go_opt=module=${PACKAGE} --go_out=. ${PROTO_DIR}/*.proto
bump: generate
go get -u ./...
clean:
rm ${PROTO_DIR}/*.pb.go
rm ${BIN}