forked from csi-addons/spec
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
76 lines (60 loc) · 2.91 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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# Copyright 2021 The csi-addons Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
SHELL:=/bin/bash
PROTOC_VERSION := 3.14.0
PROTOC_GEN_GO_VERSION := 1.25.0
PROTOC_GEN_GO_GRPC_VERSION := 1.1.0
PROTOC_FOUND := $(shell ./bin/protoc --version 2> /dev/null)
PROTOC_GEN_GO_FOUND := $(shell ./bin/protoc-gen-go --version 2> /dev/null)
PROTOC_GEN_GO_GRPC_FOUND := $(shell ./bin/protoc-gen-go-grpc --version 2> /dev/null)
ifeq ("${PROTOC_FOUND}","libprotoc ${PROTOC_VERSION}")
HAVE_PROTOC = "yes"
endif
ifeq ("${PROTOC_GEN_GO_FOUND}","protoc-gen-go v${PROTOC_GEN_GO_VERSION}")
HAVE_PROTOC_GEN_GO = "yes"
endif
ifeq ("${PROTOC_GEN_GO_GRPC_FOUND}","protoc-gen-go-grpc ${PROTOC_GEN_GO_GRPC_VERSION}")
HAVE_PROTOC_GEN_GO_GRPC = "yes"
endif
all: install-deps build
build: install-deps
# generate libs
./bin/protoc --go_out=lib/go/replication --go_opt=paths=source_relative --plugin=./bin/protoc-gen-go replication.proto
./bin/protoc --go-grpc_out=lib/go/replication --go-grpc_opt=paths=source_relative --plugin=./bin/protoc-gen-go-grpc replication.proto
install-deps:
mkdir -p bin dist google/protobuf
ifndef HAVE_PROTOC
# download protoc
wget -P dist/ --backups=1 \
https://github.com/protocolbuffers/protobuf/releases/download/v${PROTOC_VERSION}/protoc-${PROTOC_VERSION}-linux-x86_64.zip
unzip -jod bin dist/protoc-${PROTOC_VERSION}-linux-x86_64.zip bin/protoc
# extract include/google/protobuf/descriptor.proto
unzip -jod google/protobuf dist/protoc-${PROTOC_VERSION}-linux-x86_64.zip include/google/protobuf/descriptor.proto
endif
ifndef HAVE_PROTOC_GEN_GO
# download protoc-gen-go
wget -P dist/ --backups=1 \
https://github.com/protocolbuffers/protobuf-go/releases/download/v${PROTOC_GEN_GO_VERSION}/protoc-gen-go.v${PROTOC_GEN_GO_VERSION}.linux.386.tar.gz
tar -C bin -zxvf dist/protoc-gen-go.v${PROTOC_GEN_GO_VERSION}.linux.386.tar.gz protoc-gen-go
endif
ifndef HAVE_PROTOC_GEN_GO_GRPC
# download protoc-gen-go-grpc
wget -P dist/ --backups=1 \
https://github.com/grpc/grpc-go/releases/download/cmd%2Fprotoc-gen-go-grpc%2Fv${PROTOC_GEN_GO_GRPC_VERSION}/protoc-gen-go-grpc.v${PROTOC_GEN_GO_GRPC_VERSION}.linux.386.tar.gz
tar -C bin -zxvf dist/protoc-gen-go-grpc.v${PROTOC_GEN_GO_GRPC_VERSION}.linux.386.tar.gz ./protoc-gen-go-grpc
endif
check-changes:
output=`git status -z *.go | tr '\0' '\n'`; if test -z "$$output"; then echo "all good"; else echo "files got changed" exit 1; fi
clean-deps:
rm -rf bin dist google