daily update
This commit is contained in:
45
audofeed-device-backend/scripts/gen_rpc.sh
Executable file
45
audofeed-device-backend/scripts/gen_rpc.sh
Executable file
@@ -0,0 +1,45 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||
PROTO_DIR="${PROTO_DIR:-${ROOT_DIR}/proto}"
|
||||
OUT_DIR="${OUT_DIR:-${ROOT_DIR}/rpc}"
|
||||
PROTOC_BIN="${PROTOC_BIN:-protoc}"
|
||||
|
||||
if ! command -v "${PROTOC_BIN}" >/dev/null 2>&1; then
|
||||
echo "protoc not found (set PROTOC_BIN or install protobuf)." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ -n "${GRPC_CPP_PLUGIN_PATH:-}" ]]; then
|
||||
GRPC_PLUGIN="${GRPC_CPP_PLUGIN_PATH}"
|
||||
else
|
||||
GRPC_PLUGIN="$(command -v grpc_cpp_plugin || true)"
|
||||
fi
|
||||
|
||||
if [[ -z "${GRPC_PLUGIN}" ]]; then
|
||||
echo "grpc_cpp_plugin not found (set GRPC_CPP_PLUGIN_PATH or install gRPC)." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ ! -d "${PROTO_DIR}" ]]; then
|
||||
echo "Proto dir not found: ${PROTO_DIR}" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
mapfile -t PROTO_FILES < <(find "${PROTO_DIR}" -type f -name '*.proto' | sort)
|
||||
if [[ "${#PROTO_FILES[@]}" -eq 0 ]]; then
|
||||
echo "No .proto files found in ${PROTO_DIR}" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
mkdir -p "${OUT_DIR}"
|
||||
|
||||
"${PROTOC_BIN}" \
|
||||
--grpc_out "${OUT_DIR}" \
|
||||
--cpp_out "${OUT_DIR}" \
|
||||
-I "${PROTO_DIR}" \
|
||||
--plugin=protoc-gen-grpc="${GRPC_PLUGIN}" \
|
||||
"${PROTO_FILES[@]}"
|
||||
|
||||
echo "Generated C++ sources into ${OUT_DIR}"
|
||||
Reference in New Issue
Block a user