summaryrefslogtreecommitdiff
path: root/build/addons.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-17 13:35:31 -0300
committerGabriel Schneider <[email protected]>2026-11-17 13:45:32 -0300
commit7a1c66f1a15911763db42d890e9e8172fe404170 (patch)
tree2604fc13399b96b091af1350bc6b78d6e0a9f89a /build/addons.zig
parente5c57a863004914136c4e6b0fa13ed805b3b383d (diff)
downloadpardes-7a1c66f1a15911763db42d890e9e8172fe404170.tar.gz
pardes-7a1c66f1a15911763db42d890e9e8172fe404170.zip
build: the core named once (core.module), the window's pieces made once
build/core.zig's module() makes every core: the shell, the core, the core without the terminal (core-test), pardes-isolate, the static, the bare build's window, the syntax module's (syntax-test) and the 9P test roots; each import and library a core takes is written there once, in the order the fold over core_mods and wireCore gave them, so every compile keeps its inputs. Parts holds what a core is made of, Core the few ways the products differ. Tracy's client and BSD libutil stay where they were (Tracy: the shell and the core; libutil: the shell), now said by a field. Gone: the core_mods fold and its buffers, wireCore and its eleven optional fields, the 9P roots' copies of core_module's import table and link objects. The editor library's and pardes-syntax's import lists are written out in full (editorModule, library.zig); TreeSitter.wire adds the grammars; ShellConfig has defaults, so the library's two literals are one. build/gui.zig's make() builds SDL, gui_c, sketchbook's renderer, HarfBuzz and the renderer's and atlas's tests once, and Window.wire links them into each window shell. One pardes-lspmock (tests and process-test shared it twice from one root); tools.program() makes the eleven uniform runner programs in a line each. The pdf benches (tools.pdfBenches) are made once the core is. Gates: zig build -l and -h byte-identical to the base over the matrix (bare, tui, gui, macos, ReleaseFast, -Dpdf=false, -Dtree-sitter=minimal, musl, -Dtracy), test/lib's configuration byte-identical. Warm rebuild of install addons and core-test shell-test unit-test process-test on the base's cache: tui every compile cached (0 rebuilt), 2339/2486 tests passed with the base's 4 known failures, the same counts as the base; gui one change: SDL3 had -DSDL_DISABLE_STB=1 added once per window shell (twice with -Dplatform=gui), now once, so libSDL3.a's cache path moves and pardes-gui and the shell-test root relink (their argv differ in that one path, nothing else); tests 2398/2545, as the base. Installed bin/pardes, image.so and pdf.so cmp-identical on tui; image.so and pdf.so identical on gui, pardes-gui differs by the relinked SDL3 (size 398,737,210 -> 398,733,114). zig build syntax-test, which did not compile on main, now compiles and passes (40/40). Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T
Diffstat (limited to 'build/addons.zig')
-rw-r--r--build/addons.zig31
1 files changed, 6 insertions, 25 deletions
diff --git a/build/addons.zig b/build/addons.zig
index d22abc7a..a3a23825 100644
--- a/build/addons.zig
+++ b/build/addons.zig
@@ -30,6 +30,9 @@ pub fn gpu(b: *std.Build, target: std.Build.ResolvedTarget, optimize: std.lang.O
pub const Pdf = struct {
lib: ?*std.Build.Step.Compile,
+ /// The same module, for a core with the addons compiled in, which
+ /// exports nothing there (addon.exportLib).
+ module: ?*std.Build.Module,
/// What a step that needs the addon depends on when it is not built.
no_pdf: ?*std.Build.Step,
};
@@ -43,21 +46,19 @@ pub const Pdf = struct {
/// `pardes_addon` alone.
pub fn pdf(b: *std.Build, c: struct {
addon_mod: *std.Build.Module,
- builtin_mods: []const *std.Build.Module,
c_optimize: std.lang.Optimize,
- core_module: *std.Build.Module,
enable_jpx: bool,
freetype: ?*std.Build.Step.Compile,
freetype_dep: ?*std.Build.Dependency,
io: std.Io,
mupdf_check: *std.Build.Step,
mupdf_dep: ?*std.Build.Dependency,
- optimize: std.lang.Optimize,
pdf_pointer_bench_step: *std.Build.Step,
pdf_scroll_bench_step: *std.Build.Step,
target: std.Build.ResolvedTarget,
}) Pdf {
var pdf_addon: ?*std.Build.Step.Compile = null;
+ var pdf_module: ?*std.Build.Module = null;
if (c.mupdf_dep) |md| if (c.freetype_dep) |fd| {
// ...and one zlib, the one FreeType links for its gzip module. Asked
// of FreeType's build with the options it asks with, the dependency
@@ -83,36 +84,16 @@ pub fn pdf(b: *std.Build, c: struct {
const lib = b.addLibrary(.{ .name = "pdf", .linkage = .dynamic, .root_module = pdf_mod });
lib.setVersionScript(b.addWriteFiles().add("pdf.map", "{ global: pardes_addon; local: *; };\n"));
pdf_addon = lib;
- // ...and the same module compiled into a pardes, which exports
- // nothing there (addon.exportLib).
- for (c.builtin_mods) |m| m.addImport("pdf_addon", pdf_mod);
+ pdf_module = pdf_mod;
c.mupdf_check.dependOn(mupdf_build.addProbe(b, mupdf, .{
.target = c.target,
.pdf = b.path("docs/design.pdf"),
}));
-
- // The PDF benches: the core over the addon, a pane of it.
- const config = b.addOptions();
- config.addOption(bool, "release_fast_core", c.optimize == .fast);
- config.addOption([]const u8, "core_optimize", @tagName(c.optimize));
- config.addOptionPath("pdf_addon", lib.getEmittedBin());
- for ([_]struct { step: *std.Build.Step, exe: []const u8, file: []const u8, optimize: std.lang.Optimize }{
- .{ .step = c.pdf_pointer_bench_step, .exe = "pardes-pdf-pointer-bench", .file = "test/pdf_pointer_bench.zig", .optimize = .fast },
- .{ .step = c.pdf_scroll_bench_step, .exe = "pardes-pdf-scroll-bench", .file = "test/pdf_scroll_bench.zig", .optimize = c.optimize },
- }) |bench| {
- const exe = b.addExecutable(.{ .name = bench.exe, .root_module = b.createModule(.{ .target = c.target, .optimize = bench.optimize, .root_source_file = b.path(bench.file), .link_libc = true }) });
- exe.root_module.addImport("pardes", c.core_module);
- exe.root_module.addOptions("pdf_bench_config", config);
- const run = b.addRunArtifact(exe);
- run.addPassthruArgs();
- run.setCwd(b.path("."));
- bench.step.dependOn(&run.step);
- }
};
// Without it, what needs it says how to have it.
const no_pdf: ?*std.Build.Step = if (pdf_addon == null) &b.addFail("this step needs the pdf addon, over MuPDF: add -Dpdf (it is fetched once, and on from then)").step else null;
if (no_pdf) |s| for ([_]*std.Build.Step{ c.mupdf_check, c.pdf_pointer_bench_step, c.pdf_scroll_bench_step }) |step| step.dependOn(s);
- return .{ .lib = pdf_addon, .no_pdf = no_pdf };
+ return .{ .lib = pdf_addon, .module = pdf_module, .no_pdf = no_pdf };
}
/// The image addon (addons/image/image.zig over stb_image, stb.c),