91
91
ACTION=" $1 "
92
92
TARGET=" $2 "
93
93
94
- # Runs our tests on every available Xcode installation.
95
- ls /Applications/ | grep " Xcode" | while read -r xcode_path; do
96
- xcode_version=$( cat /Applications/$xcode_path /Contents/version.plist \
97
- | grep " CFBundleShortVersionString" -A1 \
98
- | grep string \
99
- | cut -d' >' -f2 \
100
- | cut -d' <' -f1)
101
- if [ -n " $MIN_XCODE_VERSION " ]; then
102
- xcode_version_as_number=" $( version_as_number $xcode_version ) "
103
-
104
- if [ " $xcode_version_as_number " -lt " $MIN_XCODE_VERSION " ]; then
105
- continue
106
- fi
107
- fi
108
-
94
+ invoke_bazel () {
95
+ xcode_version=" $1 "
109
96
extra_args=" "
110
97
if [ " $ACTION " == " build" ]; then
111
98
echo " 🏗️ $TARGET with Xcode $xcode_version ..."
@@ -117,17 +104,58 @@ ls /Applications/ | grep "Xcode" | while read -r xcode_path; do
117
104
else
118
105
extra_args=" --test_output=errors"
119
106
fi
107
+ fi
120
108
121
- if [ -n " $KOKORO_BUILD_NUMBER " ]; then
109
+ bazel clean
110
+ bazel $ACTION $TARGET --xcode_version $xcode_version $extra_args $verbosity_flags " ${POSITIONAL[@]: 2} "
111
+ }
112
+
113
+ if [ -n " $KOKORO_BUILD_NUMBER " ]; then
114
+ # Runs our tests on every available Xcode installation.
115
+ ls /Applications/ | grep " Xcode" | while read -r xcode_path; do
116
+ xcode_version=$( cat /Applications/$xcode_path /Contents/version.plist \
117
+ | grep " CFBundleShortVersionString" -A1 \
118
+ | grep string \
119
+ | cut -d' >' -f2 \
120
+ | cut -d' <' -f1)
121
+ if [ -n " $MIN_XCODE_VERSION " ]; then
122
+ xcode_version_as_number=" $( version_as_number $xcode_version ) "
123
+
124
+ if [ " $xcode_version_as_number " -lt " $MIN_XCODE_VERSION " ]; then
125
+ continue
126
+ fi
127
+ fi
128
+
129
+ if [ " $ACTION " == " test" ]; then
122
130
sudo xcode-select --switch /Applications/$xcode_path /Contents/Developer
123
131
xcodebuild -version
132
+
133
+ # Resolves the following crash when switching Xcode versions:
134
+ # "Failed to locate a valid instance of CoreSimulatorService in the bootstrap"
135
+ launchctl remove com.apple.CoreSimulator.CoreSimulatorService || true
124
136
fi
125
137
126
- # Resolves the following crash when switching Xcode versions:
127
- # "Failed to locate a valid instance of CoreSimulatorService in the bootstrap"
128
- launchctl remove com.apple.CoreSimulator.CoreSimulatorService || true
138
+ invoke_bazel $xcode_version
139
+ done
140
+ else
141
+ # Run against whichever Xcode is currently selected.
142
+ selected_xcode_developer_path=$( xcode-select -p)
143
+ selected_xcode_contents_path=$( dirname " $selected_xcode_developer_path " )
144
+
145
+ xcode_version=$( cat " $selected_xcode_contents_path /version.plist" \
146
+ | grep " CFBundleShortVersionString" -A1 \
147
+ | grep string \
148
+ | cut -d' >' -f2 \
149
+ | cut -d' <' -f1)
150
+ if [ -n " $MIN_XCODE_VERSION " ]; then
151
+ xcode_version_as_number=" $( version_as_number $xcode_version ) "
152
+
153
+ if [ " $xcode_version_as_number " -lt " $MIN_XCODE_VERSION " ]; then
154
+ echo " The currently selected Xcode version ($xcode_version_as_number ) is less than the desired version ($MIN_XCODE_VERSION )."
155
+ echo " Stopping execution..."
156
+ exit 1
157
+ fi
129
158
fi
130
159
131
- bazel clean
132
- bazel $ACTION $TARGET --xcode_version $xcode_version $extra_args $verbosity_flags " ${POSITIONAL[@]: 2} "
133
- done
160
+ invoke_bazel $xcode_version
161
+ fi
0 commit comments