1#!/bin/bash 2# 3# This script sets up a Kokoro MacOS worker for running Protobuf tests 4 5set -eux 6 7export HOMEBREW_PREFIX=$(brew --prefix) 8 9## 10# Remove any pre-existing protobuf installation. 11brew uninstall protobuf 12 13## 14# Select Xcode version 15 16## 17# Select Xcode version 18export DEVELOPER_DIR=/Applications/Xcode_14.app/Contents/Developer 19sudo xcode-select -s "${DEVELOPER_DIR}" 20 21## 22# Select C/C++ compilers 23 24export CC=gcc 25export CXX=g++ 26 27## 28# Install Python 2 by default 29 30eval "$(pyenv init -)" 31pyenv install -v -s 2.7.18 && pyenv global 2.7.18 32 33## 34# Install Tox 35 36if [[ "${KOKORO_INSTALL_TOX:-}" == "yes" ]] ; then 37 pyenv install -v -s 3.7.13 38 pyenv global 3.7.13 39 sudo python -m pip install --upgrade pip 'tox==3.27.1' tox-pyenv 40fi 41 42## 43# Setup RVM 44if [[ "${KOKORO_INSTALL_RVM:-}" == "yes" ]] ; then 45 git config --global --add safe.directory $HOMEBREW_PREFIX/Library/Taps/homebrew/homebrew-cask 46 git config --global --add safe.directory $HOMEBREW_PREFIX/Library/Taps/homebrew/homebrew-core 47 git config --global --add safe.directory $HOMEBREW_PREFIX/Library/Taps/homebrew/homebrew-services 48 sudo chown -R $(whoami) $HOME/.rvm/ 49fi 50