documentation/building.md
This guide covers building SkiaSharp on Windows and macOS.
Before building SkiaSharp, ensure you have:
global.json to pin the SDK versiondotnet workload install maui
dotnet tool install -g cake.tool
Building a complete SkiaSharp is actually pretty simple, you just need to install a few dependencies.
To get started with any type of development, you will have to fork and then clone SkiaSharp. If you are not going to be making changes, you can clone the main repository:
> git clone https://github.com/mono/SkiaSharp
Once the source is on your machine, you can get started with building. There are a few ways in which to get started, depending on what you are going to do.
In many cases, you just want to fix a bug in the managed code. If this is the case, you can just download the native bits from CI, and then work from there.
All Platforms:
global.jsondotnet workload install mauidotnet tool install -g cake.toolWindows Dependencies:
macOS Dependencies:
xcode-select --installThe latest master build bits can be downloaded by running the externals-download target:
> dotnet cake --target=externals-download
If you need a specific build, you can specify the commit SHA from the git history:
> dotnet cake --target=externals-download --gitSha=<git-sha>
If you want the latest from a specific branch, you can also pass the branch name:
> dotnet cake --target=externals-download --gitBranch=<git-branch>
Once that is complete, you should be able to now start working on some code. You can open the source/SkiaSharpSource.sln solution (or one of the platform variants) and start making changes. If you are going to be working with unit tests, or don't need to work on all the platform projects, you can open the tests/SkiaSharp.Desktop.Tests/SkiaSharp.Desktop.Tests.sln solution.
The SkiaSharpSource.sln solution is primarily for working with platform-specific bits, and then you can compile to make sure everything is working. The SkiaSharp.Desktop.Tests.sln solution is for testing that changes to the API are still working as expected.
Once you are finished making changes, you can run the tests target and make sure that the tests will pass on CI. There is also the samples and nuget targets. By adding the --skipExternals=all argument, you can let the bootstrapper know that it should not build any native bits, but rather use the bits that were downloaded.
> dotnet cake --target=everything --skipExternals=all
In addition to a few extra dependencies, the Managed-Only build dependencies are still required.
Windows Dependencies:
python is in the PATH environment variableANDROID_NDK_ROOT or ANDROID_NDK_HOME environment variables.\scripts\install-llvm.ps1LLVM_HOME to the path of the installmacOS Dependencies:
Linux Dependencies:
Build native libraries for specific platforms using Cake targets:
# macOS (Apple Silicon)
dotnet cake --target=externals-macos --arch=arm64
# macOS (Intel)
dotnet cake --target=externals-macos --arch=x64
# iOS (device)
dotnet cake --target=externals-ios
# iOS Simulator
dotnet cake --target=externals-ios-simulator --arch=arm64
# Android (ARM64)
dotnet cake --target=externals-android --arch=arm64
# Android (x86_64 for emulator)
dotnet cake --target=externals-android --arch=x64
# Windows (x64)
dotnet cake --target=externals-windows --arch=x64
# Linux (requires Docker)
dotnet cake --target=externals-linux --arch=x64
Tip: Native builds can take 10-30 minutes depending on your machine. Only build for platforms you need to test.
dotnet cake --target=docs-download-output [--gitSha=<git-sha> | --gitBranch=<git-branch>]
dotnet cake --target=update-docs