summaryrefslogtreecommitdiff
path: root/build.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-09-19 21:26:05 -0300
committerGabriel Schneider <[email protected]>2026-09-19 21:26:05 -0300
commitb05abcba3ea09ea106ad28364c6e40a3ec31b890 (patch)
tree9170fac5e7e5d8bde108de34a182aaa9d6844117 /build.zig
parentae310a207534b33b7321dd2b9f423a73b1969159 (diff)
downloadcloud9-b05abcba3ea09ea106ad28364c6e40a3ec31b890.tar.gz
cloud9-b05abcba3ea09ea106ad28364c6e40a3ec31b890.zip
Add 9player and introspect as programs beside the library
9player/: FUSE mount CLI that mounts a 9P2000 tree into a fresh user+mount namespace and runs a program in it (no root, no libfuse, no libc). introspect/: the 9P debug/introspection library (freestanding core, value renderers, Linux probe with threads/stacks/memory/breakpoints/panics) and its demo server. Each has its own build fragment; the root build.zig wires them behind -D9player/-Dintrospect with namespaced steps (9player-itest, introspect-check-freestanding, programs-test, ...) and exports the introspect module for dependents. This is the layout for related programs. Co-Authored-By: Claude Fable 5.1 <[email protected]>
Diffstat (limited to 'build.zig')
-rw-r--r--build.zig57
1 files changed, 57 insertions, 0 deletions
diff --git a/build.zig b/build.zig
index 3228cf2..63d9735 100644
--- a/build.zig
+++ b/build.zig
@@ -124,4 +124,61 @@ pub fn build(b: *std.Build) void {
const run_fuzz = b.addRunArtifact(fuzz);
if (b.args) |args| run_fuzz.addArgs(args);
b.step("fuzz", "Run deterministic local decoder and server probes (seed, iterations)").dependOn(&run_fuzz.step);
+
+ // ------------------------------------------------------------------
+ // Programs related to cloud9. Each lives in its own directory beside
+ // src/ (introspect/, 9player/) with a build.zig *fragment* exposing
+ // `add(b, ctx)`; it is imported here and runs with this builder, so its
+ // b.path() calls are relative to this root and its steps are namespaced
+ // by the program's name. New related programs follow the same pattern:
+ // add a directory, a fragment, a toggle here, and the path to
+ // build.zig.zon.
+ //
+ // -Dintrospect=[bool] library module (any target) + freestanding check;
+ // demo server and Linux suites when the target is Linux
+ // -D9player=[bool] the FUSE mount CLI (Linux only)
+ //
+ // Both default to true on a Linux target and false elsewhere. Enabled
+ // programs are installed by the plain `zig build` next to cloud9-http
+ // and cloud9-probe.
+ const is_linux = target.result.os.tag == .linux;
+ const want_introspect = b.option(bool, "introspect", "Build the introspect library module and demo (default: target is Linux)") orelse is_linux;
+ const want_9player = b.option(bool, "9player", "Build the 9player FUSE mount CLI (default: target is Linux; Linux only)") orelse is_linux;
+ if (want_9player and !is_linux) {
+ std.debug.print("error: -D9player=true needs a Linux target (got {s})\n", .{@tagName(target.result.os.tag)});
+ std.process.exit(1);
+ }
+ const programs_test = b.step("programs-test", "Run every enabled program's unit tests and checks");
+ const programs_itest = b.step("programs-itest", "Run every enabled program's integration suites");
+
+ const introspect_build = @import("introspect/build.zig");
+ const nineplayer_build = @import("9player/build.zig");
+
+ const introspect: ?introspect_build.Artifacts = if (want_introspect) introspect_build.add(b, .{
+ .target = target,
+ .optimize = optimize,
+ .cloud9 = module,
+ }) else null;
+ if (introspect) |i| {
+ programs_test.dependOn(i.test_step);
+ programs_test.dependOn(i.check_step);
+ if (i.debug_test_step) |s| programs_test.dependOn(s);
+ }
+
+ const nineplayer: ?nineplayer_build.Artifacts = if (want_9player) nineplayer_build.add(b, .{
+ .target = target,
+ .optimize = optimize,
+ .cloud9 = module,
+ .introspect_demo = if (introspect) |i| i.demo else null,
+ }) else null;
+ if (nineplayer) |p| {
+ programs_test.dependOn(p.test_step);
+ programs_itest.dependOn(p.itest_step);
+ }
+
+ // introspect's end-to-end suites drive the demo through a 9player mount,
+ // so they are wired once both fragments have run.
+ if (introspect) |i| {
+ if (introspect_build.addPlayerTests(b, i, if (nineplayer) |p| p.exe else null)) |s| programs_itest.dependOn(s);
+ }
}