From 3e9f6f90d2b47302fa31151787f312559714f834 Mon Sep 17 00:00:00 2001 From: geruipu Date: Sat, 20 Jun 2026 23:36:32 +0800 Subject: [PATCH] Fix Windows ANGLE preflight --- .github/workflows/nuget-static-graphics.yml | 11 +++++- .../patches/angle-chromium-7151.patch | 4 +-- scripts/build-windows-static-graphics.ps1 | 36 ++++++++++++++++++- 3 files changed, 47 insertions(+), 4 deletions(-) diff --git a/.github/workflows/nuget-static-graphics.yml b/.github/workflows/nuget-static-graphics.yml index c06c72e..186ba1d 100644 --- a/.github/workflows/nuget-static-graphics.yml +++ b/.github/workflows/nuget-static-graphics.yml @@ -62,7 +62,7 @@ jobs: - rid: win-arm64 target_cpu: arm64 msvc_arch: amd64_arm64 - runs-on: windows-latest + runs-on: windows-2022 steps: - uses: actions/checkout@v4 @@ -84,6 +84,15 @@ jobs: git config --global core.longpaths true choco install ninja llvm -y + - name: Validate Windows ANGLE inputs + shell: pwsh + env: + RID: ${{ matrix.rid }} + TARGET_CPU: ${{ matrix.target_cpu }} + DEPOT_TOOLS_WIN_TOOLCHAIN: 0 + GYP_MSVS_VERSION: 17.0 + run: .\scripts\build-windows-static-graphics.ps1 angle-preflight + - name: Build Windows static graphics libraries shell: pwsh env: diff --git a/External/NativeStatic/patches/angle-chromium-7151.patch b/External/NativeStatic/patches/angle-chromium-7151.patch index e7f8167..e0939df 100644 --- a/External/NativeStatic/patches/angle-chromium-7151.patch +++ b/External/NativeStatic/patches/angle-chromium-7151.patch @@ -2,10 +2,10 @@ diff --git a/BUILD.gn b/BUILD.gn index 07e1268a57..25f7cba544 100644 --- a/BUILD.gn +++ b/BUILD.gn -@@ -1472,7 +1472,18 @@ if (angle_has_frame_capture) { +@@ -1573,7 +1573,18 @@ if (angle_has_frame_capture) { } } - + +angle_static_library("libANGLE_static") { + complete_static_lib = true + public_deps = [ ":libANGLE" ] diff --git a/scripts/build-windows-static-graphics.ps1 b/scripts/build-windows-static-graphics.ps1 index e63b16d..494e7e1 100644 --- a/scripts/build-windows-static-graphics.ps1 +++ b/scripts/build-windows-static-graphics.ps1 @@ -1,5 +1,5 @@ param( - [ValidateSet("skia", "angle", "all")] + [ValidateSet("skia", "angle", "angle-preflight", "all")] [string]$Target = "all" ) @@ -186,11 +186,44 @@ function Apply-AnglePatches($Src) { $patch = Join-Path $AnglePatchDir "angle-chromium-$AngleBranch.patch" if ((Test-Path $patch) -and -not (Select-String -Path (Join-Path $Src "BUILD.gn") -Pattern 'angle_static_library\("libANGLE_static"\)' -Quiet)) { $null = git -C $Src apply $patch + if ($LASTEXITCODE -ne 0) { + throw "Failed to apply ANGLE patch: $patch" + } } } +function Assert-AngleVisualStudioVersion { + if ($env:VisualStudioVersion -and -not ($env:VisualStudioVersion -in @("17.0", "16.0", "15.0"))) { + throw "ANGLE $AngleBranch requires Visual Studio 2022/2019/2017, but VisualStudioVersion is $env:VisualStudioVersion. Use windows-2022 or a VS 2022 developer prompt." + } + if ($env:GYP_MSVS_OVERRIDE_PATH -and ($env:GYP_MSVS_OVERRIDE_PATH -match '\\Microsoft Visual Studio\\18\\')) { + throw "ANGLE $AngleBranch requires Visual Studio 2022/2019/2017, but GYP_MSVS_OVERRIDE_PATH points to $env:GYP_MSVS_OVERRIDE_PATH. Use windows-2022 or a VS 2022 developer prompt." + } +} + +function Test-AnglePatch { + Require-Command git + Assert-AngleVisualStudioVersion + + $src = Sync-Angle + $patch = Join-Path $AnglePatchDir "angle-chromium-$AngleBranch.patch" + if (-not (Test-Path $patch)) { + return + } + if (Select-String -Path (Join-Path $src "BUILD.gn") -Pattern 'angle_static_library\("libANGLE_static"\)' -Quiet) { + return + } + + $null = git -C $src apply --check $patch + if ($LASTEXITCODE -ne 0) { + throw "ANGLE patch does not apply: $patch" + } + Write-Host "ANGLE preflight passed." +} + function Build-Angle { Ensure-Tools + Assert-AngleVisualStudioVersion Ensure-DepotTools $src = Sync-Angle New-Item -ItemType Directory -Path $OutputDir -Force | Out-Null @@ -229,6 +262,7 @@ New-Item -ItemType Directory -Path $WorkDir -Force | Out-Null New-Item -ItemType Directory -Path $OutputDir -Force | Out-Null switch ($Target) { "skia" { Build-Skia } + "angle-preflight" { Test-AnglePatch } "angle" { Build-Angle } "all" { Build-Skia; Build-Angle } }