summaryrefslogtreecommitdiff
path: root/runtime/9p_io.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-18 21:23:22 -0300
committerGabriel Schneider <[email protected]>2026-11-18 21:43:03 -0300
commitf9a3179542012ec1a700e2020ac9f616b819f972 (patch)
tree73f4cb241876196331f7b28c9f773301bd341a7f /runtime/9p_io.zig
parenta75956bb3443aa8aac778d2ff12c42f5ef99e0e9 (diff)
downloadpardes-f9a3179542012ec1a700e2020ac9f616b819f972.tar.gz
pardes-f9a3179542012ec1a700e2020ac9f616b819f972.zip
dev: the frontends (dev/tui, dev/gui, the macOS app's Swift and resources in dev/macos), host_io, file_watch, fonts, the lsp client and Scip, Art, jump_trail, glide and vaxis_input into dev/ (the reorganisation's tree, step 2b): module `dev` (dev/root.zig) beside the core and the runtime, each naming the others; the window wired into it, sketchbook's devices imported as `sketchbook` (its `dev` would be ours); pardes.zig keeps its re-exports (host_io, file_watch, glide, fonts) so every caller reads as before; core-test and shell-test run the devices' test program too, so the same tests run (the ledger, tui and gui); nothing else changes: frames byte-identical, replicas and process-test the base's
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T
Diffstat (limited to 'runtime/9p_io.zig')
-rw-r--r--runtime/9p_io.zig44
1 files changed, 22 insertions, 22 deletions
diff --git a/runtime/9p_io.zig b/runtime/9p_io.zig
index acc851c4..ef4ecfdd 100644
--- a/runtime/9p_io.zig
+++ b/runtime/9p_io.zig
@@ -1097,7 +1097,7 @@ const TempRuntime = struct {
if (t.old) |v| {
_ = setenv("XDG_RUNTIME_DIR", v, 1);
testing.allocator.free(v);
- } else _ = @import("core").host_io.testUnsetenv("XDG_RUNTIME_DIR");
+ } else _ = @import("dev").host_io.testUnsetenv("XDG_RUNTIME_DIR");
std.Io.Dir.cwd().deleteTree(testing.io, std.mem.sliceTo(&t.directory, 0)) catch |err| std.debug.print("deleteTree: {s}\n", .{@errorName(err)});
}
};
@@ -1133,7 +1133,7 @@ pub fn start(io: std.Io, gpa: std.mem.Allocator, core: *pardes.Pardes) ?*Listene
/// ChildEnv.exportVar for why).
pub fn exportEnv(serial: u32, adopts: bool) void {
const socket: ?[]const u8 = if (own_socket_len > 0) own_socket[0..own_socket_len] else null;
- const ChildEnv = @import("core").host_io.ChildEnv;
+ const ChildEnv = @import("dev").host_io.ChildEnv;
var pid_buf: [16]u8 = undefined;
ChildEnv.exportVar("PARDES_PID", if (adopts) std.fmt.bufPrint(&pid_buf, "{d}", .{@as(u32, @intCast(libc.getpid()))}) catch unreachable else null); // a u32 fits 16
if (socket) |own| {
@@ -1164,10 +1164,10 @@ fn exportMount(sock_path: []const u8) void {
if (mntgen and root.len > 0 and std.mem.startsWith(u8, base, sock_prefix) and std.mem.endsWith(u8, base, suffix) and base.len > sock_prefix.len + suffix.len) {
var buf: [4096]u8 = undefined;
if (std.fmt.bufPrint(&buf, "{s}/pardes/{s}", .{ std.mem.trimEnd(u8, root, "/"), base[sock_prefix.len .. base.len - suffix.len] })) |mount| {
- return @import("core").host_io.ChildEnv.exportVar("PARDES_MOUNT", mount);
+ return @import("dev").host_io.ChildEnv.exportVar("PARDES_MOUNT", mount);
} else |_| {}
}
- @import("core").host_io.ChildEnv.exportVar("PARDES_MOUNT", null);
+ @import("dev").host_io.ChildEnv.exportVar("PARDES_MOUNT", null);
}
pub const Client = struct {
@@ -2719,16 +2719,16 @@ test "a pane's PARDES_MOUNT is the session's directory under 9ns --mntgen, and u
if (value) |old| {
_ = setenv(name, old, 1);
testing.allocator.free(old);
- } else _ = @import("core").host_io.testUnsetenv(name);
+ } else _ = @import("dev").host_io.testUnsetenv(name);
};
_ = setenv("NINE_MOUNT", "/mnt/9p", 1);
_ = setenv("NINE_MNTGEN", "1", 1);
exportMount("/run/user/1000/pardes-9p-work.sock");
- try testing.expectEqualStrings("/mnt/9p/pardes/work", @import("core").host_io.ChildEnv.exported("PARDES_MOUNT").?);
+ try testing.expectEqualStrings("/mnt/9p/pardes/work", @import("dev").host_io.ChildEnv.exported("PARDES_MOUNT").?);
// A mount of another server (9ns --unix): not this session's.
- _ = @import("core").host_io.testUnsetenv("NINE_MNTGEN");
+ _ = @import("dev").host_io.testUnsetenv("NINE_MNTGEN");
exportMount("/run/user/1000/pardes-9p-work.sock");
- try testing.expect(@import("core").host_io.ChildEnv.exported("PARDES_MOUNT") == null);
+ try testing.expect(@import("dev").host_io.ChildEnv.exported("PARDES_MOUNT") == null);
}
test "9P shell environment states being inside pardes apart from how to reach it" {
@@ -2741,16 +2741,16 @@ test "9P shell environment states being inside pardes apart from how to reach it
if (value) |old| {
_ = setenv(name, old, 1);
testing.allocator.free(old);
- } else _ = @import("core").host_io.testUnsetenv(name);
+ } else _ = @import("dev").host_io.testUnsetenv(name);
};
var dir: [sun_path_len:0]u8 = undefined;
_ = setenv("XDG_RUNTIME_DIR", "/run/user/1000", 1);
try testing.expectEqualStrings("/run/user/1000", socketDir(&dir).?);
- _ = @import("core").host_io.testUnsetenv("XDG_RUNTIME_DIR");
+ _ = @import("dev").host_io.testUnsetenv("XDG_RUNTIME_DIR");
_ = setenv("HOME", "/home/example", 1);
try testing.expectEqualStrings("/home/example/.local/state/pardes", socketDir(&dir).?);
- _ = @import("core").host_io.testUnsetenv("HOME");
+ _ = @import("dev").host_io.testUnsetenv("HOME");
try testing.expect(socketDir(&dir) == null);
// The socket a listener keeps while it lives.
@@ -2766,24 +2766,24 @@ test "9P shell environment states being inside pardes apart from how to reach it
// parent, so a pardes started in one of its shells runs a session of
// its own instead of handing its argument over.
exportEnv(7, false);
- try testing.expectEqualStrings(path, @import("core").host_io.ChildEnv.exported("PARDES_9P").?);
- try testing.expectEqualStrings("7", @import("core").host_io.ChildEnv.exported("PARDES_PANE").?);
- try testing.expect(@import("core").host_io.ChildEnv.exported("PARDES_PID") == null);
+ try testing.expectEqualStrings(path, @import("dev").host_io.ChildEnv.exported("PARDES_9P").?);
+ try testing.expectEqualStrings("7", @import("dev").host_io.ChildEnv.exported("PARDES_PANE").?);
+ try testing.expect(@import("dev").host_io.ChildEnv.exported("PARDES_PID") == null);
exportEnv(8, true);
- try testing.expectEqualStrings("8", @import("core").host_io.ChildEnv.exported("PARDES_PANE").?);
- try testing.expectEqualStrings(own_pid, @import("core").host_io.ChildEnv.exported("PARDES_PID").?);
+ try testing.expectEqualStrings("8", @import("dev").host_io.ChildEnv.exported("PARDES_PANE").?);
+ try testing.expectEqualStrings(own_pid, @import("dev").host_io.ChildEnv.exported("PARDES_PID").?);
// A session whose listener never came up is still the session this shell
// is inside: the pid stands on its own, and only the address is missing.
own_socket_len = 0;
exportEnv(0, true);
- try testing.expect(@import("core").host_io.ChildEnv.exported("PARDES_9P") == null);
- try testing.expect(@import("core").host_io.ChildEnv.exported("PARDES_PANE") == null);
- try testing.expectEqualStrings(own_pid, @import("core").host_io.ChildEnv.exported("PARDES_PID").?);
+ try testing.expect(@import("dev").host_io.ChildEnv.exported("PARDES_9P") == null);
+ try testing.expect(@import("dev").host_io.ChildEnv.exported("PARDES_PANE") == null);
+ try testing.expectEqualStrings(own_pid, @import("dev").host_io.ChildEnv.exported("PARDES_PID").?);
exportEnv(0, false);
- try testing.expect(@import("core").host_io.ChildEnv.exported("PARDES_9P") == null);
- try testing.expect(@import("core").host_io.ChildEnv.exported("PARDES_PANE") == null);
- try testing.expect(@import("core").host_io.ChildEnv.exported("PARDES_PID") == null);
+ try testing.expect(@import("dev").host_io.ChildEnv.exported("PARDES_9P") == null);
+ try testing.expect(@import("dev").host_io.ChildEnv.exported("PARDES_PANE") == null);
+ try testing.expect(@import("dev").host_io.ChildEnv.exported("PARDES_PID") == null);
}