diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-06 17:39:55 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-06 17:39:55 -0300 |
| commit | 0706014591cf4af3ee2ed08890675956fb771cc8 (patch) | |
| tree | 8f80e395264b5a054ee2fdb7ad3f2a002ad830db /build.zig | |
| parent | e8e7ed956f3914a3790e980df0862b26c30bd611 (diff) | |
| download | pardes-0706014591cf4af3ee2ed08890675956fb771cc8.tar.gz pardes-0706014591cf4af3ee2ed08890675956fb771cc8.zip | |
kinds #33, the gui with the addons in it: `zig build static -Dplatform=gui` makes a pardes-gui with image and pdf compiled in and registered at start as the terminal's musl static build has them (the gui linked dynamically, as SDL and the GPU need the display's libraries; the static step's module is a gui shell too, wired beside root_mod)
Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_016Y9MNAtZenFv4weoMD3cge
Diffstat (limited to 'build.zig')
| -rw-r--r-- | build.zig | 22 |
1 files changed, 13 insertions, 9 deletions
@@ -194,9 +194,12 @@ pub fn build(b: *std.Build) void { .link_libc = true, }) else null; - // `zig build static`'s: the terminal's, the addons compiled in - // (Addon.zig); musl's alone, as glibc links only dynamically. - const static_mod: ?*std.Build.Module = if (platform == .tui and target.result.isMuslLibC()) b.createModule(.{ + // `zig build static`'s: the addons compiled in (Addon.zig). Linked + // statically on musl alone, as glibc links only dynamically; the gui's + // is dynamic (SDL and the GPU need the display's libraries) with the + // addons in it all the same. + const static_linkage: ?std.builtin.LinkMode = if (target.result.isMuslLibC()) .static else null; + const static_mod: ?*std.Build.Module = if ((platform == .tui and static_linkage != null) or platform == .gui) b.createModule(.{ .target = target, .optimize = optimize, .root_source_file = b.path("src/main.zig"), @@ -895,7 +898,9 @@ pub fn build(b: *std.Build) void { const gui_shell_mod: ?*std.Build.Module = gui_mod orelse if (platform == .gui) root_mod else null; - if (gui_shell_mod) |gm| { + // The static step's gui module is a gui shell too. + const gui_shell_mods: [2]?*std.Build.Module = .{ gui_shell_mod, if (platform == .gui) static_mod else null }; + for (gui_shell_mods) |gui_shell_entry| if (gui_shell_entry) |gm| { const sdl_dep = b.lazyDependency("sdl", .{ .target = target, .optimize = optimize, .sanitize_c = .off, .preferred_linkage = .static }); if (sdl_dep) |dep| { const sdl_lib = dep.artifact("SDL3"); @@ -972,7 +977,7 @@ pub fn build(b: *std.Build) void { else compileGlsl(b, name), }); - } + }; if (platform == .macos) { const header = b.addTranslateC(.{ @@ -1174,11 +1179,11 @@ pub fn build(b: *std.Build) void { // addons compiled in and registered at start as if loaded. It is // also how a build for macOS, whose loader has no memfd, could have // image and PDF panes. - const static_step = b.step("static", "a static pardes with the image and pdf addons in it (-Dplatform=tui -Dtarget=x86_64-linux-musl)"); + const static_step = b.step("static", "a pardes with the image and pdf addons in it: the terminal's static (-Dplatform=tui -Dtarget=x86_64-linux-musl), the gui's dynamic (-Dplatform=gui)"); if (static_mod) |m| - static_step.dependOn(&b.addInstallArtifact(b.addExecutable(.{ .name = "pardes", .linkage = .static, .root_module = m }), .{}).step) + static_step.dependOn(&b.addInstallArtifact(b.addExecutable(.{ .name = exe_name, .linkage = if (platform == .gui) null else static_linkage, .root_module = m }), .{}).step) else - static_step.dependOn(&b.addFail("static is the terminal's and musl's: -Dplatform=tui -Dtarget=x86_64-linux-musl").step); + static_step.dependOn(&b.addFail("static is the terminal's on musl (-Dplatform=tui -Dtarget=x86_64-linux-musl) or the gui's (-Dplatform=gui)").step); const run = b.addRunArtifact(exe); b.step("run", "descend to the pardes").dependOn(&run.step); if (isolated_mod) |iso| { @@ -1496,7 +1501,6 @@ pub fn build(b: *std.Build) void { syntax_test_step.dependOn(&run_syntax_test.step); if (testMatch(b, unit_profile, test_filters, syntax_test_step)) |check| check.addArtifactArg(syntax_test); - const history = b.addExecutable(.{ .name = "pardes-history", .root_module = b.createModule(.{ |
