Created
June 5, 2025 01:11
-
-
Save lix19937/b3fae407ab58ca4fcbe5c993df46a0a9 to your computer and use it in GitHub Desktop.
proto to cc and py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -e | |
SHELL_FOLDER=$(cd $(dirname "$0") && pwd) | |
export PROTO_INTERFACE_DIR=$SHELL_FOLDER/../interface/proto | |
# protoc --help | |
# build proto | |
function build_proto() { | |
cd $PROTO_INTERFACE_DIR | |
for proto_file in ./*/*.proto; do | |
if [ -f "$proto_file" ]; then | |
protoc --python_out=. $proto_file | |
protoc --cpp_out=. $proto_file | |
if [ $? -ne 0 ]; then | |
echo "protoc command failed" | |
exit 1 | |
fi | |
fi | |
done | |
} | |
# clear .cc .h .py | |
function clear_proto_out() { | |
cd $PROTO_INTERFACE_DIR | |
for proto_file in ./*/*.py ./*/*.cc ./*/*.h; do | |
if [ -f "$proto_file" ]; then | |
rm -f "$proto_file" | |
if [ $? -ne 0 ]; then | |
echo "protoc command failed" | |
exit 1 | |
fi | |
fi | |
done | |
} | |
build_proto "$@" | |
clear_proto_out |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment