summaryrefslogtreecommitdiff
path: root/build.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-09-14 14:10:28 -0300
committerGabriel Schneider <[email protected]>2026-09-14 14:20:25 -0300
commit5f24c4a2284a0af84fb9d116f7a39f6a58e42ae9 (patch)
tree8679763439492361fe99ea01f5190e5204fa590c /build.zig
downloadcloud9-5f24c4a2284a0af84fb9d116f7a39f6a58e42ae9.tar.gz
cloud9-5f24c4a2284a0af84fb9d116f7a39f6a58e42ae9.zip
Implement base 9P2000 sessions, shared transports, and conformance probes
Diffstat (limited to 'build.zig')
-rw-r--r--build.zig74
1 files changed, 74 insertions, 0 deletions
diff --git a/build.zig b/build.zig
new file mode 100644
index 0000000..160efdf
--- /dev/null
+++ b/build.zig
@@ -0,0 +1,74 @@
+const std = @import("std");
+pub fn build(b: *std.Build) void {
+ const target = b.standardTargetOptions(.{});
+ const optimize = b.standardOptimizeOption(.{});
+ const module = b.addModule("cloud9", .{
+ .root_source_file = b.path("src/root.zig"),
+ .target = target,
+ .optimize = optimize,
+ });
+ const tests = b.addTest(.{ .root_module = module });
+ b.step("test", "Run protocol and session tests").dependOn(&b.addRunArtifact(tests).step);
+ const probe = b.addExecutable(.{
+ .name = "cloud9-probe",
+ .root_module = b.createModule(.{
+ .root_source_file = b.path("test/differential/probe.zig"),
+ .target = target,
+ .optimize = optimize,
+ .link_libc = true,
+ .imports = &.{.{ .name = "cloud9", .module = module }},
+ }),
+ });
+ b.installArtifact(probe);
+ const session_probe = b.addExecutable(.{
+ .name = "cloud9-session-probe",
+ .root_module = b.createModule(.{
+ .root_source_file = b.path("test/differential/session.zig"),
+ .target = target,
+ .optimize = optimize,
+ .link_libc = true,
+ .imports = &.{.{ .name = "cloud9", .module = module }},
+ }),
+ });
+
+ const diff = b.addSystemCommand(&.{ "go", "run", "." });
+ diff.setCwd(b.path("test/differential"));
+ diff.addArg("--probe");
+ diff.addArtifactArg(probe);
+ diff.addArg("--session-probe");
+ diff.addArtifactArg(session_probe);
+ if (b.args) |args| diff.addArgs(args);
+ b.step("differential", "Compare valid traffic with pinned 9fans and go9p").dependOn(&diff.step);
+ const transport_tests = b.addTest(.{ .root_module = b.createModule(.{
+ .root_source_file = b.path("test/transport.zig"),
+ .target = target,
+ .optimize = optimize,
+ .link_libc = true,
+ .imports = &.{.{ .name = "cloud9", .module = module }},
+ }) });
+ b.step("transport-test", "Test TCP, Unix and std.Io adapters").dependOn(&b.addRunArtifact(transport_tests).step);
+ if (b.option(bool, "quic", "Test QUIC with system OpenSSL 3.6+") orelse false) {
+ const header = b.addWriteFiles().add("openssl.h", "#include <openssl/ssl.h>\n#include <openssl/quic.h>\n#include <openssl/err.h>\n");
+ const translated = b.addTranslateC(.{ .root_source_file = header, .target = target, .optimize = optimize, .link_libc = true });
+ const ssl = translated.createModule();
+ const tests_quic = b.addTest(.{ .root_module = b.createModule(.{
+ .root_source_file = b.path("test/quic.zig"),
+ .target = target,
+ .optimize = optimize,
+ .link_libc = true,
+ .imports = &.{ .{ .name = "cloud9", .module = module }, .{ .name = "openssl", .module = ssl } },
+ }) });
+ tests_quic.root_module.linkSystemLibrary("ssl", .{});
+ tests_quic.root_module.linkSystemLibrary("crypto", .{});
+ b.step("quic-test", "Test optional QUIC transport").dependOn(&b.addRunArtifact(tests_quic).step);
+ }
+ const fuzz = b.addExecutable(.{ .name = "cloud9-fuzz", .root_module = b.createModule(.{
+ .root_source_file = b.path("test/fuzz.zig"),
+ .target = target,
+ .optimize = optimize,
+ .imports = &.{.{ .name = "cloud9", .module = module }},
+ }) });
+ 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);
+}