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