diff --git a/Makefile b/Makefile index ff9ad4b..0d74a97 100644 --- a/Makefile +++ b/Makefile @@ -28,11 +28,26 @@ mod-vendor: clean: rm -rf dist/ vendor/ build/ +./build/bin/protoc-gen-go: + ./hack/install/install-codegen-go-tools.sh + +./build/bin/protoc-gen-go-grpc: + ./hack/install/install-codegen-go-tools.sh + +./build/bin/protoc: + ./hack/install/install-protoc.sh + +.PHONY: install-protoc-go +install-protoc-go: ./build/bin/protoc-gen-go ./build/bin/protoc-gen-go-grpc + +.PHONY: install-protoc +install-protoc: ./build/bin/protoc + .PHONY: codegen codegen: protogen .PHONY: protogen -protogen: mod-vendor +protogen: mod-vendor install-protoc-go install-protoc ./hack/generate-proto.sh .PHONY: lint diff --git a/hack/generate-proto.sh b/hack/generate-proto.sh index ad36ff1..6cfdc21 100755 --- a/hack/generate-proto.sh +++ b/hack/generate-proto.sh @@ -3,6 +3,7 @@ set -eo pipefail PROJECT_ROOT=$(cd "$(dirname "${BASH_SOURCE}")"/..; pwd) +PATH=${PROJECT_ROOT}/build/bin:${PATH} GENERATE_PATHS=" ${PROJECT_ROOT}/principal/apis/auth;authapi @@ -24,7 +25,7 @@ for p in ${GENERATE_PATHS}; do protoc -I=${src_path} \ -I=${PROJECT_ROOT}/vendor \ -I=${PROJECT_ROOT}/proto \ - -I=${PROJECT_ROOT}/dist/protoc-include \ + -I=${PROJECT_ROOT}/build/bin/protoc-include \ --go_out=${PROJECT_ROOT}/pkg/api/grpc/${api_name} \ --go_opt=paths=source_relative \ --go-grpc_out=${PROJECT_ROOT}/pkg/api/grpc/${api_name} \ diff --git a/hack/install/install-codegen-go-tools.sh b/hack/install/install-codegen-go-tools.sh new file mode 100755 index 0000000..46426ec --- /dev/null +++ b/hack/install/install-codegen-go-tools.sh @@ -0,0 +1,9 @@ +#!/bin/bash + +PROJECT_ROOT=$(cd $(dirname ${BASH_SOURCE})/../..; pwd) +DIST_PATH="${PROJECT_ROOT}/build/bin" +mkdir -p "${DIST_PATH}" +export GOBIN="${DIST_PATH}" + +go install google.golang.org/protobuf/cmd/protoc-gen-go@v1.28 +go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@v1.2 diff --git a/hack/install/install-protoc.sh b/hack/install/install-protoc.sh index 5a707a5..9388152 100755 --- a/hack/install/install-protoc.sh +++ b/hack/install/install-protoc.sh @@ -2,10 +2,11 @@ set -eux -o pipefail PROJECT_ROOT=$(cd $(dirname ${BASH_SOURCE})/../..; pwd) -DIST_PATH="${PROJECT_ROOT}/dist" +DIST_PATH="${PROJECT_ROOT}/build/bin" +mkdir -p "${DIST_PATH}" PATH="${DIST_PATH}:${PATH}" -protoc_version="24.3" +protoc_version="25.3" OS=$(go env GOOS) ARCHITECTURE=$(go env GOARCH) DOWNLOADS=$(mktemp -d /tmp/downloads.XXXXXXXXX)