build_tools.sh 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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_x86 osx-x86_32.exe \
  19. macosx_x64 osx-x86_64.exe \
  20. linux_x86 linux-x86_32.exe \
  21. linux_x64 linux-x86_64.exe \
  22. )
  23. set -e
  24. mkdir -p protoc
  25. # Create a zip file for each binary.
  26. for((i=0;i<${#FILE_NAMES[@]};i+=2));do
  27. DIR_NAME=${FILE_NAMES[$i]}
  28. mkdir -p protoc/$DIR_NAME
  29. if [ ${DIR_NAME:0:3} = "win" ]; then
  30. TARGET_BINARY="protoc.exe"
  31. else
  32. TARGET_BINARY="protoc"
  33. fi
  34. BINARY_NAME=${FILE_NAMES[$(($i+1))]}
  35. BINARY_URL=http://repo1.maven.org/maven2/com/google/protobuf/protoc/${VERSION_NUMBER}/protoc-${VERSION_NUMBER}-${BINARY_NAME}
  36. if ! wget ${BINARY_URL} -O protoc/$DIR_NAME/$TARGET_BINARY &> /dev/null; then
  37. echo "[ERROR] Failed to download ${BINARY_URL}" >&2
  38. echo "[ERROR] Skipped $protoc-${VERSION_NAME}-${DIR_NAME}" >&2
  39. continue
  40. fi
  41. done
  42. nuget pack Google.Protobuf.Tools.nuspec