@@ -36,22 +36,24 @@ else ifeq (arm64,$(PROTOC_ARCH))
36
36
PROTOC_ARCH := aarch_64
37
37
endif
38
38
39
- PROTOC := ./protoc
40
39
PROTOC_ZIP := protoc-$(PROTOC_VER ) -$(PROTOC_OS ) -$(PROTOC_ARCH ) .zip
41
40
PROTOC_URL := https://github.com/protocolbuffers/protobuf/releases/download/v$(PROTOC_VER ) /$(PROTOC_ZIP )
42
41
PROTOC_TMP_DIR := .protoc
43
- PROTOC_TMP_BIN := $(PROTOC_TMP_DIR ) /bin/protoc
42
+ PROTOC := $(PROTOC_TMP_DIR ) /bin/protoc
43
+
44
+ $(GOPATH ) /bin/protoc-gen-go : ../../go.mod
45
+ go install google.golang.org/protobuf/cmd/protoc-gen-go
46
+ $(GOPATH ) /bin/protoc-gen-go-grpc :
47
+ go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@v1.3.0
44
48
45
49
$(PROTOC ) :
46
- -go install google.golang.org/protobuf/cmd/protoc-gen-go@v1.32.0 && \
47
- go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@v1.3.0 && \
48
- mkdir -p " $( PROTOC_TMP_DIR) " && \
50
+ -mkdir -p " $( PROTOC_TMP_DIR) " && \
49
51
curl -L $(PROTOC_URL ) -o " $( PROTOC_TMP_DIR) /$( PROTOC_ZIP) " && \
50
52
unzip " $( PROTOC_TMP_DIR) /$( PROTOC_ZIP) " -d " $( PROTOC_TMP_DIR) " && \
51
- chmod 0755 " $( PROTOC_TMP_BIN) " && \
52
- cp -f " $( PROTOC_TMP_BIN) " " $@ "
53
+ chmod 0755 " $@ "
53
54
stat " $@ " > /dev/null 2>&1
54
55
56
+ PROTOC_ALL := $(GOPATH ) /bin/protoc-gen-go $(GOPATH ) /bin/protoc-gen-go-grpc $(PROTOC )
55
57
56
58
# #######################################################################
57
59
# # PATH ##
@@ -66,49 +68,24 @@ export PATH := $(GOPATH)/bin:$(PATH)
66
68
# # BUILD ##
67
69
# #######################################################################
68
70
CSI_PROTO := ../../csi.proto
69
- CSI_PKG_ROOT := github.com/container-storage-interface/spec
70
- CSI_PKG_SUB := $(shell cat $(CSI_PROTO ) | sed -nE -e 's/^package.([^;]* ) .v[0-9]+;$$/\1/p'|tr '.' '/')
71
- CSI_BUILD := $(CSI_PKG_SUB ) /.build
71
+ CSI_PKG_SUB := csi
72
72
CSI_GO := $(CSI_PKG_SUB ) /csi.pb.go
73
73
CSI_GRPC := $(CSI_PKG_SUB ) /csi_grpc.pb.go
74
- CSI_GRPC_TMP := $(CSI_BUILD ) /$(CSI_PKG_ROOT ) /lib/go/$(CSI_PKG_SUB ) /csi_grpc.pb.go
75
- CSI_GO_TMP := $(CSI_BUILD ) /$(CSI_PKG_ROOT ) /lib/go/$(CSI_PKG_SUB ) /csi.pb.go
76
74
77
- # This recipe generates the go language bindings to a temp area.
78
- $(CSI_GO_TMP ) $(CSI_GRPC_TMP ) : INCLUDE := -I../.. -I$(PROTOC_TMP_DIR ) /include
79
- $(CSI_GO_TMP ) $(CSI_GRPC_TMP ) : $(CSI_PROTO ) | $(PROTOC )
75
+ # This recipe generates the go language bindings
76
+ $(CSI_GO ) $(CSI_GRPC ) : $(CSI_PROTO ) $(PROTOC_ALL )
80
77
@mkdir -p " $( @D) "
81
- $(PROTOC ) $(INCLUDE ) --go-grpc_out=$(CSI_BUILD ) --go_out=$(CSI_BUILD ) \
82
- --go_opt=Mgoogle/protobuf/descriptor.proto=google.golang.org/protobuf/types/descriptorpb \
83
- --go_opt=Mgoogle/protobuf/wrappers.proto=google.golang.org/protobuf/types/known/wrapperspb \
78
+ $(PROTOC ) -I../.. --go-grpc_out=$(CSI_PKG_SUB ) --go_out=$(CSI_PKG_SUB ) \
79
+ --go_opt=paths=source_relative --go-grpc_opt=paths=source_relative \
84
80
" $( < F) "
85
81
86
- # The temp language bindings are compared to the ones that are
87
- # versioned. If they are different then it means the language
88
- # bindings were not updated prior to being committed.
89
- $(CSI_GO ) : $(CSI_GO_TMP )
90
- ifeq (true,$(GITHUB_ACTIONS ) )
91
- diff "$@" "$?"
92
- else
93
- @mkdir -p "$(@D)"
94
- diff "$@" "$?" > /dev/null 2>&1 || cp -f "$?" "$@"
95
- endif
96
- $(CSI_GRPC ) : $(CSI_GRPC_TMP )
97
- ifeq (true,$(GITHUB_ACTIONS ) )
98
- diff "$@" "$?"
99
- else
100
- @mkdir -p "$(@D)"
101
- diff "$@" "$?" > /dev/null 2>&1 || cp -f "$?" "$@"
102
- endif
103
-
104
-
105
82
build : $(CSI_GO ) $(CSI_GRPC )
106
83
107
84
clean :
108
85
go clean -i ./...
109
- rm -rf " $( CSI_GO ) " " $( CSI_GRPC ) " " $( CSI_BUILD ) "
86
+ rm -rf " $( CSI_PKG_SUB ) "
110
87
111
88
clobber : clean
112
- rm -fr " $( PROTOC ) " " $( CSI_PKG_SUB ) "
89
+ rm -fr " $( PROTOC_TMP_DIR ) "
113
90
114
91
.PHONY : clean clobber
0 commit comments