summaryrefslogtreecommitdiff
path: root/build.zig
diff options
context:
space:
mode:
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" } };