about summary refs log tree commit diff
path: root/src/ci/scripts/select-xcode.sh
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2024-09-25 06:41:56 +0000
committerbors <bors@rust-lang.org>2024-09-25 06:41:56 +0000
commit34aff74fb06e78fb9cd1a66acafb6d150638de35 (patch)
tree14533de260c2f1834994e58af1d210a6884625a9 /src/ci/scripts/select-xcode.sh
parent938c7b1162a38dca257c7004ef7ecf86397a8634 (diff)
parent8be19465ec14880160d294f2909202451a547740 (diff)
downloadrust-34aff74fb06e78fb9cd1a66acafb6d150638de35.tar.gz
rust-34aff74fb06e78fb9cd1a66acafb6d150638de35.zip
Auto merge of #18183 - lnicola:sync-from-rust, r=lnicola
internal: Sync from downstream
Diffstat (limited to 'src/ci/scripts/select-xcode.sh')
-rwxr-xr-xsrc/ci/scripts/select-xcode.sh17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/ci/scripts/select-xcode.sh b/src/ci/scripts/select-xcode.sh
index 569c4a4136d..d635d438472 100755
--- a/src/ci/scripts/select-xcode.sh
+++ b/src/ci/scripts/select-xcode.sh
@@ -1,5 +1,6 @@
 #!/bin/bash
 # This script selects the Xcode instance to use.
+# It also tries to do some cleanup in CI jobs of unused Xcodes.
 
 set -euo pipefail
 IFS=$'\n\t'
@@ -7,5 +8,21 @@ IFS=$'\n\t'
 source "$(cd "$(dirname "$0")" && pwd)/../shared.sh"
 
 if isMacOS; then
+    # This additional step is to try to remove an Xcode we aren't using because each one is HUGE
+    old_xcode="$(xcode-select --print-path)"
+    old_xcode="${old_xcode%/*}" # pop a dir
+    old_xcode="${old_xcode%/*}" # twice
+    if [[ $old_xcode =~ $SELECT_XCODE ]]; then
+        echo "xcode-select.sh's brutal hack may not be necessary?"
+        exit 1
+    elif [[ $SELECT_XCODE =~ "16" ]]; then
+        echo "Using Xcode 16? Please fix xcode-select.sh"
+        exit 1
+    fi
+    if [ $CI ]; then # just in case someone sources this on their real computer
+        sudo rm -rf "${old_xcode}"
+        xcode_16="${old_xcode%/*}/Xcode-16.0.0.app"
+        sudo rm -rf "${xcode_16}"
+    fi
     sudo xcode-select -s "${SELECT_XCODE}"
 fi