build_tools.sh 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. #!/bin/bash
  2. if [ $# -ne 1 ]; then
  3. cat <<EOF
  4. Usage: $0 <VERSION_NUMBER>
  5. Example:
  6. $ $0 3.0.0
  7. This script will download pre-built protoc binaries from maven repository and
  8. create the Google.Protobuf.Tools package. Well-known type .proto files will also
  9. be included.
  10. EOF
  11. exit 1
  12. fi
  13. VERSION_NUMBER=$1
  14. # <directory name> <binary file name> pairs.
  15. declare -a FILE_NAMES=( \
  16. windows_x86 windows-x86_32.exe \
  17. windows_x64 windows-x86_64.exe \
  18. macosx_x64 osx-x86_64.exe \
  19. linux_x86 linux-x86_32.exe \
  20. linux_x64 linux-x86_64.exe \
  21. )
  22. set -e
  23. mkdir -p protoc
  24. # Create a zip file for each binary.
  25. for((i=0;i<${#FILE_NAMES[@]};i+=2));do
  26. DIR_NAME=${FILE_NAMES[$i]}
  27. mkdir -p protoc/$DIR_NAME
  28. if [ ${DIR_NAME:0:3} = "win" ]; then
  29. TARGET_BINARY="protoc.exe"
  30. else
  31. TARGET_BINARY="protoc"
  32. fi
  33. BINARY_NAME=${FILE_NAMES[$(($i+1))]}
  34. BINARY_URL=http://repo1.maven.org/maven2/com/google/protobuf/protoc/${VERSION_NUMBER}/protoc-${VERSION_NUMBER}-${BINARY_NAME}
  35. if ! wget ${BINARY_URL} -O protoc/$DIR_NAME/$TARGET_BINARY &> /dev/null; then
  36. echo "[ERROR] Failed to download ${BINARY_URL}" >&2
  37. echo "[ERROR] Skipped $protoc-${VERSION_NAME}-${DIR_NAME}" >&2
  38. continue
  39. fi
  40. done
  41. nuget pack Google.Protobuf.Tools.nuspec