diff --git a/build-scripts/build-windows b/build-scripts/build-windows index 9e902e52..2ec6a500 100755 --- a/build-scripts/build-windows +++ b/build-scripts/build-windows @@ -6,12 +6,15 @@ tool=$2 if [[ $tool == mingw ]]; then pacman -Sy --noconfirm make base-devel tar zip unzip - if [[ $wordsize == 64 ]]; then - pacman -Sy --noconfirm mingw-w64-x86_64-toolchain - PATH="/c/tools/msys64/mingw64/bin:$PATH" + if [ -d /c/msys64 ]; then + PATH="/c/msys64/mingw$wordsize/bin:$PATH" else - pacman -Sy --noconfirm mingw-w64-i686-toolchain - PATH="/c/tools/msys64/mingw32/bin:$PATH" + if [[ $wordsize == 64 ]]; then + pacman -Sy --noconfirm mingw-w64-x86_64-toolchain + else + pacman -Sy --noconfirm mingw-w64-i686-toolchain + fi + PATH="/c/tools/msys64/mingw$wordsize/bin:$PATH" fi g++ -v elif [[ $tool == msvc ]]; then diff --git a/build-scripts/build-windows.bat b/build-scripts/build-windows.bat index 8be269e9..0f81ebf3 100644 --- a/build-scripts/build-windows.bat +++ b/build-scripts/build-windows.bat @@ -1,5 +1,6 @@ @echo on @rem Usage: build-windows {32|64} {msvc|mingw} +setlocal ENABLEDELAYEDEXPANSION if %2 == msvc ( if %1 == 64 ( call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\Build\vcvars64.bat" @@ -9,8 +10,11 @@ if %2 == msvc ( choco install zip bash ./build-scripts/build-windows %1 %2 ) else ( - @rem The vs2017-win2016 pool has an ancient 64-bit-only mingw. - @rem Install msys2 so we can get current gcc toolchains. - choco install msys2 - C:\tools\msys64\usr\bin\env.exe MSYSTEM=MINGW64 /bin/bash -l %CD%/build-scripts/build-windows %1 %2 + if exist C:\msys64 ( + set MSYS=C:\msys64 + ) else ( + choco install msys2 + set MSYS=C:\tools\msys64 + ) + !MSYS!\usr\bin\env.exe MSYSTEM=MINGW64 /bin/bash -l %CD%/build-scripts/build-windows %1 %2 )