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