X-Git-Url: https://vilimpoc.org/repos/dotfiles/blobdiff_plain/dd9ba4de681ac07d0e7cd78d4549e9ab2a4261f2..HEAD:/setup-windows.bat diff --git a/setup-windows.bat b/setup-windows.bat index d49edd4..eb145ec 100644 --- a/setup-windows.bat +++ b/setup-windows.bat @@ -376,6 +376,46 @@ call :want NASM || goto :after_nasm if not "%ERRORLEVEL%"=="0" call :winget NASM NASM.NASM :after_nasm +@rem MSYS2, per-user, for the MinGW-w64 GCC toolchains - the same ones GitHub's +@rem windows-latest runner carries under C:\msys64, so a build that works here +@rem works there. Two environments are installed: +@rem ucrt64 x86_64, links the UCRT - the modern target +@rem mingw32 i686, links msvcrt.dll - the one that can still target +@rem Windows XP +@rem +@rem Not through winget: the MSYS2.MSYS2 package runs the GUI installer, which +@rem installs machine-wide into C:\msys64 by default. The self-extracting +@rem archive (7-Zip SFX) needs no elevation and unpacks wherever it is pointed, +@rem here %LOCALAPPDATA%\msys64. Nothing is put on the PATH on purpose: the +@rem environments' bin directories carry same-named exes (gcc, ld, windres) and +@rem a project picks one by its full path, e.g. %LOCALAPPDATA%\msys64\mingw32\bin. +@rem +@rem Re-running: the archive is downloaded only when pacman is missing; otherwise +@rem `pacman -Syu` updates what is there and `--needed` leaves installed packages +@rem alone. The first -Syu after a fresh unpack may replace the MSYS2 runtime and +@rem end the shell on purpose, which is why it runs twice. +call :want Msys2 || goto :after_msys2 +set "MSYS2_ROOT=%LOCALAPPDATA%\msys64" +if exist "%MSYS2_ROOT%\usr\bin\pacman.exe" goto :msys2_packages +echo [setup-windows] Msys2: downloading the MSYS2 base archive +"%PS64%" -NoProfile -ExecutionPolicy Bypass -Command "$ProgressPreference='SilentlyContinue'; Invoke-WebRequest -Uri 'https://github.com/msys2/msys2-installer/releases/latest/download/msys2-base-x86_64-latest.sfx.exe' -OutFile \"$env:TEMP\msys2-base.sfx.exe\"" +if not exist "%TEMP%\msys2-base.sfx.exe" ( echo [setup-windows] Msys2: download failed & goto :after_msys2 ) +echo [setup-windows] Msys2: unpacking into %MSYS2_ROOT% +"%TEMP%\msys2-base.sfx.exe" -y -o"%LOCALAPPDATA%" >nul +del /q "%TEMP%\msys2-base.sfx.exe" 2>nul +if not exist "%MSYS2_ROOT%\usr\bin\pacman.exe" ( echo [setup-windows] Msys2: unpack failed & goto :after_msys2 ) +@rem First start: creates the home directory and the key ring. +"%MSYS2_ROOT%\usr\bin\bash.exe" -lc "true" +:msys2_packages +echo [setup-windows] Msys2: updating the base system +"%MSYS2_ROOT%\usr\bin\bash.exe" -lc "pacman -Syuu --noconfirm" +"%MSYS2_ROOT%\usr\bin\bash.exe" -lc "pacman -Syuu --noconfirm" +echo [setup-windows] Msys2: MinGW-w64 GCC for ucrt64 and mingw32 +"%MSYS2_ROOT%\usr\bin\bash.exe" -lc "pacman -S --noconfirm --needed mingw-w64-ucrt-x86_64-gcc mingw-w64-i686-gcc" +"%MSYS2_ROOT%\mingw32\bin\gcc.exe" --version | findstr /i "gcc" && echo [setup-windows] Msys2: mingw32 gcc ready in %MSYS2_ROOT%\mingw32\bin +"%MSYS2_ROOT%\ucrt64\bin\gcc.exe" --version | findstr /i "gcc" && echo [setup-windows] Msys2: ucrt64 gcc ready in %MSYS2_ROOT%\ucrt64\bin +:after_msys2 + @rem VirtualBox has no ARM64 Windows host build, and the x64 one cannot be made to @rem work by emulation: a hypervisor is kernel-mode, and its x64 driver will not @rem load on an ARM64 kernel. Installing it on ARM64 gets you a broken product and