summaryrefslogtreecommitdiff
path: root/build.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-09-14 14:28:15 -0300
committerGabriel Schneider <[email protected]>2026-09-16 11:18:48 -0300
commitae310a207534b33b7321dd2b9f423a73b1969159 (patch)
treeb4c2e85091a4ff6657e0a04ba1b2ef030d588ac8 /build.zig
parent5f24c4a2284a0af84fb9d116f7a39f6a58e42ae9 (diff)
downloadcloud9-ae310a207534b33b7321dd2b9f423a73b1969159.tar.gz
cloud9-ae310a207534b33b7321dd2b9f423a73b1969159.zip
Add reusable HTTP transport, serial gateway, and WASM file browser
Diffstat (limited to 'build.zig')
-rw-r--r--build.zig53
1 files changed, 53 insertions, 0 deletions
diff --git a/build.zig b/build.zig
index 160efdf..3228cf2 100644
--- a/build.zig
+++ b/build.zig
@@ -9,6 +9,59 @@ pub fn build(b: *std.Build) void {
});
const tests = b.addTest(.{ .root_module = module });
b.step("test", "Run protocol and session tests").dependOn(&b.addRunArtifact(tests).step);
+ const wasm_target = b.resolveTargetQuery(.{ .cpu_arch = .wasm32, .os_tag = .freestanding });
+ const wasm_core = b.createModule(.{
+ .root_source_file = b.path("src/root.zig"),
+ .target = wasm_target,
+ .optimize = optimize,
+ });
+ const wasm = b.addExecutable(.{ .name = "cloud9", .root_module = b.createModule(.{
+ .root_source_file = b.path("app/client.zig"),
+ .target = wasm_target,
+ .optimize = optimize,
+ .imports = &.{.{ .name = "cloud9", .module = wasm_core }},
+ }) });
+ wasm.entry = .disabled;
+ wasm.rdynamic = true;
+ wasm.export_memory = true;
+ wasm.stack_size = 256 * 1024;
+ wasm.initial_memory = 1024 * 1024;
+ wasm.max_memory = 1024 * 1024;
+ const web = b.step("web", "Install the standalone browser client into zig-out/web");
+ web.dependOn(&b.addInstallFileWithDir(wasm.getEmittedBin(), .{ .custom = "web/_cloud9" }, "cloud9.wasm").step);
+ for ([_][]const u8{ "index.html", "app.mjs", "client.mjs", "style.css" }) |file| {
+ web.dependOn(&b.addInstallFileWithDir(b.path(b.fmt("app/web/{s}", .{file})), .{ .custom = if (std.mem.eql(u8, file, "index.html")) "web" else "web/_cloud9" }, file).step);
+ }
+ const bridge = b.addExecutable(.{ .name = "cloud9-http", .root_module = b.createModule(.{
+ .root_source_file = b.path("app/main.zig"),
+ .target = target,
+ .optimize = optimize,
+ .link_libc = true,
+ .imports = &.{.{ .name = "cloud9", .module = module }},
+ }) });
+ bridge.root_module.addAnonymousImport("client.wasm", .{ .root_source_file = wasm.getEmittedBin() });
+ b.installArtifact(bridge);
+ const run_bridge = b.addRunArtifact(bridge);
+ if (b.args) |args| run_bridge.addArgs(args);
+ b.step("serve", "Run the HTTP/WebSocket bridge (--upstream tcp:127.0.0.1:564)").dependOn(&run_bridge.step);
+ const native_http = b.addExecutable(.{ .name = "cloud9-http-test", .root_module = b.createModule(.{
+ .root_source_file = b.path("test/web/native.zig"),
+ .target = target,
+ .optimize = optimize,
+ .link_libc = true,
+ .imports = &.{.{ .name = "cloud9", .module = module }},
+ }) });
+ const http_tests = b.addTest(.{ .root_module = b.createModule(.{
+ .root_source_file = b.path("test/http.zig"),
+ .target = target,
+ .optimize = optimize,
+ .imports = &.{.{ .name = "cloud9", .module = module }},
+ }) });
+ b.step("http-test", "Test HTTP WebSocket transport framing").dependOn(&b.addRunArtifact(http_tests).step);
+ const e2e = b.addSystemCommand(&.{ "node", "test/web/e2e.mjs" });
+ e2e.addArtifactArg(bridge);
+ e2e.addArtifactArg(native_http);
+ b.step("e2e", "Run Chromium through the bridge against a local go9p server").dependOn(&e2e.step);
const probe = b.addExecutable(.{
.name = "cloud9-probe",
.root_module = b.createModule(.{