summaryrefslogtreecommitdiff
path: root/build.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-17 03:00:00 -0300
committerGabriel Schneider <[email protected]>2026-11-17 12:15:01 -0300
commit1d4015b1b9740a894bea288dadb11d212eceff73 (patch)
treeafbe13324d480e0c758ebd228c8dc37c67ac20f5 /build.zig
parente8662178dba9d779cbfaa290154ae78c61402d30 (diff)
downloadpardes-1d4015b1b9740a894bea288dadb11d212eceff73.tar.gz
pardes-1d4015b1b9740a894bea288dadb11d212eceff73.zip
gui: the font shim and the glyph atlas are sketchbook's (vendor/font.{c,h}, src/font/Atlas.zig), moved as they were, the second step of the GPU move: font.c and font.h leave src/gui/ byte for byte, and the atlas leaves gui.zig, its faces (the primary, its bytes, the fallbacks), its stage, slots, pen and dirty rows, GlyphKey (Atlas.Key, the same bits: a FontRole and a GlyphDecoration go in as its Role and Decoration, checked at compile time), ruleArms, drawRule, inkBounds, glyphForCodepoint, cachedGlyph, centerGlyphInk and decorateLine; gui.zig holds an Atlas and asks it for what it asked the shim (a face, a fallback, the name, the cell, a substitution, a run shaped), so it calls no ui_font_ function; cachedGlyph stays as the window's: it hands the atlas the body's and the tagline's sizes, GUTTER and dp(1) on every miss (a window reopened on another display draws its rules at that display's dp(1) without a reset, as before) and keeps the frame probe's raster zone; the Atlas module is built from the sketchbook checkout over gui.zig's own `c` as Cells is, font.c compiled from there against pardes's FreeType and HarfBuzz; its tests (the raster, the box rules, the decorations, the dirty rows) are Atlas.zig's and run with unit-test, the tests of pardes's use of it (shaping, taglines, grips, the allocator, the atlas's bytes, whose hashes are unchanged) stay here over the Atlas
Diffstat (limited to 'build.zig')
-rw-r--r--build.zig25
1 files changed, 23 insertions, 2 deletions
diff --git a/build.zig b/build.zig
index 12b7b35c..c2a0c8ac 100644
--- a/build.zig
+++ b/build.zig
@@ -895,7 +895,11 @@ pub fn build(b: *std.Build) void {
var sdl_include: ?std.Build.LazyPath = null;
// sketchbook's Cells.zig's own tests (the instance ABI), for unit-test.
var cells_test: ?*std.Build.Step.Compile = null;
+ // sketchbook's Atlas.zig's own tests, for unit-test.
+ var atlas_test: ?*std.Build.Step.Compile = null;
for (gui_shell_mods) |gui_shell_entry| if (gui_shell_entry) |gm| {
+ // This shell's `c`, for the Atlas's tests below.
+ var font_c: ?*std.Build.Module = null;
// SDL's build asks a cross build for macOS for the SDK's paths.
const sdk: ?std.Build.LazyPath = if (macos_sdk) |p| .{ .cwd_relative = p } else null;
const sdl_dep = b.lazyDependency("sdl", .{ .target = target, .optimize = optimize, .sanitize_c = .off, .preferred_linkage = .static, .system_include_path = if (sdk) |p| p.path(b, "usr/include") else null, .system_framework_path = if (sdk) |p| p.path(b, "System/Library/Frameworks") else null, .library_path = if (sdk) |p| p.path(b, "usr/lib") else null });
@@ -919,6 +923,7 @@ pub fn build(b: *std.Build) void {
gui_c.addIncludePath(dep.path("include"));
gui_c.addIncludePath(b.path("src/gui"));
const gui_c_mod = gui_c.createModule();
+ font_c = gui_c_mod;
gm.addImport("gui_c", gui_c_mod);
if (b.lazyDependency("sketchbook", .{ .@"gpu-only" = true })) |sb| {
const gpu = b.createModule(.{ .root_source_file = sb.path("src/gpu/Executor.zig"), .imports = &.{ .{ .name = "abi", .module = sb.module("abi") }, .{ .name = "c", .module = gui_c_mod } } });
@@ -927,6 +932,11 @@ pub fn build(b: *std.Build) void {
// against pardes's SDL; its tests run with unit-test.
gm.addImport("gpu_cells", b.createModule(.{ .root_source_file = sb.path("src/gpu/Cells.zig"), .imports = &.{.{ .name = "c", .module = gui_c_mod }} }));
if (cells_test == null) cells_test = b.addTest(.{ .root_module = b.createModule(.{ .root_source_file = sb.path("src/gpu/Cells.zig"), .target = target, .optimize = optimize, .imports = &.{.{ .name = "c", .module = gui_c_mod }} }), .filters = test_filters });
+ // The glyph atlas (src/font/Atlas.zig) over the font shim
+ // (vendor/font.{c,h}), compiled below against pardes's
+ // FreeType and HarfBuzz.
+ gm.addImport("font_atlas", b.createModule(.{ .root_source_file = sb.path("src/font/Atlas.zig"), .imports = &.{.{ .name = "c", .module = gui_c_mod }} }));
+ gui_c.addIncludePath(sb.path("vendor"));
gm.addImport("gpu_scene", sb.module("gpu_scene"));
}
sdl_include = dep.path("include");
@@ -983,11 +993,21 @@ pub fn build(b: *std.Build) void {
});
gm.linkLibrary(harfbuzz);
gm.addIncludePath(upstream.path("src"));
+ // The Atlas's own tests, over the same FreeType, HarfBuzz and
+ // shim, the embedded face theirs to draw.
+ if (atlas_test == null) if (font_c) |fc| if (b.lazyDependency("sketchbook", .{ .@"gpu-only" = true })) |sb| {
+ const atlas_mod = b.createModule(.{ .root_source_file = sb.path("src/font/Atlas.zig"), .target = target, .optimize = optimize, .link_libc = true, .imports = &.{.{ .name = "c", .module = fc }} });
+ atlas_mod.linkLibrary(ft);
+ atlas_mod.linkLibrary(harfbuzz);
+ atlas_mod.addIncludePath(upstream.path("src"));
+ atlas_mod.addCSourceFile(.{ .file = sb.path("vendor/font.c") });
+ atlas_mod.addAnonymousImport("AdwaitaMono-Regular.ttf", .{ .root_source_file = b.path("assets/AdwaitaMono-Regular.ttf") });
+ atlas_test = b.addTest(.{ .root_module = atlas_mod, .filters = test_filters });
+ };
}
if (target.result.os.tag.isDarwin())
gm.addRPath(.{ .cwd_relative = "/usr/local/lib" });
- gm.addIncludePath(b.path("src/gui"));
- gm.addCSourceFile(.{ .file = b.path("src/gui/font.c") });
+ if (b.lazyDependency("sketchbook", .{ .@"gpu-only" = true })) |sb| gm.addCSourceFile(.{ .file = sb.path("vendor/font.c") });
// the embedded UI font: provided as a build import since assets/ lives
// outside the src/ module root (@embedFile can't escape it)
gm.addAnonymousImport("AdwaitaMono-Regular.ttf", .{
@@ -1589,6 +1609,7 @@ pub fn build(b: *std.Build) void {
_ = units.add(b, perf_tests, null);
_ = units.add(b, fs_bench_test, null);
if (cells_test) |t| _ = units.add(b, t, null);
+ if (atlas_test) |t| _ = units.add(b, t, null);
const core_test = b.addTest(.{ .root_module = core_module, .filters = test_filters });
const run_core_test = b.addRunArtifact(core_test);
run_core_test.has_side_effects = true;