fx build fix
This commit is contained in:
@@ -38,7 +38,8 @@ steps:
|
|||||||
depends_on: [ version ]
|
depends_on: [ version ]
|
||||||
commands:
|
commands:
|
||||||
- set -eu
|
- set -eu
|
||||||
- apk add --no-cache bash git build-base protobuf protobuf-dev protoc
|
# protoc + headers; protobuf runtime pkg is not needed for codegen
|
||||||
|
- apk add --no-cache bash git build-base protoc protobuf-dev
|
||||||
- go install google.golang.org/protobuf/cmd/protoc-gen-go@latest
|
- go install google.golang.org/protobuf/cmd/protoc-gen-go@latest
|
||||||
- go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest
|
- go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest
|
||||||
- export PATH="$(go env GOPATH)/bin:$PATH"
|
- export PATH="$(go env GOPATH)/bin:$PATH"
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
|
||||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||||
@@ -7,44 +6,53 @@ REPO_ROOT="$(cd "${SCRIPT_DIR}/../../.." && pwd)"
|
|||||||
API_DIR="${REPO_ROOT}/api"
|
API_DIR="${REPO_ROOT}/api"
|
||||||
PROTO_DIR="./proto"
|
PROTO_DIR="./proto"
|
||||||
PROTOC_BIN="${PROTOC:-protoc}"
|
PROTOC_BIN="${PROTOC:-protoc}"
|
||||||
PROTOC_INCLUDE="$("${PROTOC_BIN}" --print_include_path 2>/dev/null)"
|
|
||||||
|
|
||||||
|
# Ensure required tools exist
|
||||||
if ! command -v "${PROTOC_BIN}" >/dev/null 2>&1; then
|
if ! command -v "${PROTOC_BIN}" >/dev/null 2>&1; then
|
||||||
echo "[proto] protoc binary not found" >&2
|
echo "[proto] protoc binary not found" >&2; exit 1
|
||||||
exit 1
|
|
||||||
fi
|
fi
|
||||||
if ! command -v protoc-gen-go >/dev/null 2>&1; then
|
if ! command -v protoc-gen-go >/dev/null 2>&1; then
|
||||||
echo "[proto] protoc-gen-go is not installed" >&2
|
echo "[proto] protoc-gen-go is not installed" >&2; exit 1
|
||||||
exit 1
|
|
||||||
fi
|
fi
|
||||||
if ! command -v protoc-gen-go-grpc >/dev/null 2>&1; then
|
if ! command -v protoc-gen-go-grpc >/dev/null 2>&1; then
|
||||||
echo "[proto] protoc-gen-go-grpc is not installed" >&2
|
echo "[proto] protoc-gen-go-grpc is not installed" >&2; exit 1
|
||||||
exit 1
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
info() {
|
info() { printf '[proto] %s\n' "$1"; }
|
||||||
printf '[proto] %s\n' "$1"
|
|
||||||
}
|
# Try to determine the include path for well-known types (WKT) without hard failing
|
||||||
|
PROTOC_INCLUDE=""
|
||||||
|
# Prefer known locations on Alpine/Debian-like images
|
||||||
|
for cand in /usr/include /usr/local/include; do
|
||||||
|
if [ -f "$cand/google/protobuf/descriptor.proto" ]; then
|
||||||
|
PROTOC_INCLUDE="$cand"
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
# Build an include-array only when non-empty
|
||||||
|
PROTOC_I=()
|
||||||
|
if [ -n "${PROTOC_INCLUDE}" ]; then
|
||||||
|
PROTOC_I+=("-I=${PROTOC_INCLUDE}")
|
||||||
|
fi
|
||||||
|
# Always include our proto tree
|
||||||
|
PROTOC_I+=("-I=${PROTO_DIR}")
|
||||||
|
|
||||||
generate_go() {
|
generate_go() {
|
||||||
local out_dir="$1"
|
local out_dir="$1"; shift
|
||||||
shift
|
|
||||||
mkdir -p "${out_dir}"
|
mkdir -p "${out_dir}"
|
||||||
"${PROTOC_BIN}" \
|
"${PROTOC_BIN}" \
|
||||||
-I="${PROTOC_INCLUDE}" \
|
"${PROTOC_I[@]}" \
|
||||||
-I="${PROTO_DIR}" \
|
|
||||||
--go_out="${out_dir}" \
|
--go_out="${out_dir}" \
|
||||||
--go_opt=paths=source_relative \
|
--go_opt=paths=source_relative \
|
||||||
"$@"
|
"$@"
|
||||||
}
|
}
|
||||||
|
|
||||||
generate_go_with_grpc() {
|
generate_go_with_grpc() {
|
||||||
local out_dir="$1"
|
local out_dir="$1"; shift
|
||||||
shift
|
|
||||||
mkdir -p "${out_dir}"
|
mkdir -p "${out_dir}"
|
||||||
"${PROTOC_BIN}" \
|
"${PROTOC_BIN}" \
|
||||||
-I="${PROTOC_INCLUDE}" \
|
"${PROTOC_I[@]}" \
|
||||||
-I="${PROTO_DIR}" \
|
|
||||||
--go_out="${out_dir}" \
|
--go_out="${out_dir}" \
|
||||||
--go_opt=paths=source_relative \
|
--go_opt=paths=source_relative \
|
||||||
--go-grpc_out="${out_dir}" \
|
--go-grpc_out="${out_dir}" \
|
||||||
@@ -61,7 +69,7 @@ clean_pb_files() {
|
|||||||
|
|
||||||
cd "${API_DIR}"
|
cd "${API_DIR}"
|
||||||
|
|
||||||
# Messaging / notification protos (top-level files).
|
# Messaging (top-level .proto files in ./proto)
|
||||||
mapfile -t messaging_protos < <(find "${PROTO_DIR}" -maxdepth 1 -type f -name '*.proto' | sort)
|
mapfile -t messaging_protos < <(find "${PROTO_DIR}" -maxdepth 1 -type f -name '*.proto' | sort)
|
||||||
if [ "${#messaging_protos[@]}" -gt 0 ]; then
|
if [ "${#messaging_protos[@]}" -gt 0 ]; then
|
||||||
info "Compiling messaging protos"
|
info "Compiling messaging protos"
|
||||||
@@ -69,7 +77,7 @@ if [ "${#messaging_protos[@]}" -gt 0 ]; then
|
|||||||
generate_go "./pkg/messaging/internal/generated" "${messaging_protos[@]}"
|
generate_go "./pkg/messaging/internal/generated" "${messaging_protos[@]}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Common shared protos
|
# Common shared
|
||||||
mapfile -t common_protos < <(find "${PROTO_DIR}/common" -type f -name '*.proto' | sort)
|
mapfile -t common_protos < <(find "${PROTO_DIR}/common" -type f -name '*.proto' | sort)
|
||||||
if [ "${#common_protos[@]}" -gt 0 ]; then
|
if [ "${#common_protos[@]}" -gt 0 ]; then
|
||||||
info "Compiling common shared protos"
|
info "Compiling common shared protos"
|
||||||
@@ -77,35 +85,35 @@ if [ "${#common_protos[@]}" -gt 0 ]; then
|
|||||||
generate_go "./pkg/proto" "${common_protos[@]}"
|
generate_go "./pkg/proto" "${common_protos[@]}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Ledger shared protos
|
# Ledger
|
||||||
if [ -f "${PROTO_DIR}/ledger/v1/ledger.proto" ]; then
|
if [ -f "${PROTO_DIR}/ledger/v1/ledger.proto" ]; then
|
||||||
info "Compiling ledger protos"
|
info "Compiling ledger protos"
|
||||||
clean_pb_files "./pkg/proto/ledger"
|
clean_pb_files "./pkg/proto/ledger"
|
||||||
generate_go_with_grpc "./pkg/proto/ledger/v1" "${PROTO_DIR}/ledger/v1/ledger.proto"
|
generate_go_with_grpc "./pkg/proto/ledger/v1" "${PROTO_DIR}/ledger/v1/ledger.proto"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Oracle shared protos
|
# Oracle
|
||||||
if [ -f "${PROTO_DIR}/oracle/v1/oracle.proto" ]; then
|
if [ -f "${PROTO_DIR}/oracle/v1/oracle.proto" ]; then
|
||||||
info "Compiling oracle protos"
|
info "Compiling oracle protos"
|
||||||
clean_pb_files "./pkg/proto/oracle"
|
clean_pb_files "./pkg/proto/oracle"
|
||||||
generate_go_with_grpc "./pkg/proto/oracle/v1" "${PROTO_DIR}/oracle/v1/oracle.proto"
|
generate_go_with_grpc "./pkg/proto/oracle/v1" "${PROTO_DIR}/oracle/v1/oracle.proto"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Chain gateway shared protos
|
# Chain gateway
|
||||||
if [ -f "${PROTO_DIR}/chain/gateway/v1/gateway.proto" ]; then
|
if [ -f "${PROTO_DIR}/chain/gateway/v1/gateway.proto" ]; then
|
||||||
info "Compiling chain gateway protos"
|
info "Compiling chain gateway protos"
|
||||||
clean_pb_files "./pkg/proto/chain/gateway"
|
clean_pb_files "./pkg/proto/chain/gateway"
|
||||||
generate_go_with_grpc "./pkg/proto/chain/gateway/v1" "${PROTO_DIR}/chain/gateway/v1/gateway.proto"
|
generate_go_with_grpc "./pkg/proto/chain/gateway/v1" "${PROTO_DIR}/chain/gateway/v1/gateway.proto"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Payments orchestrator shared protos
|
# Payments orchestrator
|
||||||
if [ -f "${PROTO_DIR}/payments/orchestrator/v1/orchestrator.proto" ]; then
|
if [ -f "${PROTO_DIR}/payments/orchestrator/v1/orchestrator.proto" ]; then
|
||||||
info "Compiling payments orchestrator protos"
|
info "Compiling payments orchestrator protos"
|
||||||
clean_pb_files "./pkg/proto/payments/orchestrator"
|
clean_pb_files "./pkg/proto/payments/orchestrator"
|
||||||
generate_go_with_grpc "./pkg/proto/payments/orchestrator/v1" "${PROTO_DIR}/payments/orchestrator/v1/orchestrator.proto"
|
generate_go_with_grpc "./pkg/proto/payments/orchestrator/v1" "${PROTO_DIR}/payments/orchestrator/v1/orchestrator.proto"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Billing fees shared protos
|
# Billing fees
|
||||||
if [ -f "${PROTO_DIR}/billing/fees/v1/fees.proto" ]; then
|
if [ -f "${PROTO_DIR}/billing/fees/v1/fees.proto" ]; then
|
||||||
info "Compiling billing fees protos"
|
info "Compiling billing fees protos"
|
||||||
clean_pb_files "./pkg/proto/billing/fees"
|
clean_pb_files "./pkg/proto/billing/fees"
|
||||||
|
|||||||
Reference in New Issue
Block a user