Capture proto dependency installs as targets
Signed-off-by: Jonathon Anderson <janderson@ciq.com>
This commit is contained in:
29
Makefile
29
Makefile
@@ -7,7 +7,7 @@ all: config vendor wwctl wwclient man_pages wwapid wwapic wwapird etc/defaults.c
|
||||
build: lint test vet all
|
||||
|
||||
.PHONY: setup_tools
|
||||
setup_tools: $(GO_TOOLS_BIN) $(GOLANGCI_LINT)
|
||||
setup_tools: $(GO_TOOLS_BIN) $(GOLANGCI_LINT) $(PROTOC_GEN_GO) $(PROTOC_GEN_GO_GRPC)
|
||||
|
||||
$(GO_TOOLS_BIN):
|
||||
GOBIN="$(PWD)/$(TOOLS_BIN)" go install -mod=vendor $(GO_TOOLS)
|
||||
@@ -15,6 +15,19 @@ $(GO_TOOLS_BIN):
|
||||
$(GOLANGCI_LINT):
|
||||
curl -qq -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(TOOLS_BIN) $(GOLANGCI_LINT_VERSION)
|
||||
|
||||
$(PROTOC):
|
||||
cd $(PWD)/$(TOOLS_DIR) && curl -LO $(PROTOC_URL) && unzip protoc-24.0-linux-aarch_64.zip
|
||||
|
||||
$(PROTOC_GEN_GRPC_GATEWAY):
|
||||
curl -L $(PROTOC_GEN_GRPC_GATEWAY_URL) -o $(PROTOC_GEN_GRPC_GATEWAY)
|
||||
chmod +x $(PROTOC_GEN_GRPC_GATEWAY)
|
||||
|
||||
$(PROTOC_GEN_GO):
|
||||
GOBIN="$(PWD)/$(TOOLS_BIN)" go install google.golang.org/protobuf/cmd/protoc-gen-go@v1.28
|
||||
|
||||
$(PROTOC_GEN_GO_GRPC):
|
||||
GOBIN="$(PWD)/$(TOOLS_BIN)" go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@v1.2
|
||||
|
||||
.PHONY: setup
|
||||
setup: vendor $(TOOLS_DIR) setup_tools
|
||||
|
||||
@@ -162,19 +175,9 @@ reference: wwctl
|
||||
latexpdf: reference
|
||||
make -C userdocs latexpdf
|
||||
|
||||
# wwapi generate code from protobuf. Requires protoc and protoc-grpc-gen-gateway to generate code.
|
||||
# To setup latest protoc:
|
||||
# Download the protobuf-all-[VERSION].tar.gz from https://github.com/protocolbuffers/protobuf/releases
|
||||
# Extract the contents and change in the directory
|
||||
# ./configure
|
||||
# make
|
||||
# make check
|
||||
# sudo make install
|
||||
# sudo ldconfig # refresh shared library cache.
|
||||
# To setup protoc-gen-grpc-gateway, see https://github.com/grpc-ecosystem/grpc-gateway
|
||||
.PHONY: proto
|
||||
proto:
|
||||
protoc -I /usr/include -I internal/pkg/api/routes/v1 -I=. \
|
||||
proto: $(PROTOC) $(PROTOC_GEN_GRPC_GATEWAY) $(PROTOC_GEN_GO) $(PROTOC_GEN_GO_GRPC)
|
||||
PATH=$(TOOLS_BIN):$(PATH) $(PROTOC) -I /usr/include -I internal/pkg/api/routes/v1 -I=. \
|
||||
--grpc-gateway_out=. \
|
||||
--grpc-gateway_opt logtostderr=true \
|
||||
--go_out=. \
|
||||
|
||||
@@ -85,6 +85,14 @@ GO_TOOLS_BIN := $(addprefix $(TOOLS_BIN)/, $(notdir $(GO_TOOLS)))
|
||||
GO_TOOLS_VENDOR := $(addprefix vendor/, $(GO_TOOLS))
|
||||
GOLANGCI_LINT := $(TOOLS_BIN)/golangci-lint
|
||||
GOLANGCI_LINT_VERSION := v1.53.2
|
||||
PROTOC_GEN_GO := $(TOOLS_BIN)/protoc-gen-go
|
||||
PROTOC_GEN_GO_GRPC := $(TOOLS_BIN)/protoc-gen-go-grpc
|
||||
PROTOC := $(TOOLS_BIN)/protoc
|
||||
PROTOC_URL := https://github.com/protocolbuffers/protobuf/releases/download/v24.0/protoc-24.0-linux-x86_64.zip
|
||||
#PROTOC_URL := https://github.com/protocolbuffers/protobuf/releases/download/v24.0/protoc-24.0-linux-aarch_64.zip
|
||||
PROTOC_GEN_GRPC_GATEWAY := $(TOOLS_BIN)/protoc-gen-grpc-gateway
|
||||
PROTOC_GEN_GRPC_GATEWAY_URL := https://github.com/grpc-ecosystem/grpc-gateway/releases/download/v2.16.2/protoc-gen-grpc-gateway-v2.16.2-linux-x86_64
|
||||
#PROTOC_GEN_GRPC_GATEWAY_URL := https://github.com/grpc-ecosystem/grpc-gateway/releases/download/v2.16.2/protoc-gen-grpc-gateway-v2.16.2-linux-arm64
|
||||
|
||||
# helper functions
|
||||
godeps=$(shell go list -deps -f '{{if not .Standard}}{{ $$dep := . }}{{range .GoFiles}}{{$$dep.Dir}}/{{.}} {{end}}{{end}}' $(1) | sed "s%${PWD}/%%g")
|
||||
|
||||
Reference in New Issue
Block a user