Skip to content

Commit f0dd1c2

Browse files
authored
Merge pull request #438 from gnufied/fix-grpc-build-makefile
Fix grpc build by cloning dependencies via Makefile
2 parents 4c5274a + 3ffa41b commit f0dd1c2

File tree

1 file changed

+42
-2
lines changed

1 file changed

+42
-2
lines changed

lib/go/Makefile

Lines changed: 42 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,46 @@ $(PROTOC_GEN_GO):
6969
go build -o "$@" $(PROTOC_GEN_GO_PKG)
7070

7171

72+
########################################################################
73+
## GEN-PROTO-GO ##
74+
########################################################################
75+
76+
# This is the recipe for getting and installing the gen-proto pkg
77+
# This is a dependency of grpc-go and must be installed before
78+
# installing grpc-go.
79+
GENPROTO_GO_SRC := github.com/googleapis/go-genproto
80+
GENPROTO_GO_PKG := google.golang.org/genproto
81+
GENPROTO_BUILD_GO := genproto-build-go
82+
$(GENPROTO_BUILD_GO): GENPROTO_VERSION := 24fa4b261c55da65468f2abfdae2b024eef27dfb
83+
$(GENPROTO_BUILD_GO):
84+
mkdir -p $(dir $(GOPATH)/src/$(GENPROTO_GO_PKG))
85+
test -d $(GOPATH)/src/$(GENPROTO_GO_PKG)/.git || git clone https://$(GENPROTO_GO_SRC) $(GOPATH)/src/$(GENPROTO_GO_PKG)
86+
(cd $(GOPATH)/src/$(GENPROTO_GO_PKG) && \
87+
(git fetch && git checkout $(GENPROTO_VERSION)))
88+
(cd $(GOPATH)/src/$(GENPROTO_GO_PKG) && go get -v -d $$(go list -f '{{ .ImportPath }}' ./...))
89+
90+
91+
92+
########################################################################
93+
## GRPC-GO ##
94+
########################################################################
95+
96+
# This is the recipe for getting and installing the grpc go
97+
GRPC_GO_SRC := github.com/grpc/grpc-go
98+
GRPC_GO_PKG := google.golang.org/grpc
99+
GRPC_BUILD_GO := grpc-build-go
100+
$(GRPC_BUILD_GO): GRPC_VERSION := v1.26.0
101+
$(GRPC_BUILD_GO):
102+
mkdir -p $(dir $(GOPATH)/src/$(GRPC_GO_PKG))
103+
test -d $(GOPATH)/src/$(GRPC_GO_PKG)/.git || git clone https://$(GRPC_GO_SRC) $(GOPATH)/src/$(GRPC_GO_PKG)
104+
(cd $(GOPATH)/src/$(GRPC_GO_PKG) && \
105+
(test "$$(git describe --tags | head -1)" = "$(GRPC_VERSION)" || \
106+
(git fetch && git checkout tags/$(GRPC_VERSION))))
107+
(cd $(GOPATH)/src/$(GRPC_GO_PKG) && go get -v -d $$(go list -f '{{ .ImportPath }}' ./...) && \
108+
go build -o "$@" $(GRPC_GO_PKG))
109+
110+
111+
72112
########################################################################
73113
## PATH ##
74114
########################################################################
@@ -119,7 +159,7 @@ endif
119159
# 1. Go get any missing dependencies.
120160
# 2. Cache the packages.
121161
# 3. Build the archive file.
122-
$(CSI_A): $(CSI_GO)
162+
$(CSI_A): $(CSI_GO) $(GENPROTO_BUILD_GO) $(GRPC_BUILD_GO)
123163
go get -v -d ./...
124164
go install ./$(CSI_PKG_SUB)
125165
go build -o "$@" ./$(CSI_PKG_SUB)
@@ -133,4 +173,4 @@ clean:
133173
clobber: clean
134174
rm -fr "$(PROTOC)" "$(PROTOC_GEN_GO)" "$(CSI_PKG_SUB)"
135175

136-
.PHONY: clean clobber
176+
.PHONY: clean clobber $(GRPC_BUILD_GO) $(GENPROTO_BUILD_GO)

0 commit comments

Comments
 (0)