summaryrefslogtreecommitdiff
path: root/build.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-06 13:28:30 -0300
committerGabriel Schneider <[email protected]>2026-11-06 14:24:59 -0300
commit0f81de017ca7b52e951bb70f6f5f3e8c88b425e6 (patch)
treefde88db0ed0dd68fbeb7bf7aaa49d3cd1f08b1c1 /build.zig
parentb7fdfb18ffd199d49a254c1c799bc3415ad45ec2 (diff)
downloadpardes-0f81de017ca7b52e951bb70f6f5f3e8c88b425e6.tar.gz
pardes-0f81de017ca7b52e951bb70f6f5f3e8c88b425e6.zip
kinds #25, addons in Zig: src/kinds/addon.zig, over the translated header and nothing of the core, makes a kind's pa_ops from a struct of the functions it has (its head from name, version, extensions and words; a public function of no kind's name a compile error), the pane's arena and a job's pa_out as std Allocators, typed keys, a Window to put text in, a Paint for the prefix and placements, tick's flags and a Deadline, dump and load as an extern struct's bytes in one line each, and body and ctl over a Writer; snake.zig and image.zig (stb_image in stb.c, static, beside any zstbi) replace snake.c and image.c with the same goldens, harness and perf cell, and addon-test runs their own zig tests
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.zig25
1 files changed, 13 insertions, 12 deletions
diff --git a/build.zig b/build.zig
index 603857e7..2328d5df 100644
--- a/build.zig
+++ b/build.zig
@@ -341,14 +341,6 @@ pub fn build(b: *std.Build) void {
const zstbi_dep = b.dependency("zstbi", .{ .target = target, .optimize = c_optimize });
const zstbi_mod = zstbi_dep.module("root");
- // The image addon (addons/image/image.c over stb_image), installed where
- // the start scan finds it (<prefix>/lib/pardes/addons) and handed by
- // path to every test that opens a picture.
- const image_addon = b.addLibrary(.{ .name = "image", .linkage = .dynamic, .root_module = b.createModule(.{ .target = target, .optimize = c_optimize, .link_libc = true }) });
- image_addon.root_module.addIncludePath(b.path("src/kinds"));
- image_addon.root_module.addIncludePath(zstbi_dep.path("libs/stbi"));
- image_addon.root_module.addCSourceFile(.{ .file = b.path("addons/image/image.c"), .flags = &.{ "-std=c11", "-Wall", "-Wextra", "-Werror" } });
-
// mvzr backtracks with no bound on its work (its own test "do not make
// this test any longer": `a?` n times is 2^n steps), and pardes searches
// with it holding the editor. Its matcher gets a step budget, patched into
@@ -817,6 +809,15 @@ pub fn build(b: *std.Build) void {
// 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.
+ const image_mod = b.createModule(.{ .root_source_file = b.path("addons/image/image.zig"), .target = target, .optimize = c_optimize, .link_libc = true, .imports = &.{.{ .name = "addon", .module = addon_mod }} });
+ image_mod.addIncludePath(zstbi_dep.path("libs/stbi"));
+ image_mod.addCSourceFile(.{ .file = b.path("addons/image/stb.c"), .flags = &.{ "-std=c11", "-Wall", "-Wextra", "-Werror" } });
+ const image_addon = b.addLibrary(.{ .name = "image", .linkage = .dynamic, .root_module = image_mod });
for (core_mods) |m| wireCore(m, .{
.kind = kind_mod,
.themes = themes_mod,
@@ -1585,10 +1586,10 @@ pub fn build(b: *std.Build) void {
// An addon's own test: `--addon-test` over the fake (the template)
// and the snake (a shipped example, built but not installed), each
// with its script, compared with what it printed when written.
- const addon_test_step = b.step("addon-test", "pardes --addon-test over the fake, snake and pdf addons, against addons/*/*.out");
- const snake_lib = b.addLibrary(.{ .name = "snake", .linkage = .dynamic, .root_module = b.createModule(.{ .target = target, .optimize = optimize, .link_libc = true }) });
- snake_lib.root_module.addIncludePath(b.path("src/kinds"));
- snake_lib.root_module.addCSourceFile(.{ .file = b.path("addons/snake/snake.c"), .flags = &.{ "-std=c11", "-Wall", "-Wextra", "-Werror" } });
+ const addon_test_step = b.step("addon-test", "pardes --addon-test over the fake, snake and pdf addons, against addons/*/*.out, and the Zig addons' own tests");
+ const snake_mod = b.createModule(.{ .root_source_file = b.path("addons/snake/snake.zig"), .target = target, .optimize = optimize, .imports = &.{.{ .name = "addon", .module = addon_mod }} });
+ const snake_lib = b.addLibrary(.{ .name = "snake", .linkage = .dynamic, .root_module = snake_mod });
+ for ([_]*std.Build.Module{ snake_mod, image_mod }) |m| addon_test_step.dependOn(&b.addRunArtifact(b.addTest(.{ .root_module = m })).step);
// ...and the pdf addon's, which mupdf-check runs too (its script
// opens docs/design.pdf, from the build root).
const libs = [_]struct { ?*std.Build.Step.Compile, []const u8 }{ .{ fake_addon_lib.?, "addons/fake/fake" }, .{ snake_lib, "addons/snake/snake" }, .{ pdf_addon, "addons/pdf/pdf" } };