-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
73 lines (60 loc) · 2.13 KB
/
Copy pathMakefile
File metadata and controls
73 lines (60 loc) · 2.13 KB
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
62
63
64
65
66
67
68
69
70
71
72
73
PROTOC_IMAGE = rvolosatovs/protoc:development
NODE_IMAGE = node:lts-alpine
# Pattern #1 example: "example : description = Description for example target"
# Pattern #2 example: "### Example separator text
help: HELP_SCRIPT = \
if (/^([a-zA-Z0-9-\.\/]+).*?: description\s*=\s*(.+)/) { \
printf "\033[34m%-40s\033[0m %s\n", $$1, $$2 \
} elsif(/^\#\#\#\s*(.+)/) { \
printf "\033[33m>> %s\033[0m\n", $$1 \
}
.PHONY: help
help:
@perl -ne '$(HELP_SCRIPT)' $(MAKEFILE_LIST)
.PHONY: setup/darwin
setup/darwin: description = Install protobuf tooling for macOS -- TODO: update correct protoc version
setup/darwin:
# Protocol compiler
brew tap yoheimuta/protolint
brew install protobuf@3.11.4 protolint
# Go plugin used by the protocol compiler
go get -u github.com/golang/protobuf/protoc-gen-go
.PHONY: setup/linux
setup/linux: description = Install protobuf tooling for linux -- TODO: update correct protoc version
setup/linux:
# Protocol compiler
PROTOC_ZIP=protoc-3.10.1-linux-x86_64.zip
curl -OL https://github.com/protocolbuffers/protobuf/releases/download/v3.10.1/$PROTOC_ZIP
sudo unzip -o $PROTOC_ZIP -d /usr/local bin/protoc
sudo unzip -o $PROTOC_ZIP -d /usr/local 'include/*'
rm -f $PROTOC_ZIP
# Go plugin used by the protocol compiler
go get -u github.com/golang/protobuf/protoc-gen-go
.PHONY: generate/go
generate/go: description = Compile protobuf schemas for Go
generate/go: clean/go
generate/go:
mkdir -p build/go/v1
docker run --platform linux/amd64 --rm -v ${PWD}:${PWD} -w ${PWD} ${PROTOC_IMAGE} \
--proto_path=fresh/protos/v1 \
--go_out=./build/go/v1 \
--go-grpc_out=./build/go/v1 \
--go-grpc_opt=paths=source_relative \
--go_opt=paths=source_relative \
fresh/protos/v1/*.proto || (exit 1)
@echo Successfully compiled protos
.PHONY: generate
generate: description = Run all generate/* targets
generate: lint generate/go
.PHONY: clean/go
clean/go: description = Remove all Go build artifacts
clean/go:
rm -rf ./build/go/*
.PHONY: clean/protoset
clean/protoset: description = Remove protoset artifacts
clean/protoset:
rm -rf ./build/protos.protoset
.PHONY: lint
lint: description = Run protolint
lint:
protolint fresh/