Skip to content

Commit ad81d20

Browse files
committed
update protoc and related
update protoc to v24.3 update protoc-gen-go to v1.31.0 added protoc-gen-go-grpc at v1.3.0 restruct the makefile to use "go install" to install tools use extended regular expressions in sed command Fixes build on arm OSX host Fixes container-storage-interface#471
1 parent 80d5310 commit ad81d20

File tree

6 files changed

+7690
-4556
lines changed

6 files changed

+7690
-4556
lines changed

csi.proto

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import "google/protobuf/descriptor.proto";
66
import "google/protobuf/timestamp.proto";
77
import "google/protobuf/wrappers.proto";
88

9-
option go_package = "csi";
9+
option go_package = "github.com/container-storage-interface/spec/csi";
1010

1111
extend google.protobuf.EnumOptions {
1212
// Indicates that this enum is OPTIONAL and part of an experimental

go.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@ go 1.18
55
require (
66
github.com/golang/protobuf v1.5.3
77
google.golang.org/grpc v1.57.0
8+
google.golang.org/protobuf v1.31.0
89
)
910

1011
require (
1112
golang.org/x/net v0.10.0 // indirect
1213
golang.org/x/sys v0.8.0 // indirect
1314
golang.org/x/text v0.9.0 // indirect
1415
google.golang.org/genproto/googleapis/rpc v0.0.0-20230803162519-f966b187b2e5 // indirect
15-
google.golang.org/protobuf v1.31.0 // indirect
1616
)

lib/go/Makefile

+27-49
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export GOPATH
2121

2222
# Only set PROTOC_VER if it has an empty value.
2323
ifeq (,$(strip $(PROTOC_VER)))
24-
PROTOC_VER := 3.9.1
24+
PROTOC_VER := 24.3
2525
endif
2626

2727
PROTOC_OS := $(shell uname -s)
@@ -32,75 +32,46 @@ endif
3232
PROTOC_ARCH := $(shell uname -m)
3333
ifeq (i386,$(PROTOC_ARCH))
3434
PROTOC_ARCH := x86_32
35+
else ifeq (arm64,$(PROTOC_ARCH))
36+
PROTOC_ARCH := aarch_64
3537
endif
3638

3739
PROTOC := ./protoc
3840
PROTOC_ZIP := protoc-$(PROTOC_VER)-$(PROTOC_OS)-$(PROTOC_ARCH).zip
39-
PROTOC_URL := https://github.com/google/protobuf/releases/download/v$(PROTOC_VER)/$(PROTOC_ZIP)
41+
PROTOC_URL := https://github.com/protocolbuffers/protobuf/releases/download/v$(PROTOC_VER)/$(PROTOC_ZIP)
4042
PROTOC_TMP_DIR := .protoc
4143
PROTOC_TMP_BIN := $(PROTOC_TMP_DIR)/bin/protoc
4244

4345
$(PROTOC):
44-
-mkdir -p "$(PROTOC_TMP_DIR)" && \
46+
-go install google.golang.org/protobuf/cmd/[email protected] && \
47+
go install google.golang.org/grpc/cmd/[email protected] && \
48+
mkdir -p "$(PROTOC_TMP_DIR)" && \
4549
curl -L $(PROTOC_URL) -o "$(PROTOC_TMP_DIR)/$(PROTOC_ZIP)" && \
4650
unzip "$(PROTOC_TMP_DIR)/$(PROTOC_ZIP)" -d "$(PROTOC_TMP_DIR)" && \
4751
chmod 0755 "$(PROTOC_TMP_BIN)" && \
4852
cp -f "$(PROTOC_TMP_BIN)" "$@"
4953
stat "$@" > /dev/null 2>&1
5054

51-
52-
########################################################################
53-
## PROTOC-GEN-GO ##
54-
########################################################################
55-
56-
# This is the recipe for getting and installing the go plug-in
57-
# for protoc
58-
PROTOC_GEN_GO_PKG := github.com/golang/protobuf/protoc-gen-go
59-
PROTOC_GEN_GO := protoc-gen-go
60-
$(PROTOC_GEN_GO): PROTOBUF_PKG := $(dir $(PROTOC_GEN_GO_PKG))
61-
$(PROTOC_GEN_GO): PROTOBUF_VERSION := v1.3.2
62-
$(PROTOC_GEN_GO):
63-
mkdir -p $(dir $(GOPATH)/src/$(PROTOBUF_PKG))
64-
test -d $(GOPATH)/src/$(PROTOBUF_PKG)/.git || git clone https://$(PROTOBUF_PKG) $(GOPATH)/src/$(PROTOBUF_PKG)
65-
(cd $(GOPATH)/src/$(PROTOBUF_PKG) && \
66-
(test "$$(git describe --tags | head -1)" = "$(PROTOBUF_VERSION)" || \
67-
(git fetch && git checkout tags/$(PROTOBUF_VERSION))))
68-
(cd $(GOPATH)/src/$(PROTOBUF_PKG) && go get -v -d $$(go list -f '{{ .ImportPath }}' ./...)) && \
69-
go build -o "$@" $(PROTOC_GEN_GO_PKG)
70-
71-
72-
########################################################################
73-
## PATH ##
74-
########################################################################
75-
76-
# Update PATH with the current directory. This enables the protoc
77-
# binary to discover the protoc-gen-go binary, built inside this
78-
# directory.
79-
export PATH := $(shell pwd):$(PATH)
80-
81-
8255
########################################################################
8356
## BUILD ##
8457
########################################################################
8558
CSI_PROTO := ../../csi.proto
8659
CSI_PKG_ROOT := github.com/container-storage-interface/spec
87-
CSI_PKG_SUB := $(shell cat $(CSI_PROTO) | sed -n -e 's/^package.\([^;]*\).v[0-9]\+;$$/\1/p'|tr '.' '/')
60+
CSI_PKG_SUB := $(shell cat $(CSI_PROTO) | sed -nE -e 's/^package.([^;]*).v[0-9]+;$$/\1/p'|tr '.' '/')
8861
CSI_BUILD := $(CSI_PKG_SUB)/.build
8962
CSI_GO := $(CSI_PKG_SUB)/csi.pb.go
90-
CSI_GO_TMP := $(CSI_BUILD)/$(CSI_PKG_ROOT)/csi.pb.go
63+
CSI_GRPC := $(CSI_PKG_SUB)/csi_grpc.pb.go
64+
CSI_GRPC_TMP := $(CSI_BUILD)/$(CSI_PKG_ROOT)/$(CSI_PKG_SUB)/csi_grpc.pb.go
65+
CSI_GO_TMP := $(CSI_BUILD)/$(CSI_PKG_ROOT)/$(CSI_PKG_SUB)/csi.pb.go
9166

9267
# This recipe generates the go language bindings to a temp area.
93-
$(CSI_GO_TMP): HERE := $(shell pwd)
94-
$(CSI_GO_TMP): PTYPES_PKG := github.com/golang/protobuf/ptypes
95-
$(CSI_GO_TMP): GO_OUT := plugins=grpc
96-
$(CSI_GO_TMP): GO_OUT := $(GO_OUT),Mgoogle/protobuf/descriptor.proto=github.com/golang/protobuf/protoc-gen-go/descriptor
97-
$(CSI_GO_TMP): GO_OUT := $(GO_OUT),Mgoogle/protobuf/wrappers.proto=$(PTYPES_PKG)/wrappers
98-
$(CSI_GO_TMP): GO_OUT := $(GO_OUT):"$(HERE)/$(CSI_BUILD)"
99-
$(CSI_GO_TMP): INCLUDE := -I$(GOPATH)/src -I$(HERE)/$(PROTOC_TMP_DIR)/include
100-
$(CSI_GO_TMP): $(CSI_PROTO) | $(PROTOC) $(PROTOC_GEN_GO)
68+
$(CSI_GO_TMP) $(CSI_GRPC_TMP): INCLUDE := -I$(GOPATH)/src -I$(PROTOC_TMP_DIR)/include
69+
$(CSI_GO_TMP) $(CSI_GRPC_TMP): $(CSI_PROTO) | $(PROTOC)
10170
@mkdir -p "$(@D)"
102-
(cd "$(GOPATH)/src" && \
103-
$(HERE)/$(PROTOC) $(INCLUDE) --go_out=$(GO_OUT) "$(CSI_PKG_ROOT)/$(<F)")
71+
$(PROTOC) $(INCLUDE) --go-grpc_out=$(CSI_BUILD) --go_out=$(CSI_BUILD) \
72+
--go_opt=Mgoogle/protobuf/descriptor.proto=github.com/golang/protobuf/protoc-gen-go/descriptor \
73+
--go_opt=Mgoogle/protobuf/wrappers.proto=github.com/golang/protobuf/ptypes/wrappers \
74+
"$(CSI_PKG_ROOT)/$(<F)"
10475

10576
# The temp language bindings are compared to the ones that are
10677
# versioned. If they are different then it means the language
@@ -112,15 +83,22 @@ else
11283
@mkdir -p "$(@D)"
11384
diff "$@" "$?" > /dev/null 2>&1 || cp -f "$?" "$@"
11485
endif
86+
$(CSI_GRPC): $(CSI_GRPC_TMP)
87+
ifeq (true,$(GITHUB_ACTIONS))
88+
diff "$@" "$?"
89+
else
90+
@mkdir -p "$(@D)"
91+
diff "$@" "$?" > /dev/null 2>&1 || cp -f "$?" "$@"
92+
endif
11593

11694

117-
build: $(CSI_GO)
95+
build: $(CSI_GO) $(CSI_GRPC)
11896

11997
clean:
12098
go clean -i ./...
121-
rm -rf "$(CSI_GO)" "$(CSI_BUILD)"
99+
rm -rf "$(CSI_GO)" "$(CSI_GRPC)" "$(CSI_BUILD)"
122100

123101
clobber: clean
124-
rm -fr "$(PROTOC)" "$(PROTOC_GEN_GO)" "$(CSI_PKG_SUB)"
102+
rm -fr "$(PROTOC)" "$(CSI_PKG_SUB)"
125103

126104
.PHONY: clean clobber

0 commit comments

Comments
 (0)