# HG changeset patch
# User Nick Wellnhofer <wellnhofer@aevum.de>
# Date 1662485222 -7200
#      Tue Sep 06 19:27:02 2022 +0200
# Node ID ee4f953bd1a10ee1d9ecbab7391e728c7c1ef768
# Parent  ad6f8eb0f3a14532f71500160530ead041bc43c9
gitlab-ci: Only install cmake MinGW package if needed

On MinGW, cmake requires curl which requires nghttp2 which requires
libxml2. But having a system libxml2 interferes with the Python tests
for now. Ultimately, we should use Python's os.add_dll_directory() on
Windows. I'm not sure why the current solution using PATH even works.

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -51,7 +51,7 @@
   before_script:
     - "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12"
     - $Env:Path="C:\msys64\$Env:MINGW_PATH\bin;C:\msys64\usr\bin;$Env:Path"
-    - bash -lc 'sh .gitlab-ci/setup_mingw.sh'
+    - bash -lc 'sh .gitlab-ci/setup_mingw.sh autotools'
   script:
     - bash -lc 'sh .gitlab-ci/test.sh'
 
@@ -136,7 +136,7 @@
   before_script:
     - "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12"
     - $Env:Path="C:\msys64\$Env:MINGW_PATH\bin;C:\msys64\usr\bin;$Env:Path"
-    - bash -lc 'sh .gitlab-ci/setup_mingw.sh'
+    - bash -lc 'sh .gitlab-ci/setup_mingw.sh cmake ninja'
     - .gitlab-ci/Install-7-Zip
     - git clone --depth 1 https://gitlab.gnome.org/GNOME/libxml2.git libxml2-source
     - cmake -G Ninja -DBUILD_SHARED_LIBS=$Env:BUILD_SHARED_LIBS -DCMAKE_INSTALL_PREFIX=libxml2-install -DLIBXML2_WITH_TESTS=OFF -S libxml2-source -B libxml2-build
diff --git a/.gitlab-ci/setup_mingw.sh b/.gitlab-ci/setup_mingw.sh
--- a/.gitlab-ci/setup_mingw.sh
+++ b/.gitlab-ci/setup_mingw.sh
@@ -1,16 +1,11 @@
 #!/bin/sh
 
+pacman --noconfirm -Syu
+
 prefix=
 if [ -n "$MINGW_PACKAGE_PREFIX" ]; then
     prefix="${MINGW_PACKAGE_PREFIX}-"
 fi
-
-pacman --noconfirm -Syu
-pacman --noconfirm -S --needed \
-    ${prefix}autotools \
-    ${prefix}cmake \
-    ${prefix}libiconv \
-    ${prefix}ninja \
-    ${prefix}python \
-    ${prefix}xz \
-    ${prefix}zlib
+for module in libiconv python xz zlib "$@"; do
+    pacman --noconfirm -S --needed ${prefix}$module
+done