forked from awslabs/volume-modifier-for-k8s
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
38 lines (30 loc) · 1.1 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
PROTO_FILE=modify.proto
PROTO_GENERATED_FILES_PATH=pkg/rpc
VERSION="v0.4.0"
LDFLAGS="-X 'main.version=$(VERSION)'"
.PHONY: all
all: build
.PHONY: build
build:
go build -o bin/main -ldflags ${LDFLAGS} cmd/main.go
.PHONY: proto
proto:
protoc --go_out=$(PROTO_GENERATED_FILES_PATH) --go_opt=paths=source_relative --go-grpc_out=$(PROTO_GENERATED_FILES_PATH) --go-grpc_opt=paths=source_relative $(PROTO_FILE)
.PHONY: test
test:
go test ./... -race
.PHONY: clean
clean:
rm -rf bin/
.PHONY: check
check: check-proto
.PHONY: linux/$(ARCH) bin/volume-modifier-for-k8s
linux/$(ARCH): bin/volume-modifier-for-k8s
bin/volume-modifier-for-k8s: | bin
CGO_ENABLED=0 GOOS=linux GOARCH=$(ARCH) go build -mod=mod -ldflags ${LDFLAGS} -o bin/volume-modifier-for-k8s ./cmd
.PHONY: check-proto
check-proto:
$(eval TMPDIR := $(shell mktemp -d))
protoc --go_out=$(TMPDIR) --go_opt=paths=source_relative --go-grpc_out=$(TMPDIR) --go-grpc_opt=paths=source_relative $(PROTO_FILE)
diff -r $(TMPDIR) $(PROTO_GENERATED_FILES_PATH) || (printf "\nThe proto file seems to have been modified. PLease run `make proto`."; exit 1)
rm -rf $(TMPDIR)