From b8ccd4acc0fa0b974eaffb0095a10c1c4af4f166 Mon Sep 17 00:00:00 2001 From: greepar Date: Thu, 23 Jul 2026 04:48:02 +0800 Subject: [PATCH] Fix SkiaSharp 4 win-x86 static linking --- scripts/build-windows-static-graphics.ps1 | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/scripts/build-windows-static-graphics.ps1 b/scripts/build-windows-static-graphics.ps1 index 2c70fa0..a057cc8 100644 --- a/scripts/build-windows-static-graphics.ps1 +++ b/scripts/build-windows-static-graphics.ps1 @@ -353,6 +353,21 @@ function Sync-SkiaSharp { return $src } +function Patch-WinX86SkiaLinker($SkiaDir) { + if ($TargetCpu -ne "x86") { + return + } + + $linkerPath = Join-Path $SkiaDir "src\c\sk_linker.cpp" + $text = Get-Content -Path $linkerPath -Raw + $pattern = '(?m)^ skjson::ObjectValue\* a = nullptr;\r?\n auto r = \(\*a\)\["tmp"\]\.getType\(\);$' + $patched = [regex]::Replace($text, $pattern, ' int r = 0;') + if ($patched -eq $text) { + throw "Unable to patch win-x86 sk_linker JSON keep-alive references." + } + Set-Content -Path $linkerPath -Value $patched -NoNewline -Encoding UTF8 +} + function Prepare-SkiaGitSyncDeps($SkiaDir) { $syncDeps = Join-Path $SkiaDir "tools\git-sync-deps" $text = Get-Content -Path $syncDeps -Raw @@ -390,6 +405,7 @@ function Build-Skia { Ensure-DepotTools $src = Sync-SkiaSharp $skiaDir = Join-Path $src "externals\skia" + Patch-WinX86SkiaLinker $skiaDir if (-not (Test-Path (Join-Path $skiaDir "bin\gn.exe"))) { Invoke-SkiaGitSyncDeps $skiaDir }