apotocki/skia
Skia, the 2D graphics library of Chrome and Android: the core with the Direct3D backend and the codecs.
- Library
- skia
- Newest
- 152.0.0 (r1, windows)
- Targets
- windows
- License
- BSD-3-Clause
- Homepage
- https://skia.org
- Keywords
- graphics, 2d, gpu
Use it
In otok.toml:
[deps.skia]
recipe = "apotocki/skia"
version = "~> 152.0.0"
Versions
| Version | Target | Channel | Published | Status |
|---|---|---|---|---|
| 152.0.0 (r1, windows) | windows | stable | 2026-11-07 |
152.0.0 (r1, windows)
Platforms
windows
Toolchains
gn { default-recipe = "apotocki/gn", version = ">= 2175" }ninja { default-recipe = "apotocki/ninja", version = ">= 1.10" }python { default-recipe = "apotocki/python", version = ">= 3.8" }
Recipe files
build.lua
-- Skia's GN with the Visual Studio and the clang-cl of the slice's environment (windows/clang-cl), lld-link of the same LLVM
-- directory; ninja builds the target skia (skia.dll and skia.dll.lib, or skia.lib). The headers are published
-- as consumers include them: <skia/core/SkCanvas.h>, <skcms/skcms.h>.
local function gn_string(s)
return '"' .. s:gsub("\\", "/"):gsub('"', '\\"') .. '"'
end
local function gn_list(values)
local quoted = {}
for _, v in ipairs(values) do table.insert(quoted, gn_string(v)) end
return "[ " .. table.concat(quoted, ", ") .. " ]"
end
-- a directory of vcvars without its trailing separator
local function directory(path)
return (path:gsub("[/\\]+$", ""))
end
-- the flags of otok and of the project Skia takes: the runtime, definitions, the C++ standard; GN chooses the rest
local function kept(flags, seen)
local out = {}
for _, f in ipairs(flags) do
if (f:match("^[/-]M[DT]d?$") or f:match("^[/-]D") or f:match("^/std:")) and not seen[f] then
seen[f] = true
table.insert(out, f)
end
end
return out
end
-- #include "include/core/…" → "skia/core/…", "modules/skcms/…" → "skcms/…"
local function publish_headers(from, to)
for _, header in ipairs(otok.glob("**/*.h", from)) do
local text = otok.read(header)
text = text:gsub('#include "include/', '#include "skia/'):gsub('#include "modules/skcms/', '#include "skcms/')
otok.write(to .. "/" .. header:sub(#from + 2), text)
end
end
function build(slice, options, deps)
local env = slice.toolchain.env
for _, name in ipairs{ "VCINSTALLDIR", "VCToolsVersion", "WindowsSdkDir", "WindowsSDKVersion" } do
if not env[name] then error("Skia builds for Windows only: the slice's environment has no " .. name .. " of Visual Studio") end
end
local llvm = slice.toolchain.cc:gsub("\\", "/"):match("^(.*)/bin/[^/]*$")
local debug = slice.configuration == "debug"
local seen = {}
local cflags = kept(slice.toolchain.cflags, seen)
local cxxflags = kept(slice.toolchain.cxxflags, seen)
local args = {
"is_debug = " .. tostring(debug),
"is_official_build = " .. tostring(not debug),
"is_component_build = " .. tostring(slice.linkage == "dynamic"),
"target_cpu = " .. gn_string(slice.arch == "x86_64" and "x64" or slice.arch),
"win_vc = " .. gn_string(directory(env.VCINSTALLDIR)),
"win_toolchain_version = " .. gn_string(env.VCToolsVersion),
"win_sdk = " .. gn_string(directory(env.WindowsSdkDir)),
"win_sdk_version = " .. gn_string(directory(env.WindowsSDKVersion)),
"clang_win = " .. gn_string(llvm),
"skia_use_egl = false",
"skia_use_dawn = false",
"skia_use_gl = false",
"skia_use_direct3d = true",
-- raw_ptr as a plain pointer: skia.dll would not load partition_alloc's DLLs anyway
"skia_use_partition_alloc = false",
-- debug builds would check SkSL's SPIR-V with spirv-tools: SPIR-V is Vulkan's, which this build has not
"skia_enable_spirv_validation = false",
"skia_enable_skshaper = true",
"skia_enable_skparagraph = true",
-- the libraries of third_party/externals, not the system's (Windows has none)
"skia_use_system_expat = false",
"skia_use_system_harfbuzz = false",
"skia_use_system_libjpeg_turbo = false",
"skia_use_system_libpng = false",
"skia_use_system_libwebp = false",
"skia_use_system_zlib = false",
"extra_cflags = " .. gn_list(cflags),
"extra_cflags_cc = " .. gn_list(cxxflags),
}
local out = slice.source .. "/out/otok"
otok.write(out .. "/args.gn", table.concat(args, "\n") .. "\n")
otok.run({ slice.toolchains.gn, "gen", "out/otok", "--script-executable=" .. slice.toolchains.python }, { cwd = slice.source })
otok.run({ slice.toolchains.ninja, "-C", "out/otok", "skia" }, { cwd = slice.source })
publish_headers(slice.source .. "/include", slice.prefix .. "/include/skia")
for _, header in ipairs{ "skcms.h", "src/skcms_public.h" } do
otok.copy(slice.source .. "/modules/skcms/" .. header, slice.prefix .. "/include/skcms/" .. header)
end
local skia
if slice.linkage == "dynamic" then
otok.copy(out .. "/skia.dll", slice.prefix .. "/bin/skia.dll")
otok.copy(out .. "/skia.dll.lib", slice.prefix .. "/lib/skia.dll.lib")
skia = { link = slice.prefix .. "/lib/skia.dll.lib", runtime = slice.prefix .. "/bin/skia.dll" }
else
otok.copy(out .. "/skia.lib", slice.prefix .. "/lib/skia.lib")
skia = slice.prefix .. "/lib/skia.lib"
end
return { libraries = { skia = skia }, headers = slice.prefix .. "/include" }
end
recipe.toml
# The otok recipe of Skia (https://github.com/apotocki/otok): the 2D graphics library for Windows, built with GN and
# clang-cl, as skia.dll or skia.lib. The source is the branch otok/152 of apotocki/skia: Skia's main at 9f737d3a
# (milestone 152) with the fixes of skia-dev, a commit each (leaks freed by SkGraphics::PurgeLeakedByDesignCaches(),
# the Direct3D backend). The libraries of third_party/externals are resources at the commits of that revision's DEPS.
[recipe]
api = 1
library = "skia"
name = "skia"
version = "152.0.0"
revision = 1
license = "BSD-3-Clause"
license-files = ["LICENSE"]
homepage = "https://skia.org"
description = "Skia, the 2D graphics library of Chrome and Android: the core with the Direct3D backend and the codecs."
keywords = ["graphics", "2d", "gpu"]
linkage = ["static", "dynamic"]
[source]
git = "https://github.com/apotocki/skia"
commit = "2e21637acd9980078d3d2e03eead5baeec4e082a"
[platforms]
supported = ["windows"]
build-on = ["windows/clang-cl"]
[toolchains]
# Skia's own GN (bin/fetch-gn) and the python of its scripts (exec_script)
gn = { version = ">= 2175", default-recipe = "apotocki/gn" }
ninja = { version = ">= 1.10", default-recipe = "apotocki/ninja" }
python = { version = ">= 3.8", default-recipe = "apotocki/python" }
[[product]]
name = "Skia"
libraries = ["skia"]
link = { runtime = "c++" }
[[resource]]
name = "zlib"
git = "https://chromium.googlesource.com/chromium/src/third_party/zlib"
commit = "646b7f569718921d7d4b5b8e22572ff6c76f2596"
dest = "third_party/externals/zlib"
[[resource]]
name = "libpng"
git = "https://skia.googlesource.com/third_party/libpng.git"
commit = "d5515b5b8be3901aac04e5bd8bd5c89f287bcd33"
dest = "third_party/externals/libpng"
[[resource]]
name = "libjpeg_turbo"
git = "https://chromium.googlesource.com/chromium/deps/libjpeg_turbo.git"
commit = "e14cbfaa85529d47f9f55b0f104a579c1061f9ad"
dest = "third_party/externals/libjpeg-turbo"
[[resource]]
name = "libwebp"
git = "https://chromium.googlesource.com/webm/libwebp.git"
commit = "845d5476a866141ba35ac133f856fa62f0b7445f"
dest = "third_party/externals/libwebp"
[[resource]]
name = "wuffs"
git = "https://skia.googlesource.com/external/github.com/google/wuffs-mirror-release-c.git"
commit = "e3f919ccfe3ef542cfc983a82146070258fb57f8"
dest = "third_party/externals/wuffs"
[[resource]]
name = "expat"
git = "https://chromium.googlesource.com/external/github.com/libexpat/libexpat.git"
commit = "6154446fccefbf3ca644894f598969113b0c7bcd"
dest = "third_party/externals/expat"
[[resource]]
name = "harfbuzz"
git = "https://chromium.googlesource.com/external/github.com/harfbuzz/harfbuzz.git"
commit = "9cb1fee51069b206effb4736e443b038d230789d"
dest = "third_party/externals/harfbuzz"
[[resource]]
name = "spirv_cross"
git = "https://chromium.googlesource.com/external/github.com/KhronosGroup/SPIRV-Cross"
commit = "b8fcf307f1f347089e3c46eb4451d27f32ebc8d3"
dest = "third_party/externals/spirv-cross"
[[resource]]
name = "d3d12allocator"
git = "https://skia.googlesource.com/external/github.com/GPUOpen-LibrariesAndSDKs/D3D12MemoryAllocator.git"
commit = "169895d529dfce00390a20e69c2f516066fe7a3b"
dest = "third_party/externals/d3d12allocator"