Add SkiaSharp 4.150.1 static graphics release

This commit is contained in:
greepar committed 2026-07-23 19:53:03 +08:00
1 parent 12588d44ed
commit 572d14040d
22 files changed
+938 -473

No files matched your search

+71 -57
View File
@@ -6,8 +6,8 @@ WORK_DIR="${WORK_DIR:-$ROOT_DIR/External/NativeStatic/.work}"
TARGET_CPU="${TARGET_CPU:-x64}"
RID="${RID:-linux-$TARGET_CPU}"
OUTPUT_DIR="${OUTPUT_DIR:-$ROOT_DIR/External/NativeStatic/$RID}"
SKIASHARP_VERSION="${SKIASHARP_VERSION:-3.119.2}"
ANGLE_BRANCH="${ANGLE_BRANCH:-7151}"
SKIASHARP_VERSION="${SKIASHARP_VERSION:-4.150.1}"
ANGLE_BRANCH="${ANGLE_BRANCH:-7922}"
BUILD_JOBS="${BUILD_JOBS:-$(nproc)}"
ANGLE_PATCH_DIR="${ANGLE_PATCH_DIR:-$ROOT_DIR/External/NativeStatic/patches}"
LLVM_AR="${LLVM_AR:-llvm-ar-19}"
@@ -20,8 +20,8 @@ Usage: scripts/build-linux-static-graphics.sh [skia|angle|all]
Environment:
WORK_DIR Source/build cache directory. Default: External/NativeStatic/.work
OUTPUT_DIR Final static library directory. Default: External/NativeStatic/linux-$TARGET_CPU
SKIASHARP_VERSION SkiaSharp release branch version. Default: 3.119.2
ANGLE_BRANCH ANGLE chromium branch. Default: 7151
SKIASHARP_VERSION SkiaSharp release branch version. Default: 4.150.1
ANGLE_BRANCH ANGLE chromium branch. Default: 7922
TARGET_CPU GN target_cpu. Default: x64. Supported: x64, arm64
RID Output RID. Default: linux-$TARGET_CPU
BUILD_JOBS Ninja parallelism. Default: nproc
@@ -149,11 +149,17 @@ sync_skiasharp() {
prepare_skia_git_sync_deps() {
local sync_deps="$1/tools/git-sync-deps"
python3 - "$sync_deps" <<'PY'
import re
import pathlib
import sys
path = pathlib.Path(sys.argv[1])
text = path.read_text()
deps_path = path.with_name("DEPS")
if deps_path.exists():
deps = deps_path.read_text()
deps = re.sub(r'^\s*"third_party/externals/dng_sdk"\s*:\s*"[^"]+",\s*\n', '', deps, flags=re.MULTILINE)
deps_path.write_text(deps)
old = " multithread(git_checkout_to_directory, list_of_arg_lists)"
new = " for args in list_of_arg_lists:\n git_checkout_to_directory(*args)"
if old in text:
@@ -267,15 +273,15 @@ build_angle() {
patch_depot_tools_python_deps "$src/third_party/depot_tools"
prepend_python_module_path six
prepare_angle_gcs_artifacts "$src"
prepare_musl_clang_toolchain
fi
prepare_musl_clang_runtime
prepare_musl_libstdcxx_headers
gclient sync -f -D -R
local out_dir="$src/out/linux-static-$TARGET_CPU"
local angle_is_clang="false"
if is_musl_rid; then
angle_is_clang="true"
local angle_is_clang="true"
if [[ "$TARGET_CPU" == "arm64" ]] && ! is_musl_rid; then
angle_is_clang="false"
fi
mkdir -p "$out_dir"
cat >"$out_dir/args.gn" <<EOF_ARGS
@@ -296,8 +302,9 @@ angle_enable_swiftshader = false
angle_enable_vulkan = false
angle_enable_wgpu = false
EOF_ARGS
append_angle_musl_gn_args "$out_dir/args.gn"
if is_musl_rid; then
printf 'clang_base_path = "%s/clang"\nclang_use_chrome_plugins = false\nclang_version = "%s"\n' "$WORK_DIR" "$(clang -dumpversion | cut -d. -f1)" >>"$out_dir/args.gn"
fi
gn gen "$out_dir"
ninja -C "$out_dir" -j "$BUILD_JOBS" libANGLE_static libGLESv2_static
@@ -380,53 +387,6 @@ download_angle_gcs_artifact() {
fi
}
append_angle_musl_gn_args() {
local args_file="$1"
if is_musl_rid; then
cat >>"$args_file" <<'EOF_ARGS'
clang_base_path = "/usr"
clang_use_chrome_plugins = false
EOF_ARGS
fi
}
prepare_musl_clang_runtime() {
if ! is_musl_rid; then
return 0
fi
local arch
local gnu_triple
case "$TARGET_CPU" in
x64)
arch="x86_64"
gnu_triple="x86_64-unknown-linux-gnu"
;;
arm64)
arch="aarch64"
gnu_triple="aarch64-unknown-linux-gnu"
;;
*)
echo "Unsupported musl ANGLE target_cpu for clang runtime: $TARGET_CPU" >&2
return 1
;;
esac
local src
src="$(find /usr/lib/llvm* /usr/lib/clang -path "*/${arch}-alpine-linux-musl/libclang_rt.builtins-${arch}.a" -print -quit 2>/dev/null || true)"
if [[ -z "$src" ]]; then
echo "Could not find Alpine compiler-rt builtins for $arch" >&2
return 1
fi
local clang_version
clang_version="$(clang -print-resource-dir | awk -F/ '{print $NF}')"
local dest_dir="/usr/lib/clang/$clang_version/lib/$gnu_triple"
mkdir -p "$dest_dir"
ln -sf "$src" "$dest_dir/libclang_rt.builtins.a"
}
prepare_musl_libstdcxx_headers() {
if ! is_musl_rid; then
return 0
@@ -466,6 +426,60 @@ prepare_musl_libstdcxx_headers() {
ln -sfn "$src_dir" "$dest_dir"
}
prepare_musl_clang_toolchain() {
local arch
local gnu_triple
case "$TARGET_CPU" in
x64)
arch="x86_64"
gnu_triple="x86_64-unknown-linux-gnu"
;;
arm64)
arch="aarch64"
gnu_triple="aarch64-unknown-linux-gnu"
;;
*)
echo "Unsupported musl ANGLE target_cpu: $TARGET_CPU" >&2
return 1
;;
esac
local clang_version
clang_version="$(clang -dumpversion | cut -d. -f1)"
local toolchain_dir="$WORK_DIR/clang"
local runtime
runtime="$(find /usr/lib/llvm* /usr/lib/clang -path "*${arch}*" -name 'libclang_rt.builtins*.a' -print -quit 2>/dev/null || true)"
if [[ -z "$runtime" ]]; then
echo "Could not find Alpine compiler-rt builtins for $arch" >&2
return 1
fi
mkdir -p "$toolchain_dir/bin" "$toolchain_dir/lib/clang/$clang_version/lib/$gnu_triple"
ln -sf "$runtime" "$toolchain_dir/lib/clang/$clang_version/lib/$gnu_triple/libclang_rt.builtins.a"
cat >"$toolchain_dir/bin/clang-wrapper.py" <<'PY'
#!/usr/bin/env python3
import os
import sys
blocked = (
"-fdiagnostics-show-inlining-chain",
"-fno-lifetime-dse",
"-fsanitize-ignore-for-ubsan-feature=",
)
args = [arg for arg in sys.argv[1:] if not arg.startswith(blocked)]
compiler = "/usr/bin/clang++" if os.path.basename(sys.argv[0]) == "clang++" else "/usr/bin/clang"
os.execv(compiler, [compiler, *args])
PY
chmod +x "$toolchain_dir/bin/clang-wrapper.py"
ln -sf clang-wrapper.py "$toolchain_dir/bin/clang"
ln -sf clang-wrapper.py "$toolchain_dir/bin/clang++"
for tool in llvm-ar llvm-ranlib llvm-nm; do
if command -v "$tool" >/dev/null 2>&1; then
ln -sf "$(command -v "$tool")" "$toolchain_dir/bin/$tool"
fi
done
}
copy_first_existing() {
local dest="$1"
shift
+10 -2
View File
@@ -6,8 +6,8 @@ WORK_DIR="${WORK_DIR:-$ROOT_DIR/External/NativeStatic/.work}"
TARGET_CPU="${TARGET_CPU:-arm64}"
RID="${RID:-osx-$TARGET_CPU}"
OUTPUT_DIR="${OUTPUT_DIR:-$ROOT_DIR/External/NativeStatic/$RID}"
SKIASHARP_VERSION="${SKIASHARP_VERSION:-3.119.2}"
ANGLE_BRANCH="${ANGLE_BRANCH:-7151}"
SKIASHARP_VERSION="${SKIASHARP_VERSION:-4.150.1}"
ANGLE_BRANCH="${ANGLE_BRANCH:-7922}"
BUILD_JOBS="${BUILD_JOBS:-$(sysctl -n hw.ncpu)}"
ANGLE_PATCH_DIR="${ANGLE_PATCH_DIR:-$ROOT_DIR/External/NativeStatic/patches}"
SKIA_DEPS_RETRIES="${SKIA_DEPS_RETRIES:-3}"
@@ -68,11 +68,17 @@ sync_skiasharp() {
prepare_skia_git_sync_deps() {
local sync_deps="$1/tools/git-sync-deps"
python3 - "$sync_deps" <<'PY'
import re
import pathlib
import sys
path = pathlib.Path(sys.argv[1])
text = path.read_text()
deps_path = path.with_name("DEPS")
if deps_path.exists():
deps = deps_path.read_text()
deps = re.sub(r'^\s*"third_party/externals/dng_sdk"\s*:\s*"[^"]+",\s*\n', '', deps, flags=re.MULTILINE)
deps_path.write_text(deps)
old = " multithread(git_checkout_to_directory, list_of_arg_lists)"
new = " for args in list_of_arg_lists:\n git_checkout_to_directory(*args)"
if old in text:
@@ -112,10 +118,12 @@ build_skia() {
cat >"$out_dir/args.gn" <<EOF_ARGS
target_os = "mac"
target_cpu = "$TARGET_CPU"
min_macos_version = "10.13"
is_official_build = true
is_static_skiasharp = true
skia_enable_tools = false
skia_enable_ganesh = true
skia_use_metal = true
skia_enable_pdf = false
skia_enable_skottie = false
skia_use_dng_sdk = false
+27 -2
View File
@@ -7,8 +7,8 @@ $ErrorActionPreference = "Stop"
$RootDir = Split-Path -Parent $PSScriptRoot
$WorkDir = if ($env:WORK_DIR) { $env:WORK_DIR } else { Join-Path $RootDir "External\NativeStatic\.work" }
$SkiaSharpVersion = if ($env:SKIASHARP_VERSION) { $env:SKIASHARP_VERSION } else { "3.119.2" }
$AngleBranch = if ($env:ANGLE_BRANCH) { $env:ANGLE_BRANCH } else { "7151" }
$SkiaSharpVersion = if ($env:SKIASHARP_VERSION) { $env:SKIASHARP_VERSION } else { "4.150.1" }
$AngleBranch = if ($env:ANGLE_BRANCH) { $env:ANGLE_BRANCH } else { "7922" }
$TargetCpu = if ($env:TARGET_CPU) { $env:TARGET_CPU } else { "x64" }
$Rid = if ($env:RID) { $env:RID } else { "win-$TargetCpu" }
$OutputDir = if ($env:OUTPUT_DIR) { $env:OUTPUT_DIR } else { Join-Path $RootDir "External\NativeStatic\$Rid" }
@@ -353,9 +353,33 @@ 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\(\);\r?$'
$patched = [regex]::Replace($text, $pattern, ' int r = 0;')
if ($patched -eq $text) {
if ($text -match '(?m)^ int r = 0;\r?$') {
return
}
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
$depsPath = Join-Path $SkiaDir "DEPS"
if (Test-Path $depsPath) {
$depsText = Get-Content -Path $depsPath -Raw
$depsText = [regex]::Replace($depsText, '(?m)^\s*"third_party/externals/dng_sdk"\s*:\s*"[^"]+",\s*\r?\n', '')
Set-Content -Path $depsPath -Value $depsText -NoNewline -Encoding UTF8
}
$old = " multithread(git_checkout_to_directory, list_of_arg_lists)"
$new = " for args in list_of_arg_lists:`n git_checkout_to_directory(*args)"
if ($text.Contains($old)) {
@@ -384,6 +408,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
}
+20 -128
View File
@@ -14,144 +14,36 @@ param(
$ErrorActionPreference = "Stop"
$templateDir = Join-Path (Split-Path -Parent $PSScriptRoot) "Smoke/AvaloniaStaticLinkSmoke"
if (-not (Test-Path (Join-Path $templateDir "AvaloniaStaticLinkSmoke.csproj"))) {
throw "Smoke project template was not found: $templateDir"
}
New-Item -ItemType Directory -Path $ProjectDir -Force | Out-Null
Copy-Item (Join-Path $templateDir "*") -Destination $ProjectDir -Recurse -Force
$nativeReference = ""
if ($StaticLinkNativeVersion) {
$nativeReference = "`n <PackageReference Include=`"StaticLink.Avalonia.Native`" Version=`"$StaticLinkNativeVersion`" />"
}
$escapedNuGetSource = [System.Security.SecurityElement]::Escape($NuGetSource)
$escapedAvaloniaVersion = [System.Security.SecurityElement]::Escape($AvaloniaVersion)
$escapedStaticLinkVersion = [System.Security.SecurityElement]::Escape($StaticLinkVersion)
$escapedStaticLinkNativeVersion = [System.Security.SecurityElement]::Escape($StaticLinkNativeVersion)
$staticLinkReference = ""
if ($StaticLinkVersion) {
$staticLinkReference = "`n <PackageReference Include=`"StaticLink.Avalonia`" Version=`"$StaticLinkVersion`" />"
}
@"
<Project>
<PropertyGroup>
<AvaloniaVersion>$escapedAvaloniaVersion</AvaloniaVersion>
<StaticLinkVersion>$escapedStaticLinkVersion</StaticLinkVersion>
<StaticLinkNativeVersion>$escapedStaticLinkNativeVersion</StaticLinkNativeVersion>
</PropertyGroup>
</Project>
"@ | Set-Content -Path (Join-Path $ProjectDir "SmokeVersions.props") -Encoding UTF8
@"
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<clear />
<add key="local-staticlink" value="$NuGetSource" />
<add key="local-staticlink" value="$escapedNuGetSource" />
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" />
</packageSources>
</configuration>
"@ | Set-Content -Path (Join-Path $ProjectDir "NuGet.config") -Encoding UTF8
@"
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net10.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<AvaloniaUseCompiledBindingsByDefault>true</AvaloniaUseCompiledBindingsByDefault>
<PublishAot>true</PublishAot>
<SelfContained>true</SelfContained>
<PublishSingleFile>true</PublishSingleFile>
<PublishTrimmed>true</PublishTrimmed>
<PublishReadyToRun>false</PublishReadyToRun>
<InvariantGlobalization>true</InvariantGlobalization>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Avalonia" Version="$AvaloniaVersion" />
<PackageReference Include="Avalonia.Desktop" Version="$AvaloniaVersion" />
<PackageReference Include="Avalonia.Themes.Fluent" Version="$AvaloniaVersion" />$staticLinkReference$nativeReference
</ItemGroup>
</Project>
"@ | Set-Content -Path (Join-Path $ProjectDir "AvaloniaStaticLinkSmoke.csproj") -Encoding UTF8
@"
using Avalonia;
namespace AvaloniaStaticLinkSmoke;
internal static class Program
{
[STAThread]
public static void Main(string[] args) => BuildAvaloniaApp().StartWithClassicDesktopLifetime(args);
public static AppBuilder BuildAvaloniaApp()
{
var builder = AppBuilder.Configure<App>()
.UsePlatformDetect()
.LogToTrace();
if (OperatingSystem.IsMacOS())
{
builder = builder.With(new AvaloniaNativePlatformOptions
{
RenderingMode = [AvaloniaNativeRenderingMode.Software]
});
}
return builder;
}
}
"@ | Set-Content -Path (Join-Path $ProjectDir "Program.cs") -Encoding UTF8
@"
using Avalonia;
using Avalonia.Controls.ApplicationLifetimes;
using Avalonia.Markup.Xaml;
namespace AvaloniaStaticLinkSmoke;
public sealed partial class App : Application
{
public override void Initialize()
{
AvaloniaXamlLoader.Load(this);
}
public override void OnFrameworkInitializationCompleted()
{
if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
{
desktop.MainWindow = new MainWindow();
}
base.OnFrameworkInitializationCompleted();
}
}
"@ | Set-Content -Path (Join-Path $ProjectDir "App.axaml.cs") -Encoding UTF8
@"
<Application xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:Class="AvaloniaStaticLinkSmoke.App">
<Application.Styles>
<FluentTheme />
</Application.Styles>
</Application>
"@ | Set-Content -Path (Join-Path $ProjectDir "App.axaml") -Encoding UTF8
@"
using Avalonia.Controls;
namespace AvaloniaStaticLinkSmoke;
public sealed partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}
}
"@ | Set-Content -Path (Join-Path $ProjectDir "MainWindow.axaml.cs") -Encoding UTF8
@"
<Window xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:Class="AvaloniaStaticLinkSmoke.MainWindow"
Width="420"
Height="220"
Title="Avalonia StaticLink Smoke">
<Border Padding="24">
<StackPanel Spacing="8" HorizontalAlignment="Center" VerticalAlignment="Center">
<TextBlock Text="Avalonia $AvaloniaVersion" FontSize="24" FontWeight="SemiBold" HorizontalAlignment="Center" />
<TextBlock Text="StaticLink NativeAOT smoke publish" HorizontalAlignment="Center" />
</StackPanel>
</Border>
</Window>
"@ | Set-Content -Path (Join-Path $ProjectDir "MainWindow.axaml") -Encoding UTF8