Skip to content

Compile C API (src/c) in libSkiaSharp instead of upstream :core#4131

Open
mattleibow wants to merge 4 commits into
mainfrom
mattleibow/move-capi-to-libskiasharp
Open

Compile C API (src/c) in libSkiaSharp instead of upstream :core#4131
mattleibow wants to merge 4 commits into
mainfrom
mattleibow/move-capi-to-libskiasharp

Conversation

@mattleibow

@mattleibow mattleibow commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

Summary

Parent-repo side of the change that compiles SkiaSharp's fork-owned C API shim (externals/skia/src/c/*.cpp) in the libSkiaSharp target on every platform, instead of injecting it into upstream Skia's :core GN target.

See mono/skia#251 for the full motivation (the m148 :fontmgr_fontconfig / SK_FONTMGR_FONTCONFIG_AVAILABLE regression that this architecturally fixes).

Why the non-GN builds need separate changes

libSkiaSharp is produced by three independent build systems:

Build system Platforms Compiles src/c?
GN (externals/skia/BUILD.gn) Linux, Windows, WASM, Android now in skiasharp_build("SkiaSharp") (mono/skia#251)
Xcode (*.xcodeproj) macOS, iOS, tvOS, Mac Catalyst (reuses the ios project) listed in project.pbxproj Sources
Tizen makefile (project_def.prop) Tizen listed in USER_SRCS

The Apple/Tizen builds compile our shim directly and link a prebuilt libskia.a, so the GN source-list move doesn't propagate to them automatically — they each carry their own copy of the list.

Changes

externals/skia submodule

Apple xcodeprojs — native/{macos,ios,tvos}/libSkiaSharp/libSkiaSharp.xcodeproj/project.pbxproj

  • Added the 40 src/c/*.cpp sources to each project's Sources build phase (previously they came from :core indirectly; now they're explicit, matching the GN move). Covers macOS, iOS, tvOS, and Mac Catalyst (which reuses the ios project via native/maccatalyst/build.cake).
  • Added OTHER_CFLAGS = -Werror=deprecated-declarations to all four build configurations in each of the three projects. These targets build via xcodebuild (not GN), so the GN-side guardrail doesn't apply — without this, deprecated-API usage only warned and the build still succeeded. They compile only our src/c + src/xamarin shim (upstream Skia is a prebuilt static lib), so the scope is exactly our own sources.

Tizen — native/tizen/libSkiaSharp/project_def.prop

  • Added the src/c/*.cpp sources to USER_SRCS. (Tizen's makefile already builds with -Wall -Wextra -Werror, which is what first caught the deprecated TightBounds usage.)

Deprecation enforcement is now consistent everywhere

Build system Mechanism
GN (Linux/Windows/WASM/Android) :skiasharp_strict config → -Werror=deprecated-declarations (mono/skia#251)
Xcode (macOS/iOS/tvOS/MacCatalyst) OTHER_CFLAGS = -Werror=deprecated-declarations (this PR)
Tizen existing -Werror

Validation

  • macOS arm64 (native xcodebuild): ARCHIVE SUCCEEDED; real 7.3 MB dylib.
  • Deprecation guardrail proven on macOS: with the deprecated TightBounds call restored, dotnet cake --target=externals-macos fails (exit 65) with error: 'TightBounds' is deprecated [-Werror,-Wdeprecated-declarations]; with the fix it builds clean.
  • Linux x64 (Docker): clean; fontconfig regression guard passes (non-empty default typeface).
  • Tests: SkiaSharp.Tests.Console pass.

Merge order

Merge mono/skia#251 first, then this PR will point at the merged submodule SHA.

@github-actions

github-actions Bot commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

📦 Try the packages from this PR

Warning

Do not run these scripts without first reviewing the code in this PR.

Step 1 — Download the packages

bash / macOS / Linux:

curl -fsSL https://raw.githubusercontent.com/mono/SkiaSharp/main/scripts/get-skiasharp-pr.sh | bash -s -- 4131

PowerShell / Windows:

iex "& { $(irm https://raw.githubusercontent.com/mono/SkiaSharp/main/scripts/get-skiasharp-pr.ps1) } 4131"

Step 2 — Add the local NuGet source

dotnet nuget add source ~/.skiasharp/hives/pr-4131/packages --name skiasharp-pr-4131
More options
Option Description
--successful-only / -SuccessfulOnly Only use successful builds
--force / -Force Overwrite previously downloaded packages
--list / -List List available artifacts without downloading
--build-id ID / -BuildId ID Download from a specific build

Or download manually from Azure Pipelines — look for the nuget artifact on the build for this PR.

Remove the source when you're done:

dotnet nuget remove source skiasharp-pr-4131

@github-actions

github-actions Bot commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

📖 Documentation Preview

The documentation for this PR has been deployed and is available at:

🔗 View Staging Site
🔗 View Staging Docs
🔗 View Staging Gallery (Blazor)
🔗 View Staging Gallery (Uno Platform)
🔗 View Staging SkiaFiddle

This preview will be updated automatically when you push new commits to this PR.


This comment is automatically updated by the documentation staging workflow.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR aligns the non-GN native build systems (Apple Xcode projects and Tizen makefile) with the upstream GN-graph change that moves SkiaSharp’s fork-owned C API shim (externals/skia/src/c/*.cpp) into the libSkiaSharp target, instead of relying on those sources being compiled via Skia’s upstream :core target.

Changes:

  • Adds externals/skia/src/c/*.cpp files to the libSkiaSharp Xcode project sources for macOS, iOS (and thus Mac Catalyst via reuse), and tvOS.
  • Adds -Werror=deprecated-declarations via OTHER_CFLAGS to all Xcode build configurations so deprecation enforcement matches GN/Tizen behavior.
  • Adds the same src/c/*.cpp list to Tizen’s USER_SRCS so the non-GN Tizen build compiles the shim directly.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.

File Description
native/macos/libSkiaSharp/libSkiaSharp.xcodeproj/project.pbxproj Adds src/c shim sources to the macOS Xcode build and enforces deprecated-declarations as errors.
native/ios/libSkiaSharp/libSkiaSharp.xcodeproj/project.pbxproj Adds src/c shim sources to the iOS (and Mac Catalyst via reuse) Xcode build and enforces deprecated-declarations as errors.
native/tvos/libSkiaSharp/libSkiaSharp.xcodeproj/project.pbxproj Adds src/c shim sources to the tvOS Xcode build and enforces deprecated-declarations as errors.
native/tizen/libSkiaSharp/project_def.prop Adds src/c shim sources to the Tizen makefile’s USER_SRCS list.

mattleibow and others added 4 commits June 13, 2026 00:33
Follow-up to the mono/skia change that moves the fork-owned C API shim
(src/c/*.cpp) out of upstream Skia's :core target and into the libSkiaSharp
build, decoupling it from :core's milestone-churning transitive dependencies
(which silently dropped SK_FONTMGR_FONTCONFIG_AVAILABLE on Linux in m148).

On platforms built via the GN skiasharp_build("SkiaSharp") target (Android,
Linux, Windows, WASM) the move is handled entirely in the submodule. But the
Apple platforms (macOS, iOS, tvOS) and Tizen build libSkiaSharp from a project
file that compiles the managed-interop glue and links the GN-built libskia.a;
they relied on src/c being inside :core. Add the src/c/*.cpp sources to:

  - native/{macos,ios,tvos}/libSkiaSharp/libSkiaSharp.xcodeproj
  - native/tizen/libSkiaSharp/project_def.prop

so every platform compiles the C API into libSkiaSharp itself, consistent with
how the src/xamarin glue is already handled. These projects already link
-lskottie/-lsksg/-lskresources/-ljsonreader, so no extra linkage is needed.

Validated: macOS arm64 (real dylib, full test suite passes) and Linux x64
(real .so with libfontconfig.so.1 dependency and 44 Fc* imports — the m148
regression guard).

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The macOS/iOS/tvOS libSkiaSharp targets build via xcodebuild (pbxproj), not
GN, so the GN-side deprecation guardrail does not cover them. They compiled
the deprecated SkPathOps TightBounds() with only a warning. Add
OTHER_CFLAGS = -Werror=deprecated-declarations to every build configuration in
the three Apple xcodeprojs so deprecated Skia API usage fails the build on
Apple platforms too, matching the GN (:skiasharp_strict) and Tizen (-Werror)
builds. These targets compile only our src/c + src/xamarin shim (upstream Skia
is linked as a prebuilt static lib), so the scope is exactly our own sources.

Bumps externals/skia to pick up the TightBounds fix + GN warnings guardrail.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@mattleibow mattleibow force-pushed the mattleibow/move-capi-to-libskiasharp branch from f878b64 to 9a9e700 Compare June 12, 2026 22:34
@mattleibow mattleibow requested a review from Copilot June 12, 2026 23:09

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated no new comments.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

2 participants