prepare_build_macos_rc 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. #!/bin/bash
  2. #
  3. # This script sets up a Kokoro MacOS worker for running Protobuf tests
  4. set -eux
  5. ##
  6. # Select Xcode version
  7. # Remember to update the Xcode version when Xcode_11.3.app is not available.
  8. # If xcode is not available, it will probably encounter the failure for
  9. # "autom4te: need GNU m4 1.4 or later: /usr/bin/m4"
  10. # go/kokoro/userdocs/macos/selecting_xcode.md for more information.
  11. export DEVELOPER_DIR=/Applications/Xcode_11.3.app/Contents/Developer
  12. ##
  13. # Select C/C++ compilers
  14. export CC=gcc
  15. export CXX=g++
  16. ##
  17. # Brew: update, then upgrade the installed tools to current version and install
  18. # some needed ones not in the Kokoro base image. This ensure current versions
  19. # of CMake, autotools, etc.
  20. # But first...
  21. #
  22. # The transitive deps of the installed tools need protobuf, but Kokoro manually
  23. # installed it outside of brew so it needs to be removed so brew can install the
  24. # tools (and a newer version of protobuf). g/kokoro-users/7FRvQMUdN40 about why
  25. # it is a manual install vs. a brew install in the first place.
  26. sudo rm -rf \
  27. /usr/local/include/google/protobuf \
  28. /usr/local/bin/protoc
  29. # Likewise, updating python can have issues because of some existing binaries.
  30. sudo rm -rf \
  31. /usr/local/bin/2to3* \
  32. /usr/local/bin/idle3* \
  33. /usr/local/bin/pip3 \
  34. /usr/local/bin/pydoc3* \
  35. /usr/local/bin/python3* \
  36. /usr/local/bin/pyvenv*
  37. git -C /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core fetch --unshallow
  38. git -C /usr/local/Homebrew/Library/Taps/homebrew/homebrew-cask fetch --unshallow
  39. brew update
  40. brew upgrade
  41. ##
  42. # Install Ruby
  43. if [[ "${KOKORO_INSTALL_RUBY:-}" == "yes" ]] ; then
  44. brew install ruby
  45. fi
  46. ##
  47. # Install Cocoapods
  48. if [[ "${KOKORO_INSTALL_COCOAPODS:-}" == "yes" ]] ; then
  49. # The existing cocoapods was installed via gem, but that doesn't work well
  50. # with the overlap in deps with things managed by brew (errors around ruby
  51. # versions, etc.); so remove it and install in via brew instead.
  52. gem uninstall -a "$(gem list | grep cocoapods | cut -d ' ' -f 1)"
  53. brew install cocoapods
  54. fi
  55. ##
  56. # Install Tox
  57. if [[ "${KOKORO_INSTALL_TOX:-}" == "yes" ]] ; then
  58. sudo python3 -m pip install --upgrade pip tox
  59. fi
  60. ##
  61. # Install RVM
  62. if [[ "${KOKORO_INSTALL_RVM:-}" == "yes" ]] ; then
  63. curl -sSL https://rvm.io/mpapis.asc | gpg --import -
  64. curl -sSL https://rvm.io/pkuczynski.asc | gpg --import -
  65. curl -sSL https://get.rvm.io | bash -s master --ruby
  66. fi