Description
To build SkiaSharp
on Windows
:
this requires ~50GB
for installation/setup
and an additional 44GB
for building natives and bindings/views
building is recommended on EXTERNAL HARD-DRIVE
if free space on internal hdd is small
install VS 2022
install specified https://github.com/mono/SkiaSharp/wiki/Building-SkiaSharp for 2022
NOTE: MSVC v143 - VS 2019 C++ build tools
(x86/64, ARM, and ARM64) are required for the UWP natives to build
NOTE: Xamarin SDKs
are required to build libs
(SkiaSharp bindings)
IMPORTANT: the following files require re-targeting
native/uwp/libHarfBuzzSharp/libHarfBuzzSharp.sln
native/uwp/SkiaSharp.Views.Interop.UWP/SkiaSharp.Views.Interop.UWP.sln
native/windows/libHarfBuzzSharp/libHarfBuzzSharp.sln
open each solution, select Retarget solution
and then select Update to v143
and then select ok
~25GB
for components installation
Windows 10 SDK (10.0.10240)
can be obtained from https://go.microsoft.com/fwlink/p/?LinkId=619296
Windows 10 SDK (10.0.16299.91)
can be obtained from https://go.microsoft.com/fwlink/p/?linkid=864422
Android NDK
is not available in VS component selection
install Android NDK 21
from https://github.com/android/ndk/wiki/Unsupported-Downloads#r21e
Android NDK 22
restructures the following root paths, which are not yet adapted to this build system
* platforms
* sources/cxx-stl
* sysroot
* toolchains (with the exception of toolchains/llvm)
In general this change should only affect build system maintainers, or those
using build systems that are not up to date. ndk-build and the CMake
toolchain users are unaffected, and neither are
`make_standalone_toolchain.py` users (though that script has been unnecessary
since r19).
go to System > Advanced System Settings > Environment Variables
add the following
name: ANDROID_SDK_ROOT
value: C:\Program Files (x86)\Android\android-sdk
the above is where VS installs the sdk to
name: ANDROID_NDK_ROOT
value: C:\Users\small\Downloads\android-ndk-r21
(replace "small" with your username)
restart your machine to apply the above changes to system environmental variables
open and replace ./scripts/install-android-platform.ps1
with the following content
Param(
[string] $API
)
$ErrorActionPreference = 'Stop'
$sdk = "$env:ANDROID_SDK_ROOT"
$apiPath = "$sdk/platforms/android-$API/android.jar"
if (Test-Path $apiPath) {
Write-Host "Android API level $API was already installed."
exit 0
}
$latest = "$sdk/cmdline-tools/latest"
if (-not (Test-Path $latest)) {
$versions = Get-ChildItem ("$sdk/cmdline-tools")
$latest = "$sdk/cmdline-tools/" + ($versions | Select-Object -Last 1)[0]
}
if (-not $IsMacOS -and -not $IsLinux) {
$ext = ".bat"
}
$sdkmanager = "$latest/bin/sdkmanager$ext"
Set-Content -Value "y" -Path "yes.txt"
try {
if ($IsMacOS -or $IsLinux) {
sh -c "`"$sdkmanager`" `"platforms\;android-$API`" < yes.txt"
} else {
cmd /c "`"$sdkmanager`" `"platforms;android-$API`" < yes.txt"
}
} finally {
Remove-Item "yes.txt"
}
exit $LASTEXITCODE
next execute the following in an admin powershell
./scripts/install-android-platform.ps1 29
execute the following in non-admin powershell
# note you will need to execute ./scripts/install-tizen.ps1
# multiple times due to bugs in waiting for process to finish
./scripts/install-tizen.ps1 # install tizen studio
# dont execute the next line until the above is done installing tizen studio
# note you will need to execute ./scripts/install-tizen.ps1
# multiple times due to bugs in waiting for process to finish
./scripts/install-tizen.ps1 # install packages from tizen studio package manager
# dont execute the next line until the above is done installing packages from tizen studio package manager
# note you will need to execute ./scripts/install-tizen.ps1
# multiple times due to bugs in waiting for process to finish
./scripts/install-tizen.ps1 # patch llvm in tizen
./scripts/install-llvm.ps1 # windows llvm
./scripts/install-gtk.ps1
./scrips/install-maui.ps1
./scrips/install-mono.ps1
dotnet workload install android ios tvos macos maccatalyst wasm-tools maui --source https://api.nuget.org/v3/index.json --source https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet6/nuget/v3/index.json --source https://pkgs.dev.azure.com/dnceng/public/_packaging/darc-pub-dotnet-runtime-bd261ea4/nuget/v3/index.json --source https://pkgs.dev.azure.com/dnceng/public/_packaging/darc-pub-dotnet-emsdk-52e9452f-3/nuget/v3/index.json
add the following to cake/msbuild.cake
find
if (!string.IsNullOrEmpty(MSBUILD_EXE)) {
c.ToolPath = MSBUILD_EXE;
} else if (IsRunningOnWindows() && !string.IsNullOrEmpty(VS_INSTALL)) {
c.ToolPath = ((DirectoryPath)VS_INSTALL).CombineWithFilePath("MSBuild/Current/Bin/MSBuild.exe");
}
and replace it with
if (!string.IsNullOrEmpty(MSBUILD_EXE)) {
c.ToolPath = MSBUILD_EXE;
} else if (IsRunningOnWindows()) {
if (!string.IsNullOrEmpty(VS_INSTALL)) {
c.ToolPath = ((DirectoryPath)VS_INSTALL).CombineWithFilePath("MSBuild/Current/Bin/MSBuild.exe");
} else {
// check for msbuild 17, this is required to build .net 6 projects (non-natives)
// VS 2022 is in preview
// check VS 2022 Community when it comes out of preview
bool vs2022Cexists = DirectoryExists("C:/Program Files/Microsoft Visual Studio/2022/Community");
bool vs2022Pexists = DirectoryExists("C:/Program Files/Microsoft Visual Studio/2022/Preview");
if (!vs2022Pexists && !vs2022Cexists) {
throw new Exception("Visual Studio 2022 Preview or Community is required");
}
if (vs2022Pexists) {
c.ToolPath = "C:/Program Files/Microsoft Visual Studio/2022/Preview/MSBuild/Current/Bin/MSBuild.exe";
}
if (vs2022Cexists) {
c.ToolPath = "C:/Program Files/Microsoft Visual Studio/2022/Community/MSBuild/Current/Bin/MSBuild.exe";
}
}
}
next, we can begin building
we will assume K:\
is location of SkiaSharp git repo
and the repo has been cloned into SkiaSharp
first we need to grab all external libs needed to pack the nuget
dotnet cake --target=externals-download
any native builds will be built over the top of these
build/windows/skia.so -> out/native/windows/skia.so # overwrites downloaded native/windows/skia.so
when building on a different platform the above will need to be done to retain changes to native libs
Windows natives/windows/skia.so -> K:\skia.so
OSX download natives
OSX K:\skia.so -> natives/windows/skia.so // for windows
next we build
the nugets (WITH NATIVE BUILDING) can be built via
cd K:\SkiaSharp\
dotnet tool restore
if ($?) {
dotnet run --project=utils/SkiaSharpGenerator/SkiaSharpGenerator.csproj -- generate --config binding/libSkiaSharp.json --skia externals/skia --output binding/Binding/SkiaApi.generated.cs
if ($?) {
dotnet run --project=utils/SkiaSharpGenerator/SkiaSharpGenerator.csproj -- verify --config binding/libSkiaSharp.json --skia externals/skia
if ($?) {
dotnet cake --target=nuget --buildall=true
}
}
}
this is useful if you want to build the natives
(and then build C# bindings to be able to test) (when modifying native code
)
the nugets (WITHOUT NATIVE BUILDING) can be built via
cd K:\SkiaSharp\
dotnet tool restore
if ($?) {
dotnet run --project=utils/SkiaSharpGenerator/SkiaSharpGenerator.csproj -- generate --config binding/libSkiaSharp.json --skia externals/skia --output binding/Binding/SkiaApi.generated.cs
if ($?) {
dotnet run --project=utils/SkiaSharpGenerator/SkiaSharpGenerator.csproj -- verify --config binding/libSkiaSharp.json --skia externals/skia
if ($?) {
dotnet cake --target=nuget --buildall=true --skipexternals=all
}
}
}
this is useful if you want to build the C# bindings only
(when your modifying the C# code
)
Metadata
Metadata
Assignees
Type
Projects
Status