summaryrefslogtreecommitdiff
path: root/build.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-06 21:34:19 -0300
committerGabriel Schneider <[email protected]>2026-11-06 21:36:55 -0300
commit5a42ad8d8033c589231e81afdc6f9cb1279b5c22 (patch)
treea0e345b55031e07d02bd6fa19dd5f05e67d36028 /build.zig
parent9589f6878ffd2501b4ce5a034ead58119d38749c (diff)
downloadpardes-5a42ad8d8033c589231e81afdc6f9cb1279b5c22.tar.gz
pardes-5a42ad8d8033c589231e81afdc6f9cb1279b5c22.zip
kinds #43, the PDF kind in Zig: addons/pdf/pdf.zig replaces pdf.c over the same pdf_bridge.c (its header translated by build.zig, Zig 0.17 having no @cImport), one place a pane (a page and how far down it, which where says and address takes) laid out by each view its own way (a view with pictures its own strip, rasters and thumb by its id, a view of glyphs the page's text layer), the view of the last input the one whose window's top the place follows; the pages' sizes, the page's text and its hits, and the search over every page on the lanes as jobs (rows streamed through found, a stale search cancelled, its first hit gone to as a Look of its first row went), the tick asking and laying out only, open's one parse and close kept on the loop (0.4 and 0.8 ms; a truncated file stays a refused Look); a band at most PA_RASTER_MAX; the static build reads the module's pardes_addon, exported only from the library
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.zig40
1 files changed, 17 insertions, 23 deletions
diff --git a/build.zig b/build.zig
index 73902a1b..ab180cc4 100644
--- a/build.zig
+++ b/build.zig
@@ -469,7 +469,12 @@ pub fn build(b: *std.Build) void {
// hands back that same artifact rather than a second copy.
const zlib = freetype_dep.builder.dependency("zlib", .{ .target = target, .optimize = c_optimize }).artifact("z");
- // The PDF addon (addons/pdf/pdf.c over MuPDF and pdf_bridge.c), built
+ // The kinds' C ABI (src/kinds/pardes_addon.h), translated once: the core's
+ // records are the header's, never a mirror of it.
+ const kind_mod = b.addTranslateC(.{ .root_source_file = b.path("src/kinds/pardes_addon.h"), .target = target, .optimize = optimize }).createModule();
+ // ...and what an addon in Zig imports over it (src/kinds/addon.zig).
+ const addon_mod = b.createModule(.{ .root_source_file = b.path("src/kinds/addon.zig"), .target = target, .optimize = optimize, .imports = &.{.{ .name = "pardes_addon", .module = kind_mod }} });
+ // The PDF addon (addons/pdf/pdf.zig over MuPDF through pdf_bridge.c), built
// and installed as the image addon is: compiled only for a step that
// needs it (`pdf`, the tests), though fetched at the first configure,
// which Zig runs alike for every step. MuPDF is compiled against the
@@ -489,25 +494,19 @@ pub fn build(b: *std.Build) void {
.zlib = zlib,
.pic = true,
});
- const lib = b.addLibrary(.{ .name = "pdf", .linkage = .dynamic, .root_module = b.createModule(.{ .target = target, .optimize = c_optimize, .link_libc = true }) });
- mupdf.linkTo(lib.root_module);
- lib.root_module.addIncludePath(b.path("src/kinds"));
- lib.root_module.addIncludePath(b.path("addons/pdf"));
- lib.root_module.addCSourceFile(.{ .file = b.path("addons/pdf/pdf.c"), .flags = &.{ "-std=gnu11", "-Wall", "-Wextra", "-Werror" } });
- lib.root_module.addCSourceFile(.{ .file = b.path("addons/pdf/pdf_bridge.c"), .flags = &.{"-std=gnu11"} });
+ // The bridge's header translated here for pdf.zig (Zig 0.17 has no
+ // @cImport), as the kinds' header is for the core.
+ const bridge_mod = b.addTranslateC(.{ .root_source_file = b.path("addons/pdf/pdf_bridge.h"), .target = target, .optimize = c_optimize }).createModule();
+ const pdf_mod = b.createModule(.{ .root_source_file = b.path("addons/pdf/pdf.zig"), .target = target, .optimize = c_optimize, .link_libc = true, .imports = &.{ .{ .name = "addon", .module = addon_mod }, .{ .name = "pdf_bridge", .module = bridge_mod } } });
+ mupdf.linkTo(pdf_mod);
+ pdf_mod.addIncludePath(b.path("addons/pdf"));
+ pdf_mod.addCSourceFile(.{ .file = b.path("addons/pdf/pdf_bridge.c"), .flags = &.{"-std=gnu11"} });
+ 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 for a static pardes the same C compiled into it, its
- // export renamed: it is one of two in a binary (Addon.zig).
- if (static_mod) |m| {
- const in = b.addLibrary(.{ .name = "pdf-builtin", .linkage = .static, .root_module = b.createModule(.{ .target = target, .optimize = c_optimize, .link_libc = true }) });
- mupdf.linkTo(in.root_module);
- in.root_module.addIncludePath(b.path("src/kinds"));
- in.root_module.addIncludePath(b.path("addons/pdf"));
- in.root_module.addCSourceFile(.{ .file = b.path("addons/pdf/pdf.c"), .flags = &.{ "-std=gnu11", "-Wall", "-Wextra", "-Werror", "-Dpardes_addon=pardes_addon_pdf" } });
- in.root_module.addCSourceFile(.{ .file = b.path("addons/pdf/pdf_bridge.c"), .flags = &.{"-std=gnu11"} });
- m.linkLibrary(in);
- }
+ // ...and for a static pardes the same module compiled into it,
+ // which exports nothing there (Addon.zig reads its declaration).
+ if (static_mod) |m| m.addImport("pdf_addon", pdf_mod);
mupdf_check.dependOn(mupdf_build.addProbe(b, mupdf, .{
.target = target,
.pdf = b.path("docs/design.pdf"),
@@ -831,11 +830,6 @@ pub fn build(b: *std.Build) void {
// One call per module instead of one line per module per dependency, and
// BEFORE the fold below, which reads what these imports put in the table.
- // The kinds' C ABI (src/kinds/pardes_addon.h), translated once: the core's
- // records are the header's, never a mirror of it.
- const kind_mod = b.addTranslateC(.{ .root_source_file = b.path("src/kinds/pardes_addon.h"), .target = target, .optimize = optimize }).createModule();
- // ...and what an addon in Zig imports over it (src/kinds/addon.zig).
- const addon_mod = b.createModule(.{ .root_source_file = b.path("src/kinds/addon.zig"), .target = target, .optimize = optimize, .imports = &.{.{ .name = "pardes_addon", .module = kind_mod }} });
// The image addon (addons/image/image.zig over stb_image, stb.c),
// installed by its step and handed by path to every test that opens a
// picture.