diff options
Diffstat (limited to 'build.zig')
| -rw-r--r-- | build.zig | 49 |
1 files changed, 44 insertions, 5 deletions
@@ -86,8 +86,14 @@ pub fn build(b: *Build) void { }); tracy.link_libcpp = true; } + const text_library = textLibrary(b, target, optimize) orelse return; + b.installArtifact(text_library); const c = cModule(b, target, optimize); + c.linkLibrary(text_library); gpu.addImport("c", c); + // pardes's glyph atlas, for its ink boxes (the host packs its own: see + // src/host/Glyphs.zig) and the comparison with pardes's raster. + const font_atlas = b.createModule(.{ .root_source_file = b.path("src/font/Atlas.zig"), .imports = &.{.{ .name = "c", .module = c }} }); // No optimize mode of its own: the host's Zig code builds in the mode // of the executable it is part of (`script_optimize` makes use of it). const cloud9 = b.dependency("cloud9", .{ .target = target, .optimize = optimize }).module("cloud9"); @@ -95,7 +101,7 @@ pub fn build(b: *Build) void { const host = b.addModule("host", .{ .root_source_file = b.path("src/host/root.zig"), .target = target, - .imports = &.{ .{ .name = "abi", .module = abi }, .{ .name = "c", .module = c }, .{ .name = "gpu", .module = gpu }, .{ .name = "tracy", .module = tracy }, .{ .name = "cloud9", .module = cloud9 }, .{ .name = "xitdb", .module = xitdb } }, + .imports = &.{ .{ .name = "abi", .module = abi }, .{ .name = "c", .module = c }, .{ .name = "gpu", .module = gpu }, .{ .name = "tracy", .module = tracy }, .{ .name = "cloud9", .module = cloud9 }, .{ .name = "xitdb", .module = xitdb }, .{ .name = "font_atlas", .module = font_atlas } }, }); b.step("test-control", "Test 9P control validation and screenshot snapshots").dependOn(&b.addRunArtifact(b.addTest(.{ .root_module = host, .filters = &.{ "control writes", "9P reads", "the State as files", "a row of scalars" } })).step); @@ -181,7 +187,7 @@ pub fn build(b: *Build) void { b.createModule(.{ .root_source_file = b.path("src/abi.zig"), .target = target, .optimize = optimize }), b.createModule(.{ .root_source_file = b.path("src/sketch/root.zig"), .target = target, .optimize = optimize, .imports = sketch_imports }), b.createModule(.{ .root_source_file = b.path("src/math/root.zig"), .target = target, .optimize = optimize }), - b.createModule(.{ .root_source_file = b.path("src/host/root.zig"), .target = target, .optimize = optimize, .imports = &.{ .{ .name = "abi", .module = abi }, .{ .name = "c", .module = c }, .{ .name = "gpu", .module = gpu }, .{ .name = "tracy", .module = tracy }, .{ .name = "cloud9", .module = cloud9 }, .{ .name = "xitdb", .module = xitdb } } }), + b.createModule(.{ .root_source_file = b.path("src/host/root.zig"), .target = target, .optimize = optimize, .imports = &.{ .{ .name = "abi", .module = abi }, .{ .name = "c", .module = c }, .{ .name = "gpu", .module = gpu }, .{ .name = "tracy", .module = tracy }, .{ .name = "cloud9", .module = cloud9 }, .{ .name = "xitdb", .module = xitdb }, .{ .name = "font_atlas", .module = font_atlas } } }), }) |module| test_step.dependOn(&b.addRunArtifact(b.addTest(.{ .root_module = module })).step); // A State bigger than a save holds is a compile error that says what to do. const too_big = b.addObject(.{ .name = "too_big", .root_module = b.createModule(.{ @@ -657,13 +663,46 @@ fn cModule(b: *Build, target: Build.ResolvedTarget, optimize: std.builtin.Optimi source.addFileArg(protocol); translator.mod.addCSourceFile(.{ .file = source.addOutputFileArg("presentation-time-protocol.c"), .flags = &.{"-std=c99"} }); translator.mod.linkSystemLibrary("wayland-client", .{ .use_pkg_config = .force }); - translator.mod.addCSourceFile(.{ .file = b.path("vendor/text.c"), .flags = &.{"-std=c23"} }); - translator.mod.linkSystemLibrary("pangocairo-1.0", .{ .use_pkg_config = .force }); - translator.mod.linkSystemLibrary("pangoft2-1.0", .{ .use_pkg_config = .force }); } return translator.mod; } +/// `sketchbook-text`: vendor/text.c over pardes's vendor/font.c, FreeType +/// and HarfBuzz, the packages and flags pardes builds its window with. The +/// host links it, and so do a sketch's tests (`App.addTest`), which measure +/// text with no host; a sketch's library never does. Null until the lazy +/// packages are fetched. +fn textLibrary(b: *Build, target: Build.ResolvedTarget, optimize: std.builtin.OptimizeMode) ?*Build.Step.Compile { + const freetype = (b.lazyDependency("freetype", .{ .target = target, .optimize = optimize, .@"enable-libpng" = false }) orelse return null).artifact("freetype"); + const harfbuzz = b.lazyDependency("harfbuzz", .{}) orelse return null; + const lib = b.addLibrary(.{ .name = "sketchbook-text", .linkage = .static, .root_module = b.createModule(.{ + .target = target, + .optimize = optimize, + .link_libc = true, + .link_libcpp = true, + }) }); + lib.root_module.linkLibrary(freetype); + lib.root_module.addIncludePath(harfbuzz.path("src")); + lib.root_module.addCSourceFile(.{ .file = harfbuzz.path("src/harfbuzz.cc"), .flags = &.{ + "-DHAVE_STDBOOL_H", + "-DHAVE_UNISTD_H", + "-DHAVE_SYS_MMAN_H", + "-DHAVE_PTHREAD=1", + "-DHAVE_FREETYPE=1", + "-DHAVE_FT_GET_VAR_BLEND_COORDINATES=1", + "-DHAVE_FT_SET_VAR_BLEND_COORDINATES=1", + "-DHAVE_FT_DONE_MM_VAR=1", + "-DHAVE_FT_GET_TRANSFORM=1", + "-Dhb_malloc_impl=ui_malloc", + "-Dhb_calloc_impl=ui_calloc", + "-Dhb_realloc_impl=ui_realloc", + "-Dhb_free_impl=ui_free", + } }); + lib.root_module.addCSourceFile(.{ .file = b.path("vendor/font.c") }); + lib.root_module.addCSourceFile(.{ .file = b.path("vendor/text.c"), .flags = &.{"-std=c23"} }); + return lib; +} + /// SDL 3.4.14 gives its pthread TLS key no destructor, so threads SDL did not /// create (PipeWire's) leave error storage behind when they exit. Compile the /// original backend with an exit destructor; the pinned package is untouched. |
