@@ -204,11 +204,15 @@ CONTROLLER_GEN ?= $(LOCALBIN)/controller-gen
204204ENVTEST ?= $(LOCALBIN ) /setup-envtest
205205ADDLICENSE ?= $(LOCALBIN ) /addlicense
206206GOLANGCI_LINT = $(LOCALBIN ) /golangci-lint
207+ PROTOC_GEN_GO ?= $(LOCALBIN ) /protoc-gen-go
208+ PROTOC_GEN_GO_GRPC ?= $(LOCALBIN ) /protoc-gen-go-grpc
207209
208210# # Tool Versions
209211KUSTOMIZE_VERSION ?= v5.8.1
210212CONTROLLER_TOOLS_VERSION ?= v0.20.1
211213ADDLICENSE_VERSION ?= v1.1.1
214+ PROTOC_GEN_GO_VERSION ?= v1.36.8
215+ PROTOC_GEN_GO_GRPC_VERSION ?= v1.5.1
212216
213217# ENVTEST_VERSION is the version of controller-runtime release branch to fetch the envtest setup script (i.e. release-0.20)
214218ENVTEST_VERSION ?= $(shell v='$(call gomodver,sigs.k8s.io/controller-runtime) '; \
@@ -260,6 +264,25 @@ addlicense: $(ADDLICENSE) ## Download addlicense locally if necessary.
260264$(ADDLICENSE ) : $(LOCALBIN )
261265 $(call go-install-tool,$(ADDLICENSE ) ,github.com/google/addlicense,$(ADDLICENSE_VERSION ) )
262266
267+ .PHONY : generate-proto
268+ generate-proto : $(PROTOC_GEN_GO ) $(PROTOC_GEN_GO_GRPC ) # # Generate Go code from proto/sonic/v1alpha1/sonic.proto.
269+ protoc \
270+ --plugin=protoc-gen-go=$(PROTOC_GEN_GO ) \
271+ --plugin=protoc-gen-go-grpc=$(PROTOC_GEN_GO_GRPC ) \
272+ --go_out=. --go_opt=module=github.com/ironcore-dev/wire \
273+ --go-grpc_out=. --go-grpc_opt=module=github.com/ironcore-dev/wire \
274+ proto/sonic/v1alpha1/sonic.proto
275+
276+ .PHONY : protoc-gen-go
277+ protoc-gen-go : $(PROTOC_GEN_GO ) # # Download protoc-gen-go locally if necessary.
278+ $(PROTOC_GEN_GO ) : $(LOCALBIN )
279+ $(call go-install-tool,$(PROTOC_GEN_GO ) ,google.golang.org/protobuf/cmd/protoc-gen-go,$(PROTOC_GEN_GO_VERSION ) )
280+
281+ .PHONY : protoc-gen-go-grpc
282+ protoc-gen-go-grpc : $(PROTOC_GEN_GO_GRPC ) # # Download protoc-gen-go-grpc locally if necessary.
283+ $(PROTOC_GEN_GO_GRPC ) : $(LOCALBIN )
284+ $(call go-install-tool,$(PROTOC_GEN_GO_GRPC ) ,google.golang.org/grpc/cmd/protoc-gen-go-grpc,$(PROTOC_GEN_GO_GRPC_VERSION ) )
285+
263286# go-install-tool will 'go install' any package with custom target and name of binary, if it doesn't exist
264287# $1 - target path with name of binary
265288# $2 - package url which can be installed
0 commit comments