]> git.lizzy.rs Git - rust.git/blob - src/ci/scripts/install-msys2.sh
Rollup merge of #92366 - jhpratt:derive-default-enum, r=Mark-Simulacrum
[rust.git] / src / ci / scripts / install-msys2.sh
1 #!/bin/bash
2 # Download and install MSYS2, needed primarily for the test suite (run-make) but
3 # also used by the MinGW toolchain for assembling things.
4
5 set -euo pipefail
6 IFS=$'\n\t'
7
8 source "$(cd "$(dirname "$0")" && pwd)/../shared.sh"
9
10 if isWindows; then
11     msys2Path="c:/msys64"
12     mkdir -p "${msys2Path}/home/${USERNAME}"
13     ciCommandAddPath "${msys2Path}/usr/bin"
14
15     # Detect the native Python version installed on the agent. On GitHub
16     # Actions, the C:\hostedtoolcache\windows\Python directory contains a
17     # subdirectory for each installed Python version.
18     #
19     # The -V flag of the sort command sorts the input by version number.
20     native_python_version="$(ls /c/hostedtoolcache/windows/Python | sort -Vr | head -n 1)"
21
22     # Make sure we use the native python interpreter instead of some msys equivalent
23     # one way or another. The msys interpreters seem to have weird path conversions
24     # baked in which break LLVM's build system one way or another, so let's use the
25     # native version which keeps everything as native as possible.
26     python_home="/c/hostedtoolcache/windows/Python/${native_python_version}/x64"
27     if ! [[ -f "${python_home}/python3.exe" ]]; then
28         cp "${python_home}/python.exe" "${python_home}/python3.exe"
29     fi
30     ciCommandAddPath "C:\\hostedtoolcache\\windows\\Python\\${native_python_version}\\x64"
31     ciCommandAddPath "C:\\hostedtoolcache\\windows\\Python\\${native_python_version}\\x64\\Scripts"
32 fi