diff options
Diffstat (limited to 'build.zig')
| -rw-r--r-- | build.zig | 25 |
1 files changed, 23 insertions, 2 deletions
@@ -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; |
