protoc.sh 528 B

123456789101112131415161718
  1. #!/bin/bash
  2. files=($(find $1 -type f -name "*.proto"))
  3. paths=()
  4. filenames=()
  5. for file in ${files[@]}; do
  6. path=$(dirname $file)
  7. filename=$(basename $file)
  8. # paths+=("$path")
  9. # filenames+=("$filename#*.")
  10. if [ "${filename#*.}" = "grpc.proto" ]; then
  11. # 打印文件名
  12. protoc -I="$path" $filename --cpp_out="$path" --grpc_out="$path" --plugin=protoc-gen-grpc=`which grpc_cpp_plugin`
  13. elif [ "${filename#*.}" = "proto" ]; then
  14. protoc -I="$path" $filename --cpp_out="$path"
  15. fi
  16. done