]> git.lizzy.rs Git - rust.git/blob - src/ci/scripts/install-mingw.sh
Auto merge of #107443 - cjgillot:generator-less-query, r=compiler-errors
[rust.git] / src / ci / scripts / install-mingw.sh
1 #!/bin/bash
2 # If we need to download a custom MinGW, do so here and set the path
3 # appropriately.
4 #
5 # Otherwise install MinGW through `pacman`
6
7 set -euo pipefail
8 IFS=$'\n\t'
9
10 source "$(cd "$(dirname "$0")" && pwd)/../shared.sh"
11
12 MINGW_ARCHIVE_32="i686-12.2.0-release-posix-dwarf-rt_v10-rev0.7z"
13 MINGW_ARCHIVE_64="x86_64-12.2.0-release-posix-seh-rt_v10-rev0.7z"
14
15 if isWindows; then
16     case "${CI_JOB_NAME}" in
17         *i686*)
18             bits=32
19             arch=i686
20             mingw_archive="${MINGW_ARCHIVE_32}"
21             ;;
22         *x86_64*)
23             bits=64
24             arch=x86_64
25             mingw_archive="${MINGW_ARCHIVE_64}"
26             ;;
27         *aarch64*)
28             # aarch64 is a cross-compiled target. Use the x86_64
29             # mingw, since that's the host architecture.
30             bits=64
31             arch=x86_64
32             mingw_archive="${MINGW_ARCHIVE_64}"
33             ;;
34         *)
35             echo "src/ci/scripts/install-mingw.sh can't detect the builder's architecture"
36             echo "please tweak it to recognize the builder named '${CI_JOB_NAME}'"
37             exit 1
38             ;;
39     esac
40
41     if [[ "${CUSTOM_MINGW-0}" -ne 1 ]]; then
42         pacman -S --noconfirm --needed mingw-w64-$arch-toolchain mingw-w64-$arch-cmake \
43             mingw-w64-$arch-gcc \
44             mingw-w64-$arch-python # the python package is actually for python3
45         ciCommandAddPath "$(ciCheckoutPath)/msys2/mingw${bits}/bin"
46     else
47         mingw_dir="mingw${bits}"
48
49         curl -o mingw.7z "${MIRRORS_BASE}/${mingw_archive}"
50         7z x -y mingw.7z > /dev/null
51         ciCommandAddPath "$(pwd)/${mingw_dir}/bin"
52     fi
53 fi