diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index cf9926b4da..99b6bf2171 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -14,6 +14,7 @@ spec: description: 'Pipelines used only for testing' options: - GIMP_CI_MESON_CLANG #trigger the Debian Clang build (rare usefulness) + - GIMP_CI_MESON_MSVC #trigger the Windows MSVC build (rare usefulness) - GIMP_CI_RASTER_ICONS #trigger the Debian Clang build without vector icons (rare usefulness) - GIMP_CI_CPPCHECK #trigger cppcheck (static code analysis) - none @@ -536,6 +537,7 @@ gimp-snap: tags: - $RUNNER variables: + VCPKG_ROOT: "$CI_PROJECT_DIR/vcpkg" MSYS_ROOT: 'C:/msys64' #meson.build forces non-relocatable .pc. See: https://github.com/mesonbuild/meson/issues/14346 PKGCONF_RELOCATABLE_OPTION: '-Dpkgconfig.relocatable=true' @@ -549,17 +551,30 @@ gimp-snap: # See: https://testing.developer.gimp.org/core/setup/build/windows/#prepare-for-building - Write-Output "$([char]27)[0Ksection_start:$(Get-Date -UFormat %s -Millisecond 0):win_environ[collapsed=true]$([char]13)$([char]27)[0KPreparing build environment" ## Build-time vars -- $env:PKG_CONFIG_PATH = "$GIMP_PREFIX/lib/pkgconfig;$env:MSYS_ROOT/$env:MSYSTEM_PREFIX/lib/pkgconfig;$env:MSYS_ROOT/$env:MSYSTEM_PREFIX/share/pkgconfig" -- $env:XDG_DATA_DIRS = "$GIMP_PREFIX/share;$env:MSYS_ROOT/$env:MSYSTEM_PREFIX/share" +- $env:PKG_CONFIG_PATH = "$GIMP_PREFIX/lib/pkgconfig;$env:VCPKG_ROOT/installed/$env:VCPKG_DEFAULT_TRIPLET/lib/pkgconfig;$env:VCPKG_ROOT/installed/$env:VCPKG_DEFAULT_TRIPLET/share/pkgconfig;$env:MSYS_ROOT/$env:MSYSTEM_PREFIX/lib/pkgconfig;$env:MSYS_ROOT/$env:MSYSTEM_PREFIX/share/pkgconfig" +- $env:XDG_DATA_DIRS = "$GIMP_PREFIX/share;$env:VCPKG_ROOT/installed/$env:VCPKG_DEFAULT_TRIPLET/share;$env:MSYS_ROOT/$env:MSYSTEM_PREFIX/share" ## Runtime vars -- $env:PATH = "$GIMP_PREFIX/bin;$env:MSYS_ROOT/$env:MSYSTEM_PREFIX/bin;$env:PATH" -- $env:GI_TYPELIB_PATH = "$GIMP_PREFIX/lib/girepository-1.0;$env:MSYS_ROOT/$env:MSYSTEM_PREFIX/lib/girepository-1.0" +- $env:PATH = "$GIMP_PREFIX/bin;$env:VCPKG_ROOT/installed/$env:VCPKG_DEFAULT_TRIPLET/bin;$env:MSYS_ROOT/$env:MSYSTEM_PREFIX/bin;$env:PATH" +- $env:GI_TYPELIB_PATH = "$GIMP_PREFIX/lib/girepository-1.0;$env:VCPKG_ROOT/installed/$env:VCPKG_DEFAULT_TRIPLET/lib/girepository-1.0;$env:MSYS_ROOT/$env:MSYSTEM_PREFIX/lib/girepository-1.0" - Write-Output "$([char]27)[0Ksection_end:$(Get-Date -UFormat %s -Millisecond 0):win_environ$([char]13)$([char]27)[0K" deps-win: extends: .win + rules: + - !reference [.win, rules] + - if: '$GIMP_CI_MESON_MSVC != null || "$[[ inputs.test_pipeline ]]" =~ /.*GIMP_CI_MESON_MSVC.*/' + variables: + VARIANT: "-msvc" stage: dependencies + cache: + key: $CI_PROJECT_PATH_SLUG + paths: + - vcpkg + variables: + VCPKG_ARCHIVES_DIR: "$CI_PROJECT_DIR/vcpkg/archives" script: + - if ("$VARIANT" -eq '-msvc') { if (-not (Test-Path $VCPKG_ROOT)) { git clone --depth 1 https://github.com/microsoft/vcpkg; .\vcpkg\bootstrap-vcpkg.bat }; pip install meson } + - if ("$VARIANT" -eq '-msvc') { $VSINSTALLDIR = $(vswhere -products * -latest -property installationPath); Import-Module "$VSINSTALLDIR\Common7\Tools\Microsoft.VisualStudio.DevShell.dll"; Enter-VsDevShell -VsInstallPath "$VSINSTALLDIR" -SkipAutomaticLocation -DevCmdArguments "-arch=$(((Get-WmiObject Win32_ComputerSystem).SystemType).Split('-')[0].Trim().ToLower())" } - build\windows\1_build-deps-msys2.ps1 artifacts: paths: diff --git a/build/windows/1_build-deps-msys2.ps1 b/build/windows/1_build-deps-msys2.ps1 index e7156772f1..074f4e6785 100644 --- a/build/windows/1_build-deps-msys2.ps1 +++ b/build/windows/1_build-deps-msys2.ps1 @@ -21,7 +21,21 @@ if (-not $GITLAB_CI) # Install the required (pre-built) packages for babl, GEGL and GIMP -if (-not $env:MSYS_ROOT) +if (-not $env:VCPKG_ROOT -or (Test-Path "$env:VCPKG_ROOT\vcpkg.exe" -Type Leaf)) + { + $env:VCPKG_ROOT = $(Resolve-Path "${PWD}${PARENT_DIR}\vcpkg" -ErrorAction SilentlyContinue) + if ((Test-Path "$env:VCPKG_ROOT\vcpkg.exe" -Type Leaf) -and -not "$env:VSINSTALLDIR") + { + Write-Host '(ERROR): MSVC installation not found. Please, install it then run this script from Developer PowerShell.' -ForegroundColor Red + exit 1 + } + } +if (-not $env:VCPKG_DEFAULT_TRIPLET) + { + $env:VCPKG_DEFAULT_TRIPLET = if ((Get-WmiObject Win32_ComputerSystem).SystemType -like 'ARM64*') { 'arm64-windows' } else { 'x64-windows' } + } + +if (-not $env:MSYS_ROOT -and -not (Test-Path "$env:VCPKG_ROOT\vcpkg.exe" -Type Leaf)) { $env:MSYS_ROOT = $(Get-ChildItem HKCU:\Software\Microsoft\Windows\CurrentVersion\Uninstall -Recurse | ForEach-Object { Get-ItemProperty $_.PSPath -ErrorAction SilentlyContinue } | Where-Object { $_.PSObject.Properties.Value -like "*The MSYS2 Developers*" } | ForEach-Object { return "$($_.InstallLocation)" }) -replace '\\','/' if ("$env:MSYS_ROOT" -eq '') @@ -35,9 +49,20 @@ if (-not $env:MSYSTEM_PREFIX) $env:MSYSTEM_PREFIX = if ((Get-WmiObject Win32_ComputerSystem).SystemType -like 'ARM64*') { 'clangarm64' } else { 'clang64' } } -Write-Output "$([char]27)[0Ksection_start:$(Get-Date -UFormat %s -Millisecond 0):deps_install[collapsed=true]$([char]13)$([char]27)[0KInstalling dependencies provided by MSYS2" -powershell -Command { $ProgressPreference = 'SilentlyContinue'; $env:PATH="$env:MSYS_ROOT\usr\bin;$env:PATH"; pacman --noconfirm -Suy }; if ("$LASTEXITCODE" -gt '0') { exit 1 } -powershell -Command { $ProgressPreference = 'SilentlyContinue'; $env:PATH="$env:MSYS_ROOT\usr\bin;$env:PATH"; pacman --noconfirm -S --needed $(if ($env:MSYSTEM_PREFIX -ne 'mingw32') { "$(if ($env:MSYSTEM_PREFIX -eq 'clangarm64') { 'mingw-w64-clang-aarch64' } else { 'mingw-w64-clang-x86_64' })-perl" }) (Get-Content build/windows/all-deps-uni.txt | Where-Object { $_.Trim() -ne '' -and -not $_.Trim().StartsWith('#') }).Replace('${MINGW_PACKAGE_PREFIX}',$(if ($env:MINGW_PACKAGE_PREFIX) { "$env:MINGW_PACKAGE_PREFIX" } elseif ($env:MSYSTEM_PREFIX -eq 'clangarm64') { 'mingw-w64-clang-aarch64' } else { 'mingw-w64-clang-x86_64' })).Replace(' \','') }; if ("$LASTEXITCODE" -gt '0') { exit 1 } +Write-Output "$([char]27)[0Ksection_start:$(Get-Date -UFormat %s -Millisecond 0):deps_install[collapsed=true]$([char]13)$([char]27)[0KInstalling dependencies provided by $(if ("$env:VCPKG_ROOT" -ne '') {'vcpkg'} else {'MSYS2'})" +if (Test-Path "$env:VCPKG_ROOT\vcpkg.exe" -Type Leaf) + { + & "$env:VCPKG_ROOT\vcpkg.exe" upgrade --no-dry-run + & "$env:VCPKG_ROOT\vcpkg.exe" install (Get-Content build/windows/all-deps-vcpkg.txt | Where-Object { $_.Trim() -ne '' -and -not $_.Trim().StartsWith('#') }).Replace(' \','') + $env:PKG_CONFIG="$env:VCPKG_ROOT\installed\$env:VCPKG_DEFAULT_TRIPLET\tools\pkgconf\pkgconf.exe" + $env:CC='clang-cl' + } +else + { + Write-Output '(INFO): vcpkg installation not found. Falling back to MSYS2...' + powershell -Command { $ProgressPreference = 'SilentlyContinue'; $env:PATH="$env:MSYS_ROOT\usr\bin;$env:PATH"; pacman --noconfirm -Suy }; if ("$LASTEXITCODE" -gt '0') { exit 1 } + powershell -Command { $ProgressPreference = 'SilentlyContinue'; $env:PATH="$env:MSYS_ROOT\usr\bin;$env:PATH"; pacman --noconfirm -S --needed $(if ($env:MSYSTEM_PREFIX -ne 'mingw32') { "$(if ($env:MSYSTEM_PREFIX -eq 'clangarm64') { 'mingw-w64-clang-aarch64' } else { 'mingw-w64-clang-x86_64' })-perl" }) (Get-Content build/windows/all-deps-uni.txt | Where-Object { $_.Trim() -ne '' -and -not $_.Trim().StartsWith('#') }).Replace('${MINGW_PACKAGE_PREFIX}',$(if ($env:MINGW_PACKAGE_PREFIX) { "$env:MINGW_PACKAGE_PREFIX" } elseif ($env:MSYSTEM_PREFIX -eq 'clangarm64') { 'mingw-w64-clang-aarch64' } else { 'mingw-w64-clang-x86_64' })).Replace(' \','') }; if ("$LASTEXITCODE" -gt '0') { exit 1 } + } Write-Output "$([char]27)[0Ksection_end:$(Get-Date -UFormat %s -Millisecond 0):deps_install$([char]13)$([char]27)[0K" @@ -105,7 +130,7 @@ function self_build ([string]$repo, [array]$branch, [array]$patches, [array]$opt if ((Test-Path meson.build -Type Leaf) -and -not (Test-Path CMakeLists.txt -Type Leaf)) { #babl and GEGL already auto install .pdb but we don't know about other eventual deps - if ("$env:MSYSTEM_PREFIX" -ne 'MINGW32') + if (-not "$env:VSINSTALLDIR" -and "$env:MSYSTEM_PREFIX" -ne 'MINGW32') { if ("$dep" -ne 'babl' -and "$dep" -ne 'gegl') { @@ -119,7 +144,7 @@ function self_build ([string]$repo, [array]$branch, [array]$patches, [array]$opt } elseif (Test-Path CMakeLists.txt -Type Leaf) { - if ("$env:MSYSTEM_PREFIX" -ne 'MINGW32') + if (-not "$env:VSINSTALLDIR" -and "$env:MSYSTEM_PREFIX" -ne 'MINGW32') { Add-Content CMakeLists.txt "install(CODE `"execute_process(COMMAND `${Python3_EXECUTABLE`} $("$GIMP_DIR".Replace('\','/'))/build/windows/2_bundle-gimp-uni_sym.py`)`")" $clang_opts_cmake=@('-DCMAKE_C_FLAGS="-gcodeview"', '-DCMAKE_CXX_FLAGS="-gcodeview"', '-DCMAKE_EXE_LINKER_FLAGS="-Wl,--pdb="', '-DCMAKE_SHARED_LINKER_FLAGS="-Wl,--pdb="', '-DCMAKE_MODULE_LINKER_FLAGS="-Wl,--pdb="') @@ -138,6 +163,10 @@ function self_build ([string]$repo, [array]$branch, [array]$patches, [array]$opt } self_build babl +if ("$VARIANT" -eq '-msvc') + { + exit 0 + } self_build gegl @('build/windows/patches/0001-meson-only-generate-CodeView-.pdb-symbols-on-Windows.patch') @('-Dworkshop=true') if ("$env:MSYSTEM_PREFIX" -ne 'MINGW32') { diff --git a/build/windows/2_build-gimp-msys2.ps1 b/build/windows/2_build-gimp-msys2.ps1 index 4925bc8dc8..3efc66d365 100644 --- a/build/windows/2_build-gimp-msys2.ps1 +++ b/build/windows/2_build-gimp-msys2.ps1 @@ -21,11 +21,11 @@ if (-not $GITLAB_CI) # Install the required (pre-built) packages for babl, GEGL and GIMP (again) -Invoke-Expression ((Get-Content build\windows\1_build-deps-msys2.ps1 | Select-String 'MSYS_ROOT\)' -Context 0,12) -replace '> ','') +Invoke-Expression ((Get-Content build\windows\1_build-deps-msys2.ps1 | Select-String '-not \$env:VCPKG_ROOT' -Context 0,26) -replace '> ','') if ($GITLAB_CI) { - Invoke-Expression ((Get-Content build\windows\1_build-deps-msys2.ps1 | Select-String 'deps_install\[' -Context 0,6) -replace '> ','') + Invoke-Expression ((Get-Content build\windows\1_build-deps-msys2.ps1 | Select-String 'deps_install\[' -Context 0,14) -replace '> ','') } diff --git a/build/windows/all-deps-vcpkg.txt b/build/windows/all-deps-vcpkg.txt new file mode 100644 index 0000000000..2ce97594a5 --- /dev/null +++ b/build/windows/all-deps-vcpkg.txt @@ -0,0 +1,9 @@ +# DEPS AT BUILD-TIME ONLY +pkgconf \ + +# DEPS AT RUNTIME +#glib \ +#json-glib \ +lcms \ +#libjpeg-turbo \ +#libpng