-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgenerate_proto.sh
More file actions
executable file
·40 lines (31 loc) · 934 Bytes
/
generate_proto.sh
File metadata and controls
executable file
·40 lines (31 loc) · 934 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#!/bin/bash
PROTOC=/home/olivercai/vcpkg/installed/x64-linux/tools/protobuf/protoc
GRPC_CPP_PLUGIN=/home/olivercai/vcpkg/installed/x64-linux/tools/grpc/grpc_cpp_plugin
SRC_DIR=src/proto
OUT_DIR=src/generated
if [ ! -f "$PROTOC" ]; then
echo "❌ Error: protoc not found at $PROTOC"
exit 1
fi
if [ ! -f "$GRPC_CPP_PLUGIN" ]; then
echo "❌ Error: grpc_cpp_plugin not found at $GRPC_CPP_PLUGIN"
exit 1
fi
if [ ! -d "$SRC_DIR" ]; then
echo "❌ Error: Proto source directory not found: $SRC_DIR"
exit 1
fi
# 创建输出目录(如果不存在)
mkdir -p "$OUT_DIR"
echo "🚀 Generating proto files from $SRC_DIR to $OUT_DIR ..."
$PROTOC -I"$SRC_DIR" \
--cpp_out="$OUT_DIR" \
--grpc_out="$OUT_DIR" \
--plugin=protoc-gen-grpc="$GRPC_CPP_PLUGIN" \
"$SRC_DIR/file.proto"
if [ $? -eq 0 ]; then
echo "✅ Proto generation successful!"
else
echo "❌ Proto generation failed!"
exit 2
fi