about summary refs log tree commit diff
path: root/src/ci/scripts/install-msys2.sh
diff options
context:
space:
mode:
Diffstat (limited to 'src/ci/scripts/install-msys2.sh')
-rwxr-xr-xsrc/ci/scripts/install-msys2.sh38
1 files changed, 31 insertions, 7 deletions
diff --git a/src/ci/scripts/install-msys2.sh b/src/ci/scripts/install-msys2.sh
index 0aa4b42a6a8..905edf38a09 100755
--- a/src/ci/scripts/install-msys2.sh
+++ b/src/ci/scripts/install-msys2.sh
@@ -1,17 +1,12 @@
 #!/bin/bash
-# Download and install MSYS2, needed primarily for the test suite (run-make) but
-# also used by the MinGW toolchain for assembling things.
+# Clean up and prepare the MSYS2 installation. MSYS2 is needed primarily for
+# the test suite (run-make), but is also used by the MinGW toolchain for assembling things.
 
 set -euo pipefail
 IFS=$'\n\t'
 
 source "$(cd "$(dirname "$0")" && pwd)/../shared.sh"
-
 if isWindows; then
-    msys2Path="c:/msys64"
-    mkdir -p "${msys2Path}/home/${USERNAME}"
-    ciCommandAddPath "${msys2Path}/usr/bin"
-
     # Detect the native Python version installed on the agent. On GitHub
     # Actions, the C:\hostedtoolcache\windows\Python directory contains a
     # subdirectory for each installed Python version.
@@ -29,4 +24,33 @@ if isWindows; then
     fi
     ciCommandAddPath "C:\\hostedtoolcache\\windows\\Python\\${native_python_version}\\x64"
     ciCommandAddPath "C:\\hostedtoolcache\\windows\\Python\\${native_python_version}\\x64\\Scripts"
+
+    # Install pacboy for easily installing packages
+    pacman -S --noconfirm pactoys
+
+    # Delete these pre-installed tools so we can't accidentally use them, because we are using the
+    # MSYS2 setup action versions instead.
+    # Delete pre-installed version of MSYS2
+    rm -r "/c/msys64/"
+    # Delete Strawberry Perl, which contains a version of mingw
+    rm -r "/c/Strawberry/"
+    # Delete these other copies of mingw, I don't even know where they come from.
+    rm -r "/c/mingw64/"
+    rm -r "/c/mingw32/"
+
+    if isKnownToBeMingwBuild; then
+        # Use the mingw version of CMake for mingw builds.
+        # However, the MSVC build needs native CMake, as it fails with the mingw one.
+        # Delete native CMake
+        rm -r "/c/Program Files/CMake/"
+        # Install mingw-w64-$arch-cmake
+        pacboy -S --noconfirm cmake:p
+
+        # We use Git-for-Windows for MSVC builds, and MSYS2 Git for mingw builds,
+        # so that both are tested.
+        # Delete Windows-Git
+        rm -r "/c/Program Files/Git/"
+        # Install MSYS2 git
+        pacman -S --noconfirm git
+    fi
 fi