proto-gen.sh 699 B

123456789101112131415161718192021222324252627282930
  1. #!/bin/bash
  2. function detect_protoc() {
  3. SYS_LOC=$(which protoc)
  4. if [ -n "${SYS_LOC}" ]; then
  5. echo ${SYS_LOC}
  6. return
  7. fi
  8. if [[ "$OSTYPE" == "linux"* ]]; then
  9. echo $GOPATH/src/v2ray.com/core/.dev/protoc/linux/protoc
  10. elif [[ "$OSTYPE" == "darwin"* ]]; then
  11. echo $GOPATH/src/v2ray.com/core/.dev/protoc/linux/protoc
  12. fi
  13. }
  14. PROTOC=$(detect_protoc)
  15. # Update Golang proto compiler
  16. go get -u github.com/golang/protobuf/{proto,protoc-gen-go}
  17. pushd $GOPATH/src
  18. for DIR in $(find ./v2ray.com/core -type d -not -path "*.git*"); do
  19. TEST_FILES=($DIR/*.proto)
  20. #echo ${TEST_FILES}
  21. if [ -f ${TEST_FILES[0]} ]; then
  22. ${PROTOC} --proto_path=. --go_out=. $DIR/*.proto
  23. fi
  24. done
  25. popd