我有几个嵌套目录,每个目录都包含原型文件,许多原型文件都依赖于位于根目录内某处的其他原型。我正在使用这个脚本来尝试编译它们,并从包含protos的文件夹和我想要编译的proto类的文件夹的目录中执行它。我现在遇到的一个问题是我收到protoc: command not found
错误。
set -e
BASEDIR="$(greadlink -f $(dirname $0))"
PROTO_DIR="$BASEDIR/new-protos-aug/"
SWIFTPROTO_DIR="$BASEDIR/new-swift-protos-aug/"
echo "Converting files from $PROTO_DIR to $SWIFTPROTO_DIR"
FILES=$(find new-protos-aug -type f -name "*.proto")
for proto in $FILES; do
PATH=${proto///[^ ]*\.proto/};
PROTO_DIR="$BASEDIR/$PATH/"
protoc -I=$PROTO_DIR --swift_out=$SWIFTPROTO_DIR $proto;
done
关于如何最好地做到这一点的任何想法?
答案 0 :(得分:0)
忘了发布我是如何解决这个问题的。这样做了(基本上只是用-I列出每个可能的子目录)
#!/bin/bash
set -e
BASEDIR="$(greadlink -f $(dirname $0))"
PROTO_DIR="$BASEDIR/new-protos-aug/"
SWIFTPROTO_DIR="$BASEDIR/new-swift-protos-aug/"
echo "Converting files from $PROTO_DIR to $SWIFTPROTO_DIR"
FILES=$(find new-protos-aug -type f -name "*.proto")
for proto in $FILES; do
echo $proto;
echo "Running in $PROTO_DIR"
protoc -I="new-protos-aug" -I="new-protos-aug/bgs/low/pb/client" -I="new-protos-aug/bgs/low/pb/client/client" -I="new-protos-aug/bgs/low/pb/client/global_extensions" -I="new-protos-aug/bgs/low/pb/client/client/v1" -I="new-protos-aug/bgs/low/pb/client/client/v2" -I="new-protos-aug/google/protobuf" --swift_out="$SWIFTPROTO_DIR" "$proto";
done