summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-18 20:52:50 -0300
committerGabriel Schneider <[email protected]>2026-11-18 21:22:58 -0300
commita75956bb3443aa8aac778d2ff12c42f5ef99e0e9 (patch)
tree17547cbf6606c8bd05be313cd8f835cb85d13e57
parent5b33c88476054fffc1044fff0526f7f0b28563cf (diff)
downloadpardes-a75956bb3443aa8aac778d2ff12c42f5ef99e0e9.tar.gz
pardes-a75956bb3443aa8aac778d2ff12c42f5ef99e0e9.zip
runtime: main, daemon, upgrade, crash, addon_test, 9p_io, 9p and macos.zig into runtime/ (the reorganisation's tree, step 2a), skill.txt with main.zig, its one reader: module `runtime` (runtime/root.zig) and the core, each naming the other, a product's root (main.zig, macos.zig) a module of its own over both; the files name across by module (`@import("runtime").daemon`, `@import("core").look`), pardes.zig exporting what they name (ctl, edit_cmd, tracy, selection_pipe, and the frontends until they move); core-test and shell-test run each module's test program, so the same tests run (the ledger: every named test of every suite the base's, tui and gui); nothing else changes: frames byte-identical, the same counts (tui core-test 822/963, the one more an anonymous collector)
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T
-rw-r--r--build.zig23
-rw-r--r--build/core.zig88
-rw-r--r--build/macos.zig2
-rw-r--r--build/process.zig12
-rw-r--r--build/tests.zig31
-rw-r--r--build/tools.zig2
-rw-r--r--runtime/9p.zig (renamed from src/9p.zig)0
-rw-r--r--runtime/9p_io.zig (renamed from src/9p_io.zig)58
-rw-r--r--runtime/addon_test.zig (renamed from src/addon_test.zig)4
-rw-r--r--runtime/crash.zig (renamed from src/crash.zig)4
-rw-r--r--runtime/daemon.zig (renamed from src/daemon.zig)2
-rw-r--r--runtime/macos.zig (renamed from src/macos.zig)30
-rw-r--r--runtime/main.zig (renamed from src/main.zig)73
-rw-r--r--runtime/root.zig26
-rw-r--r--runtime/skill.txt (renamed from src/skill.txt)0
-rw-r--r--runtime/upgrade.zig (renamed from src/upgrade.zig)2
-rw-r--r--src/Handover.zig2
-rw-r--r--src/Output.zig2
-rw-r--r--src/builtins.zig2
-rw-r--r--src/fs.zig8
-rw-r--r--src/gui/gui.zig6
-rw-r--r--src/host_io.zig8
-rw-r--r--src/look.zig2
-rw-r--r--src/ninep/tree.zig2
-rw-r--r--src/pardes.zig18
-rw-r--r--src/replica.zig2
-rw-r--r--src/tui/tui.zig6
-rw-r--r--test/process.zig2
28 files changed, 244 insertions, 173 deletions
diff --git a/build.zig b/build.zig
index e7997363..dbc7e3ba 100644
--- a/build.zig
+++ b/build.zig
@@ -174,28 +174,32 @@ pub fn build(b: *std.Build) void {
// addons compiled in.
const compiled_in = target.result.os.tag != .linux;
// The macOS shell is a library whose host owns main(): it roots at
- // its own flat C ABI instead of src/main.zig. Tracy's client and BSD
+ // its own flat C ABI instead of runtime/main.zig. Tracy's client and BSD
// libutil go to the shell (and Tracy's to the core) alone, as before
// core.module.
- const root_mod = core.module(b, parts, .{ .root = if (platform == .macos) "src/macos.zig" else "src/main.zig", .config = opts, .builtin_addons = compiled_in, .tracy = true, .util = true });
+ const root_set = core.module(b, parts, .{ .root = if (platform == .macos) "runtime/macos.zig" else "runtime/main.zig", .config = opts, .builtin_addons = compiled_in, .tracy = true, .util = true });
+ const root_mod = root_set.root;
// hxdiff's headless core and pardes-isolate are the primary shell's
// configuration compiled two more ways, not two more frontends.
const core_cfg: core.Core = .{ .root = "src/pardes.zig", .config = opts, .builtin_addons = compiled_in, .tracy = true };
- const core_module = core.module(b, parts, core_cfg);
+ const core_set = core.module(b, parts, core_cfg);
+ const core_module = core_set.root;
// The core without the terminal module (docs/next-terminal.md, Phase 1):
// what core-test is compiled from. No ghostty-vt, wuffs, zstbi or C++;
// a shell boot is a scratch pane, a test that needs a terminal skips,
// and shell-test runs them all with one.
const lean_cfg: core.Core = .{ .root = "src/pardes.zig", .config = opts, .builtin_addons = compiled_in, .terminal = false };
const core_lean = core.module(b, parts, lean_cfg);
- const isolated_mod: ?*std.Build.Module = if (platform == .tui) core.module(b, parts, .{ .root = "src/main.zig", .config = opts, .builtin_addons = compiled_in, .isolated = true }) else null;
+ const isolated_mod: ?*std.Build.Module = if (platform == .tui) core.module(b, parts, .{ .root = "runtime/main.zig", .config = opts, .builtin_addons = compiled_in, .isolated = true }).root else null;
// `zig build static`'s: the addons compiled in (Addon.zig). Linked
// statically on musl alone, as glibc links only dynamically; the gui's
// is dynamic (SDL and the GPU need the display's libraries) with the
// addons in it all the same.
const static_linkage: ?std.builtin.LinkMode = if (target.result.isMuslLibC()) .static else null;
- const static_mod: ?*std.Build.Module = if ((platform == .tui and static_linkage != null) or platform == .gui) core.module(b, parts, .{ .root = "src/main.zig", .config = opts, .builtin_addons = true }) else null;
- const gui_mod: ?*std.Build.Module = if (also_gui) core.module(b, parts, .{ .root = "src/main.zig", .config = a.gui_opts.?, .builtin_addons = compiled_in }) else null;
+ const static_set: ?core.Modules = if ((platform == .tui and static_linkage != null) or platform == .gui) core.module(b, parts, .{ .root = "runtime/main.zig", .config = opts, .builtin_addons = true }) else null;
+ const static_mod: ?*std.Build.Module = if (static_set) |s| s.root else null;
+ const gui_set: ?core.Modules = if (also_gui) core.module(b, parts, .{ .root = "runtime/main.zig", .config = a.gui_opts.?, .builtin_addons = compiled_in }) else null;
+ const gui_mod: ?*std.Build.Module = if (gui_set) |s| s.root else null;
if (a.pdf.lib) |lib| tools.pdfBenches(b, target, optimize, core_module, lib, pdf_pointer_bench_step, pdf_scroll_bench_step);
const builtins_json_step = docs.builtinsJson(b, requested_platform, platform, target, optimize, core_module, doc_renders);
@@ -205,7 +209,8 @@ pub fn build(b: *std.Build) void {
var sketchbook: ?*std.Build.Dependency = null;
if (also_gui or platform == .gui) {
const window = gui.make(b, target, optimize, macos_sdk, prebuilt_shaders, a.freetype);
- for ([_]?*std.Build.Module{ gui_mod, if (platform == .gui) root_mod else null, if (platform == .gui) static_mod else null }) |m| if (m) |gm| window.wire(gm);
+ // ...into the core, whose gui/gui.zig names the window.
+ for ([_]?core.Modules{ gui_set, if (platform == .gui) root_set else null, if (platform == .gui) static_set else null }) |m| if (m) |s| window.wire(s.core);
sketchbook = window.sketchbook;
}
const snake_shader_lib = addons.gpu(b, target, optimize, a.addon_mod, sketchbook);
@@ -292,6 +297,7 @@ pub fn build(b: *std.Build) void {
.optimize = optimize,
.ghostty_vt = a.ghostty_vt,
.cloud9 = parts.cloud9,
+ .runtime = core_set.runtime,
.gui = platform == .gui,
});
@@ -321,6 +327,7 @@ pub fn build(b: *std.Build) void {
tests.add(b, .{
.addon_mod = a.addon_mod,
.core_lean = core_lean,
+ .root_set = root_set,
.core_module = core_module,
.core_cfg = core_cfg,
.exe = exe,
@@ -350,7 +357,7 @@ pub fn build(b: *std.Build) void {
for (test_build.dependencies.items) |dep| {
const t = dep.cast(std.Build.Step.Compile) orelse continue;
const name = switch (t.root_module.root_source_file orelse continue) {
- .src_path => |p| std.fs.path.stem(p.sub_path),
+ .src_path => |p| if (std.mem.eql(u8, std.fs.path.basename(p.sub_path), "root.zig")) std.fs.path.basename(std.fs.path.dirname(p.sub_path).?) else std.fs.path.stem(p.sub_path),
else => t.name,
};
test_install.dependOn(&b.addInstallArtifact(t, .{ .dest_dir = .{ .override = .{ .custom = "test" } }, .dest_sub_path = name }).step);
diff --git a/build/core.zig b/build/core.zig
index 3b9eefa8..8749d612 100644
--- a/build/core.zig
+++ b/build/core.zig
@@ -284,6 +284,8 @@ pub const Parts = struct {
uucode: *std.Build.Module,
xitdb: *std.Build.Module,
doc_typ: *std.Build.Step.Options,
+ /// -Dembed-sources: the core embeds its sources for /src.
+ embed_sources: bool,
/// One options module for each value of `terminal`, `isolated` and
/// `on`, shared by every core.
term_on: *std.Build.Step.Options,
@@ -296,8 +298,9 @@ pub const Parts = struct {
/// Which core: its root and the few ways the products differ.
pub const Core = struct {
- /// src/main.zig for a shell, src/pardes.zig for the core, or a file
- /// whose tests run on the core's imports.
+ /// runtime/main.zig for a shell (runtime/macos.zig for the macOS
+ /// library), src/pardes.zig for the core, runtime/root.zig for the
+ /// runtime, or a core file whose tests run on the core's imports.
root: []const u8,
/// The shell's options (`pardes_config`): this build's, or the window's
/// in the bare build.
@@ -315,10 +318,21 @@ pub const Core = struct {
util: bool = false,
};
-/// A core module, everything it imports and links named here and nowhere else.
-pub fn module(b: *std.Build, p: Parts, c: Core) *std.Build.Module {
- const m = b.createModule(.{ .target = p.target, .optimize = p.optimize, .root_source_file = b.path(c.root), .link_libc = true });
- m.addImport("cloud9", p.cloud9);
+/// What `module` makes: the core and the runtime, each naming the other
+/// (`core`, `runtime`), and the module a compile roots at.
+pub const Modules = struct {
+ /// A product's own file (runtime/main.zig, runtime/macos.zig) naming
+ /// both, the runtime, or the core.
+ root: *std.Build.Module,
+ core: *std.Build.Module,
+ runtime: *std.Build.Module,
+};
+
+/// A core and the runtime beside it, everything they import and link
+/// named here and nowhere else.
+pub fn module(b: *std.Build, p: Parts, c: Core) Modules {
+ const in_runtime = std.mem.startsWith(u8, c.root, "runtime/");
+ const m = b.createModule(.{ .target = p.target, .optimize = p.optimize, .root_source_file = b.path(if (in_runtime) "src/pardes.zig" else c.root), .link_libc = true });
// forkpty: in libc proper on glibc>=2.34 and darwin; the BSDs keep it in libutil
if (c.util and (p.target.result.os.tag == .freebsd or p.target.result.os.tag == .netbsd or p.target.result.os.tag == .openbsd))
m.linkSystemLibrary("util", .{});
@@ -338,28 +352,47 @@ pub fn module(b: *std.Build, p: Parts, c: Core) *std.Build.Module {
});
m.link_libcpp = true;
};
- if (c.builtin_addons) if (p.pdf) |pdf| m.addImport("pdf_addon", pdf);
m.linkLibrary(p.zstd);
- if (c.builtin_addons) m.addImport("image_addon", p.image);
- if (c.terminal) {
- m.addImport("term", p.term);
- m.addOptions("term_options", p.term_on);
- } else m.addOptions("term_options", p.term_off);
- m.addImport("plain", p.plain);
- m.addImport("pardes_addon", p.kind);
- m.addImport("generated_themes", p.themes);
- p.ts.wire(m);
- m.addImport("mvzr", p.mvzr);
- m.addImport("c_heap", p.c_heap);
- m.addImport("vaxis", p.vaxis);
- m.addImport("uucode", p.uucode);
- m.addImport("xitdb", p.xitdb);
- // config.zig's test checks the words and keys docs/typ names exist.
- m.addOptions("doc_typ", p.doc_typ);
- m.addOptions("pardes_config", c.config);
- m.addOptions("pardes_isolation", if (c.isolated) p.iso_on else p.iso_off);
- m.addOptions("builtin_addons", if (c.builtin_addons) p.builtin_on else p.builtin_off);
- return m;
+ for (p.ts.libs.items) |lib| m.linkLibrary(lib);
+ // The /src tree's files that live outside the core's directory
+ // (fs.zig embeds them under the names they had there).
+ if (p.embed_sources) for ([_][]const u8{ "runtime/9p.zig", "runtime/9p_io.zig", "runtime/main.zig" }) |f|
+ m.addAnonymousImport(f, .{ .root_source_file = b.path(f) });
+ const runtime = b.createModule(.{ .target = p.target, .optimize = p.optimize, .root_source_file = b.path("runtime/root.zig"), .link_libc = true });
+ const root = if (!in_runtime) m else if (std.mem.eql(u8, c.root, "runtime/root.zig")) runtime else b.createModule(.{ .target = p.target, .optimize = p.optimize, .root_source_file = b.path(c.root), .link_libc = true });
+ // Each options module once, so that the modules share it: a file is in
+ // one module of a compilation.
+ const term_options = (if (c.terminal) p.term_on else p.term_off).createModule();
+ const ts_queries = if (p.ts.queries) |q| q.createModule() else null;
+ const doc_typ = p.doc_typ.createModule();
+ const pardes_config = c.config.createModule();
+ const pardes_isolation = (if (c.isolated) p.iso_on else p.iso_off).createModule();
+ const builtin_addons = (if (c.builtin_addons) p.builtin_on else p.builtin_off).createModule();
+ for ([_]*std.Build.Module{ m, runtime, root }) |x| {
+ x.addImport("cloud9", p.cloud9);
+ if (c.builtin_addons) if (p.pdf) |pdf| x.addImport("pdf_addon", pdf);
+ if (c.builtin_addons) x.addImport("image_addon", p.image);
+ if (c.terminal) x.addImport("term", p.term);
+ x.addImport("term_options", term_options);
+ x.addImport("plain", p.plain);
+ x.addImport("pardes_addon", p.kind);
+ x.addImport("generated_themes", p.themes);
+ if (p.ts.mod) |ts| x.addImport("tree-sitter", ts);
+ if (ts_queries) |q| x.addImport("ts_queries", q);
+ x.addImport("mvzr", p.mvzr);
+ x.addImport("c_heap", p.c_heap);
+ x.addImport("vaxis", p.vaxis);
+ x.addImport("uucode", p.uucode);
+ x.addImport("xitdb", p.xitdb);
+ // config.zig's test checks the words and keys docs/typ names exist.
+ x.addImport("doc_typ", doc_typ);
+ x.addImport("pardes_config", pardes_config);
+ x.addImport("pardes_isolation", pardes_isolation);
+ x.addImport("builtin_addons", builtin_addons);
+ x.addImport("core", m);
+ x.addImport("runtime", runtime);
+ }
+ return .{ .root = root, .core = m, .runtime = runtime };
}
/// What `assemble` makes besides the parts: the shells' options, the
@@ -598,6 +631,7 @@ pub fn assemble(b: *std.Build, c: struct {
.uucode = uucode_mod,
.xitdb = xitdb_mod,
.doc_typ = c.doc_typ,
+ .embed_sources = c.shell_cfg.embed_sources,
.term_on = term_on,
.term_off = term_off,
.iso_on = iso_on,
diff --git a/build/macos.zig b/build/macos.zig
index bcaf4d4c..7289e70a 100644
--- a/build/macos.zig
+++ b/build/macos.zig
@@ -22,6 +22,8 @@ pub fn add(b: *std.Build, c: struct {
.optimize = c.optimize,
});
c.root_mod.addImport("pardes.h", header.createModule());
+ // The app's watcher, which macos.zig's test reads beside its own.
+ c.root_mod.addAnonymousImport("macos/Sources/FileWatcher.swift", .{ .root_source_file = b.path("src/macos/Sources/FileWatcher.swift") });
const lib = b.addLibrary(.{
.name = "pardes",
diff --git a/build/process.zig b/build/process.zig
index 16f9b48b..d3ae9e68 100644
--- a/build/process.zig
+++ b/build/process.zig
@@ -15,16 +15,11 @@ pub fn add(b: *std.Build, opts: struct {
optimize: std.builtin.OptimizeMode,
ghostty_vt: ?*std.Build.Module,
cloud9: *std.Build.Module,
+ /// The runtime whose 9P client the runner speaks (build/core.zig `module`).
+ runtime: *std.Build.Module,
/// The build is the window's (-Dplatform=gui): the process tests drive it.
gui: bool = false,
}) void {
- const ninep_client = b.createModule(.{
- .target = opts.target,
- .optimize = opts.optimize,
- .root_source_file = b.path("src/9p_io.zig"),
- .link_libc = true,
- });
- ninep_client.addImport("cloud9", opts.cloud9);
const process_test = b.addExecutable(.{
.name = "pardes-process-test",
.root_module = b.createModule(.{
@@ -35,7 +30,8 @@ pub fn add(b: *std.Build, opts: struct {
}),
});
if (opts.ghostty_vt) |vt| process_test.root_module.addImport("ghostty-vt", vt);
- process_test.root_module.addImport("9p_io", ninep_client);
+ // The 9P client (runtime/9p_io.zig), through the runtime beside the core.
+ process_test.root_module.addImport("runtime", opts.runtime);
process_test.root_module.addImport("cloud9", opts.cloud9);
switch (opts.target.result.os.tag) {
.freebsd, .netbsd, .openbsd => process_test.root_module.linkSystemLibrary("util", .{}),
diff --git a/build/tests.zig b/build/tests.zig
index e0b9235a..2d43d743 100644
--- a/build/tests.zig
+++ b/build/tests.zig
@@ -9,7 +9,10 @@ const program = tools.program;
/// addon-test (and the addons it loads), kitty-test, the 9P roots.
pub fn add(b: *std.Build, c: struct {
addon_mod: *std.Build.Module,
- core_lean: *std.Build.Module,
+ /// The core without a terminal and the runtime beside it: core-test.
+ core_lean: core.Modules,
+ /// The shell's root, core and runtime: shell-test.
+ root_set: core.Modules,
core_module: *std.Build.Module,
/// core_module's configuration, for the test roots that run on its imports.
core_cfg: core.Core,
@@ -60,12 +63,15 @@ pub fn add(b: *std.Build, c: struct {
// The perf and fs bench programs' own tests: they compile no editor.
_ = units.add(b, units.root(b, "test/perf.zig", true, &.{.{ .name = "perf_options", .module = c.tools.perf_options.createModule() }}), null);
_ = units.add(b, units.root(b, "test/fs_bench.zig", null, &.{}), null);
- const core_test = b.addTest(.{ .root_module = c.core_lean, .filters = c.test_filters });
- const run_core_test = b.addRunArtifact(core_test);
- run_core_test.has_side_effects = true;
- const core_test_step = b.step("core-test", "run core tests without native shell tests, on the core without a terminal (a test that needs one skips)");
- core_test_step.dependOn(&run_core_test.step);
- if (testMatch(b, c.unit_profile, c.test_filters, core_test_step)) |check| check.addArtifactArg(core_test);
+ const core_test_step = b.step("core-test", "run core tests without native shell tests, on the core without a terminal (a test that needs one skips), and the runtime's beside it");
+ const core_match = testMatch(b, c.unit_profile, c.test_filters, core_test_step);
+ for ([_]*std.Build.Module{ c.core_lean.core, c.core_lean.runtime }) |m| {
+ const core_test = b.addTest(.{ .root_module = m, .filters = c.test_filters });
+ const run_core_test = b.addRunArtifact(core_test);
+ run_core_test.has_side_effects = true;
+ core_test_step.dependOn(&run_core_test.step);
+ if (core_match) |check| check.addArtifactArg(core_test);
+ }
// The terminal module's own tests (src/term/): the emulator without a core.
const run_term_test = units.add(b, b.addTest(.{ .root_module = c.parts.term, .filters = c.test_filters }), null);
b.step("term-test", "run the terminal module's own tests (src/term/)").dependOn(&run_term_test.step);
@@ -190,18 +196,18 @@ pub fn add(b: *std.Build, c: struct {
// stays reachable even when Zig's filter leaves the core's
// anonymous test-import block out.
for ([_]struct { path: []const u8, step: []const u8, about: []const u8, filters: []const []const u8 }{
- .{ .path = "src/9p_io.zig", .step = "9p-io-test", .about = "run native 9P transport and client integration tests", .filters = &.{ "Unix and TCP", "one fetch", "expired sessions", "posts itself" } },
+ .{ .path = "runtime/root.zig", .step = "9p-io-test", .about = "run native 9P transport and client integration tests", .filters = &.{ "Unix and TCP", "one fetch", "expired sessions", "posts itself" } },
.{ .path = "src/fs.zig", .step = "fs-unit-test", .about = "run filesystem unit tests", .filters = c.test_filters },
}) |t| {
var cfg = c.core_cfg;
cfg.root = t.path;
- const m = core.module(b, c.parts, cfg);
+ const m = core.module(b, c.parts, cfg).root;
b.step(t.step, t.about).dependOn(&b.addRunArtifact(b.addTest(.{ .root_module = m, .filters = t.filters })).step);
}
const cloud9: []const std.Build.Module.Import = &.{.{ .name = "cloud9", .module = c.parts.cloud9 }};
_ = units.add(b, units.root(b, "test/history.zig", false, cloud9), null);
- const protocol_tests = units.root(b, "src/9p.zig", false, cloud9);
+ const protocol_tests = units.root(b, "runtime/9p.zig", false, cloud9);
const protocol_step = b.step("9p-test", "run freestanding 9P protocol tests");
protocol_step.dependOn(&units.add(b, protocol_tests, null).step);
if (testMatch(b, c.unit_profile, c.test_filters, protocol_step)) |check| check.addArtifactArg(protocol_tests);
@@ -213,10 +219,11 @@ pub fn add(b: *std.Build, c: struct {
_ = units.add(b, units.root(b, "test/deck/replay.zig", null, &.{.{ .name = "deck", .module = b.createModule(.{ .target = c.target, .optimize = c.optimize, .root_source_file = b.path("src/gui/deck.zig") }) }}), null);
if (c.platform == .tui or c.platform == .gui) {
- const run_shell_test = units.add(b, b.addTest(.{ .root_module = c.root_mod, .filters = c.test_filters }), null);
// The native shell's tests alone, without the perf gate's
// ReleaseFast build: what a -Dtest-filter iteration wants.
- b.step("shell-test", "run the native shell's unit tests (src/main.zig's)").dependOn(&run_shell_test.step);
+ const shell_test_step = b.step("shell-test", "run the native shell's unit tests (runtime/main.zig's, and its core's and runtime's)");
+ for ([_]*std.Build.Module{ c.root_set.root, c.root_set.core, c.root_set.runtime }) |m|
+ shell_test_step.dependOn(&units.add(b, b.addTest(.{ .root_module = m, .filters = c.test_filters }), null).step);
const profile_test = b.addExecutable(.{
.name = "pardes-unit-profile-test",
.root_module = b.createModule(.{
diff --git a/build/tools.zig b/build/tools.zig
index 92217c4e..c6f25e6d 100644
--- a/build/tools.zig
+++ b/build/tools.zig
@@ -236,7 +236,7 @@ pub fn add(b: *std.Build, c: struct {
// a terminal: its tests reach the editor's modes (modal.zig).
var syntax_cfg = c.lean;
syntax_cfg.root = "src/syntax.zig";
- const syntax_module = core.module(b, c.parts, syntax_cfg);
+ const syntax_module = core.module(b, c.parts, syntax_cfg).root;
const syntax_runner = program(b, "pardes-syntax", "test/syntax.zig", c.target, c.optimize, &.{.{ .name = "syntax", .module = syntax_module }});
const run_syntax = b.addRunArtifact(syntax_runner);
run_syntax.addPassthruArgs();
diff --git a/src/9p.zig b/runtime/9p.zig
index 61715750..61715750 100644
--- a/src/9p.zig
+++ b/runtime/9p.zig
diff --git a/src/9p_io.zig b/runtime/9p_io.zig
index b557594a..acc851c4 100644
--- a/src/9p_io.zig
+++ b/runtime/9p_io.zig
@@ -5,8 +5,8 @@ const builtin = @import("builtin");
const ninep = @import("9p.zig");
const cloud9 = @import("cloud9");
const transport = cloud9.transport;
-const pardes = @import("pardes.zig");
-const limits = @import("memory.zig").limits;
+const pardes = @import("core");
+const limits = @import("core").memory.limits;
const log = std.log.scoped(.ninep);
const nowMs = transport.nowMs;
@@ -318,7 +318,7 @@ pub const Listener = struct {
// The errno a builtin's failure in the same words has; what
// that leaves EIO and says `no space` (a full disk under a
// Save) is ENOSPC.
- const said = @import("ninep/ctl.zig").failureErrno(late);
+ const said = @import("core").ctl.failureErrno(late);
const errno = if (said == pardes.ctlfs.E.IO and std.mem.indexOf(u8, late, "no space") != null) pardes.ctlfs.E.NOSPC else said;
const failed = pardes.ctlfs.failText(req.tag, errno, late);
// Its err record says it (the path in it), the one record: it
@@ -400,7 +400,7 @@ pub const Listener = struct {
}
misses += 1;
if (misses < 3) continue;
- if (h.done) core.fs.edit_hold = null else @import("edit_cmd.zig").cancel(core);
+ if (h.done) core.fs.edit_hold = null else @import("core").edit_cmd.cancel(core);
l.kick();
return;
}
@@ -672,7 +672,7 @@ pub const Listener = struct {
fn allocRunner() ?*Runner {
if (comptime !supported) return @constCast(&@as(Runner, {}));
const bytes = std.heap.page_allocator.rawAlloc(@sizeOf(Runner), .of(Runner), @returnAddress()) orelse return null;
- @import("memory.zig").sparse(bytes[0..@sizeOf(Runner)]);
+ @import("core").memory.sparse(bytes[0..@sizeOf(Runner)]);
return @ptrCast(@alignCast(bytes));
}
@@ -919,7 +919,7 @@ pub fn listen(io: std.Io, gpa: std.mem.Allocator, core: *pardes.Pardes, named: [
// then was refused.
// unreachable: checked above, before anything was made
const tmp = std.fmt.bufPrintSentinel(&tmp_buf, "{s}.{d}", .{ p, libc.getpid() }, 0) catch unreachable;
- const existing = @import("fs.zig").statPath(io, p, .{ .follow_symlinks = false }) catch null;
+ const existing = @import("core").filesystem.statPath(io, p, .{ .follow_symlinks = false }) catch null;
if (existing != null and existing.?.kind != .unix_domain_socket) {
log.warn("something is already listening on {s}", .{p});
return error.InUse;
@@ -1097,7 +1097,7 @@ const TempRuntime = struct {
if (t.old) |v| {
_ = setenv("XDG_RUNTIME_DIR", v, 1);
testing.allocator.free(v);
- } else _ = @import("host_io.zig").testUnsetenv("XDG_RUNTIME_DIR");
+ } else _ = @import("core").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("host_io.zig").ChildEnv;
+ const ChildEnv = @import("core").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("host_io.zig").ChildEnv.exportVar("PARDES_MOUNT", mount);
+ return @import("core").host_io.ChildEnv.exportVar("PARDES_MOUNT", mount);
} else |_| {}
}
- @import("host_io.zig").ChildEnv.exportVar("PARDES_MOUNT", null);
+ @import("core").host_io.ChildEnv.exportVar("PARDES_MOUNT", null);
}
pub const Client = struct {
@@ -2310,7 +2310,7 @@ test "a listening editor posts itself into the 9P registry and unposts on stop"
try testing.expectEqualStrings(sock, link[0..@intCast(n)]);
// A host path no fid names is swept, but never while a request is
// out in a syscall: it may be that request's, mid-walk.
- try p.fs.os_paths.append(gpa, .{ .node = @import("fs.zig").os_node | 1, .path = try gpa.dupe(u8, "/tmp") });
+ try p.fs.os_paths.append(gpa, .{ .node = @import("core").filesystem.os_node | 1, .path = try gpa.dupe(u8, "/tmp") });
pardes.turn.out = 1;
l.collectOs();
pardes.turn.out = 0;
@@ -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("host_io.zig").testUnsetenv(name);
+ } else _ = @import("core").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("host_io.zig").ChildEnv.exported("PARDES_MOUNT").?);
+ try testing.expectEqualStrings("/mnt/9p/pardes/work", @import("core").host_io.ChildEnv.exported("PARDES_MOUNT").?);
// A mount of another server (9ns --unix): not this session's.
- _ = @import("host_io.zig").testUnsetenv("NINE_MNTGEN");
+ _ = @import("core").host_io.testUnsetenv("NINE_MNTGEN");
exportMount("/run/user/1000/pardes-9p-work.sock");
- try testing.expect(@import("host_io.zig").ChildEnv.exported("PARDES_MOUNT") == null);
+ try testing.expect(@import("core").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("host_io.zig").testUnsetenv(name);
+ } else _ = @import("core").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("host_io.zig").testUnsetenv("XDG_RUNTIME_DIR");
+ _ = @import("core").host_io.testUnsetenv("XDG_RUNTIME_DIR");
_ = setenv("HOME", "/home/example", 1);
try testing.expectEqualStrings("/home/example/.local/state/pardes", socketDir(&dir).?);
- _ = @import("host_io.zig").testUnsetenv("HOME");
+ _ = @import("core").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("host_io.zig").ChildEnv.exported("PARDES_9P").?);
- try testing.expectEqualStrings("7", @import("host_io.zig").ChildEnv.exported("PARDES_PANE").?);
- try testing.expect(@import("host_io.zig").ChildEnv.exported("PARDES_PID") == null);
+ 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);
exportEnv(8, true);
- try testing.expectEqualStrings("8", @import("host_io.zig").ChildEnv.exported("PARDES_PANE").?);
- try testing.expectEqualStrings(own_pid, @import("host_io.zig").ChildEnv.exported("PARDES_PID").?);
+ 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").?);
// 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("host_io.zig").ChildEnv.exported("PARDES_9P") == null);
- try testing.expect(@import("host_io.zig").ChildEnv.exported("PARDES_PANE") == null);
- try testing.expectEqualStrings(own_pid, @import("host_io.zig").ChildEnv.exported("PARDES_PID").?);
+ 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").?);
exportEnv(0, false);
- try testing.expect(@import("host_io.zig").ChildEnv.exported("PARDES_9P") == null);
- try testing.expect(@import("host_io.zig").ChildEnv.exported("PARDES_PANE") == null);
- try testing.expect(@import("host_io.zig").ChildEnv.exported("PARDES_PID") == null);
+ 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);
}
diff --git a/src/addon_test.zig b/runtime/addon_test.zig
index 025d2e86..a08237fc 100644
--- a/src/addon_test.zig
+++ b/runtime/addon_test.zig
@@ -29,8 +29,8 @@
//! Word arg one of the kind's words, at its pane
//! # anything a comment, not printed
const std = @import("std");
-const pardes = @import("pardes.zig");
-const Kind = @import("Kind.zig");
+const pardes = @import("core");
+const Kind = @import("core").Kind;
const Pardes = pardes.Pardes;
pub fn main(io: std.Io, gpa: std.mem.Allocator, lib: []const u8, script_path: ?[]const u8) u8 {
diff --git a/src/crash.zig b/runtime/crash.zig
index 26e810ac..2ce43353 100644
--- a/src/crash.zig
+++ b/runtime/crash.zig
@@ -21,7 +21,7 @@
const std = @import("std");
const builtin = @import("builtin");
-const pardes = @import("pardes.zig");
+const pardes = @import("core");
/// The crash log's name, beside `init` in the configuration directory.
pub const name = "crashes";
@@ -182,7 +182,7 @@ pub fn record(msg: []const u8) void {
// what it said. That is the half a reporter cannot reconstruct afterwards.
w.print("panic: {s}\n", .{msg}) catch {};
var in_addon: [160]u8 = undefined;
- if (@import("Kind.zig").calling(&in_addon)) |where| w.print("{s}\n", .{where}) catch {};
+ if (@import("core").Kind.calling(&in_addon)) |where| w.print("{s}\n", .{where}) catch {};
// One `write(2)`, and the loop is for a short write rather than for a
// second record: `O_APPEND` puts it at the end whatever else is writing,
diff --git a/src/daemon.zig b/runtime/daemon.zig
index 55ffe376..6d96708d 100644
--- a/src/daemon.zig
+++ b/runtime/daemon.zig
@@ -27,7 +27,7 @@ const builtin = @import("builtin");
const libc = std.c;
const posix = std.posix;
const ninep_io = @import("9p_io.zig");
-const wire = @import("wire.zig");
+const wire = @import("core").wire;
const upgrade = @import("upgrade.zig");
const log = std.log.scoped(.replica);
diff --git a/src/macos.zig b/runtime/macos.zig
index 389a4b4a..f968597b 100644
--- a/src/macos.zig
+++ b/runtime/macos.zig
@@ -1,23 +1,23 @@
-const filesystem = @import("fs.zig");
-const ninep_io = @import("9p_io.zig");
+const filesystem = @import("core").filesystem;
+const ninep_io = @import("runtime").ninep_io;
const std = @import("std");
const builtin = @import("builtin");
const posix = std.posix;
const libc = std.c;
-const pardes = @import("pardes.zig");
-const dump = @import("dump.zig");
-const mouse = @import("mouse.zig");
-const colors = @import("colors.zig");
-const look = @import("look.zig");
+const pardes = @import("core");
+const dump = @import("core").dump;
+const mouse = @import("core").mouse;
+const colors = @import("core").colors;
+const look = @import("core").look;
const message = pardes.Messages.Message;
-const layout = @import("layout.zig");
-const file_watch = @import("file_watch.zig");
-const host_io = @import("host_io.zig");
-const fonts = @import("fonts.zig"); // the shared fallback preference order
-const tracy = @import("tracy.zig"); // no-op unless -Dtracy names a checkout
-const selection_pipe = @import("selection_pipe.zig"); // start, Response and Tasks
-const crash = @import("crash.zig");
+const layout = @import("core").layout;
+const file_watch = @import("core").file_watch;
+const host_io = @import("core").host_io;
+const fonts = @import("core").fonts; // the shared fallback preference order
+const tracy = @import("core").tracy; // no-op unless -Dtracy names a checkout
+const selection_pipe = @import("core").selection_pipe; // start, Response and Tasks
+const crash = @import("runtime").crash;
pub const panic = std.debug.FullPanic(struct {
fn call(msg: []const u8, ret_addr: ?usize) noreturn {
@@ -1401,7 +1401,7 @@ export fn pardes_tag_text_inset() u32 {
}
export fn pardes_grip_columns() u32 {
- return @import("config.zig").GUTTER;
+ return @import("core").config.GUTTER;
}
export fn pardes_tag_layer_limit() u32 {
diff --git a/src/main.zig b/runtime/main.zig
index 08edc0c1..85b3e249 100644
--- a/src/main.zig
+++ b/runtime/main.zig
@@ -1,9 +1,9 @@
const std = @import("std");
const builtin = @import("builtin");
-const pardes = @import("pardes.zig");
-const ninep_io = @import("9p_io.zig");
-const daemon = @import("daemon.zig");
-const upgrade = @import("upgrade.zig");
+const pardes = @import("core");
+const ninep_io = @import("runtime").ninep_io;
+const daemon = @import("runtime").daemon;
+const upgrade = @import("runtime").upgrade;
const cloud9 = @import("cloud9");
pub const std_options_debug_threaded_io: ?*std.Io.Threaded = std.Io.Threaded.global_single_threaded;
@@ -39,7 +39,7 @@ pub const panic = std.debug.FullPanic(struct {
pardes.replica.dying();
@import("vaxis").recover();
}
- @import("crash.zig").record(msg);
+ @import("runtime").crash.record(msg);
std.debug.defaultPanic(msg, ret_addr);
}
}.call);
@@ -226,7 +226,7 @@ fn die(io: std.Io, comptime fmt: []const u8, args: anytype) noreturn {
/// The second line is what a replica's build must share with its session's
/// (wire.zig `semantics`).
-const version_text = upgrade.version_line ++ "\n" ++ std.fmt.comptimePrint("semantics {x:0>16}\n", .{@import("wire.zig").semantics});
+const version_text = upgrade.version_line ++ "\n" ++ std.fmt.comptimePrint("semantics {x:0>16}\n", .{@import("core").wire.semantics});
const nested_text =
\\pardes: this shell is already inside pardes, and a pardes inside a pardes
@@ -591,13 +591,13 @@ fn writeHelpAll(w: *std.Io.Writer, t: *Tree) !void {
/// `fs` ask the same tree a session serves, through the same client. Never
/// stepped and never performing an effect: no shell, no file, no socket.
const Here = struct {
- const Engine = cloud9.fs.Server(pardes.ctlfs, .{ .fid_capacity = 32, .name_capacity = 255, .park_data_max = @import("9p.zig").msize - 23, .slot_capacity = 1 });
+ const Engine = cloud9.fs.Server(pardes.ctlfs, .{ .fid_capacity = 32, .name_capacity = 255, .park_data_max = @import("runtime").ninep.msize - 23, .slot_capacity = 1 });
core: *pardes.Pardes,
engine: Engine,
fd: c_int,
- in: [@import("9p.zig").msize]u8,
- out: [2 * @import("9p.zig").msize]u8,
- buf: [@import("9p.zig").msize]u8,
+ in: [@import("runtime").ninep.msize]u8,
+ out: [2 * @import("runtime").ninep.msize]u8,
+ buf: [@import("runtime").ninep.msize]u8,
/// Answers what comes until the other end hangs up. A request the core
/// parks (a read of /log) stays parked: the client's deadline ends it.
@@ -809,7 +809,7 @@ fn runCommand(init: std.process.Init, cmd: Cmd, all: []const [:0]const u8) noret
},
.version => version: {
out.writeAll(version_text) catch {};
- out.print("9p 9P2000 msize {d}\n", .{@import("9p.zig").msize}) catch {};
+ out.print("9p 9P2000 msize {d}\n", .{@import("runtime").ninep.msize}) catch {};
break :version 0;
},
.skill => skill: {
@@ -1127,7 +1127,7 @@ fn nativeMain(std_init: std.process.Init) !void {
const args = try init.minimal.args.toSlice(arena);
// An addon's author's test (addon_test.zig): nothing else.
if (args.len >= 3 and std.mem.eql(u8, args[1], "--addon-test"))
- std.process.exit(@import("addon_test.zig").main(init.io, init.gpa, args[2], if (args.len > 3) args[3] else null));
+ std.process.exit(@import("runtime").addon_test.main(init.io, init.gpa, args[2], if (args.len > 3) args[3] else null));
// The per-user daemon a session started (daemon.zig), or an upgrade of
// one with its registry: nothing else.
if (comptime daemon.supported) if (args.len >= 2 and args.len <= 3 and std.mem.eql(u8, args[1], "--daemon"))
@@ -1219,7 +1219,7 @@ fn nativeMain(std_init: std.process.Init) !void {
const dial = value orelse badArgs(init.io, "--9p-tcp needs tcp!<numeric-ip>!<port>", .{});
if (!std.mem.startsWith(u8, dial, "tcp!"))
badArgs(init.io, "--9p-tcp needs tcp!<numeric-ip>!<port>", .{});
- _ = @import("9p_io.zig").networkAddress(dial, true) catch
+ _ = @import("runtime").ninep_io.networkAddress(dial, true) catch
badArgs(init.io, "--9p-tcp needs tcp!<numeric-ip>!<port>", .{});
if (opts.ninep_tcp != null) badArgs(init.io, "--9p-tcp was specified twice", .{});
opts.ninep_tcp = dial;
@@ -1231,9 +1231,9 @@ fn nativeMain(std_init: std.process.Init) !void {
badArgs(init.io, "--mount needs name=dial", .{});
const name = mount[0..split];
const dial = mount[split + 1 ..];
- if (dial.len == 0 or !@import("fs.zig").validMountName(name))
+ if (dial.len == 0 or !@import("core").filesystem.validMountName(name))
badArgs(init.io, "invalid mount name or dial: '{s}'", .{mount});
- @import("9p_io.zig").Client.validateDial(dial) catch
+ @import("runtime").ninep_io.Client.validateDial(dial) catch
badArgs(init.io, "invalid mount dial: '{s}'", .{dial});
for (mounts[0..mounts_len]) |existing| if (std.mem.eql(u8, existing.name, name))
badArgs(init.io, "duplicate mount name: '{s}'", .{name});
@@ -1371,7 +1371,7 @@ fn nativeMain(std_init: std.process.Init) !void {
// `pardes '~/x'`, quoted so the shell left it: home, as a look's.
var home_buf: [4096]u8 = undefined;
const word = pardes.filesystem.expandHome(typed_word, &home_buf);
- const target = @import("look.zig").parsePathLine(word);
+ const target = @import("core").look.parsePathLine(word);
// `@pN[:addr]` addresses a pane of this session: one it has is
// looked at, one it has not is refused, never a file of that name.
if (std.mem.startsWith(u8, target.path, pardes.config.pane_addr)) {
@@ -1455,7 +1455,7 @@ fn nativeMain(std_init: std.process.Init) !void {
positional = null;
};
if (positional) |a| {
- const target = @import("look.zig").parsePathLine(a);
+ const target = @import("core").look.parsePathLine(a);
if (std.mem.eql(u8, target.path, "/n") or std.mem.startsWith(u8, target.path, "/n/") or
std.mem.eql(u8, target.path, "/virtual") or std.mem.startsWith(u8, target.path, "/virtual/"))
{
@@ -1466,7 +1466,7 @@ fn nativeMain(std_init: std.process.Init) !void {
const cwd = cwdbuf[0 .. std.process.currentPath(init.io, &cwdbuf) catch
badArgs(init.io, "this shell's working directory is gone; cd somewhere that exists", .{})];
var realbuf: [4096]u8 = undefined;
- switch (@import("look.zig").resolve(null, a, cwd, &realbuf)) {
+ switch (@import("core").look.resolve(null, a, cwd, &realbuf)) {
.file => |t| {
opts.file = try arena.dupe(u8, t.path);
opts.file_line = t.at.line;
@@ -1495,7 +1495,7 @@ fn nativeMain(std_init: std.process.Init) !void {
opts.config_dir = found.dir;
opts.state = .disk;
opts.recent_import = oldRecentDir(arena, init.environ_map);
- if (found.dir) |d| @import("crash.zig").setDir(d);
+ if (found.dir) |d| @import("runtime").crash.setDir(d);
if (attach) |name| if (std.mem.lastIndexOfScalar(u8, name, ':')) |colon| {
attachClient(init, opts, name[0..colon], name[colon + 1 ..]);
};
@@ -1537,7 +1537,7 @@ fn nativeMain(std_init: std.process.Init) !void {
opts.rows = 50;
}
const kind: daemon.Kind = if (pardes.platform == .gui) .gui else .tty;
- var term: @import("tui/tui.zig").Term = if (detach != null) .detached else .open;
+ var term: @import("core").tui.Term = if (detach != null) .detached else .open;
var detached = detach != null;
upgrade.remember(args);
if (upgrade.resumed) |*rec| {
@@ -1583,7 +1583,7 @@ fn nativeMain(std_init: std.process.Init) !void {
defer daemon.quit();
errdefer daemon.tellStubExit(1);
switch (pardes.platform) {
- .tui => @import("tui/tui.zig").run(init, opts, term) catch |err| switch (err) {
+ .tui => @import("core").tui.run(init, opts, term) catch |err| switch (err) {
// No controlling terminal (a detached pty, a daemon): said, not
// an error trace.
error.NoDevice => {
@@ -1592,7 +1592,7 @@ fn nativeMain(std_init: std.process.Init) !void {
},
else => return err,
},
- .gui => try @import("gui/gui.zig").run(init, opts, detached),
+ .gui => try @import("core").gui.run(init, opts, detached),
.macos => unreachable,
}
daemon.tellStubExit(0);
@@ -1692,8 +1692,8 @@ fn commOf(io: std.Io, pid: []const u8, buf: *[64]u8) []const u8 {
/// window's (gui.zig).
fn clientOf(init: std.process.Init, opts: pardes.Options, path: []const u8, name: []const u8, far: bool) !void {
switch (pardes.platform) {
- .tui => try @import("tui/tui.zig").runClient(init, opts, path, name, far),
- .gui => try @import("gui/gui.zig").runClient(init, opts, path, name, far),
+ .tui => try @import("core").tui.runClient(init, opts, path, name, far),
+ .gui => try @import("core").gui.runClient(init, opts, path, name, far),
else => unreachable,
}
}
@@ -1915,25 +1915,12 @@ test "tcgetattr writes nothing past a Zig termios" {
test {
_ = pardes.config.User;
- _ = @import("crash.zig");
- _ = @import("memory.zig");
- _ = @import("locations.zig");
- _ = @import("fs.zig");
- _ = @import("wire.zig");
- _ = @import("vaxis_input.zig");
- _ = @import("daemon.zig");
- _ = @import("9p_io.zig");
- _ = @import("9p_io.zig").Client;
- _ = @import("host_io.zig");
- _ = @import("host_io.zig").Shell;
- _ = @import("host_io.zig").Lsp;
- // Its tests too: imported by the hosts only, it was never collected.
- _ = @import("file_watch.zig");
- _ = @import("lsp/lsp_client.zig");
- _ = @import("lsp/lsp.zig");
+ // The rest this block collected is collected where it lives now: the
+ // runtime's files by runtime/root.zig's test block, the core's (the
+ // frontends among them) by pardes.zig's. The window stays named: its
+ // C's allocator (ui_malloc and the rest) is gui.zig's.
if (comptime pardes.platform == .tui) {
- _ = @import("tui/tui.zig");
+ _ = @import("core").tui;
}
- if (comptime pardes.platform == .gui) _ = @import("gui/gui.zig");
- if (comptime pardes.font_picker) _ = @import("fonts.zig");
+ if (comptime pardes.platform == .gui) _ = @import("core").gui;
}
diff --git a/runtime/root.zig b/runtime/root.zig
new file mode 100644
index 00000000..86fd9a75
--- /dev/null
+++ b/runtime/root.zig
@@ -0,0 +1,26 @@
+//! What runs a session: the daemon and a session's link to it, the
+//! upgrade, the crash file, `--addon-test`, the 9P listener and client
+//! (9p_io) over cloud9's options (9p). Module `runtime`; a product's root
+//! (main.zig, macos.zig) sits beside it as a module of its own, naming it
+//! and `core`.
+pub const daemon = @import("daemon.zig");
+pub const upgrade = @import("upgrade.zig");
+pub const crash = @import("crash.zig");
+pub const addon_test = @import("addon_test.zig");
+pub const ninep_io = @import("9p_io.zig");
+pub const ninep = @import("9p.zig");
+
+test {
+ _ = daemon;
+ _ = upgrade;
+ _ = ninep_io;
+ _ = ninep_io.Client;
+ _ = ninep;
+ // main.zig's test block collected the crash file's: a shell's build
+ // (shell-test); the core without a terminal (core-test) never compiled it.
+ if (comptime @import("term_options").terminal) _ = crash;
+ // A window's build links the window's C (font.c over FreeType and
+ // HarfBuzz) into each of its programs, and their allocator (ui_malloc
+ // and the rest) is gui.zig's.
+ if (comptime @import("term_options").terminal and @import("pardes_config").platform == .gui) _ = @import("core").gui;
+}
diff --git a/src/skill.txt b/runtime/skill.txt
index 8ae6a15a..8ae6a15a 100644
--- a/src/skill.txt
+++ b/runtime/skill.txt
diff --git a/src/upgrade.zig b/runtime/upgrade.zig
index 460169e7..e145eb70 100644
--- a/src/upgrade.zig
+++ b/runtime/upgrade.zig
@@ -18,7 +18,7 @@ const builtin = @import("builtin");
/// libc: exec of the new build with fds held across it, and /proc/self/exe opened before it.
const libc = std.c;
const posix = std.posix;
-const pardes = @import("pardes.zig");
+const pardes = @import("core");
pub const supported = builtin.os.tag == .linux or builtin.os.tag == .freebsd;
pub const flag = "--upgraded=";
diff --git a/src/Handover.zig b/src/Handover.zig
index 8eb29d5d..b8491978 100644
--- a/src/Handover.zig
+++ b/src/Handover.zig
@@ -24,7 +24,7 @@ const builtin = @import("builtin");
const pardes = @import("pardes.zig");
const layout = @import("layout.zig");
const dump = @import("dump.zig");
-const ninep_io = @import("9p_io.zig");
+const ninep_io = @import("runtime").ninep_io;
const panes = @import("panes.zig");
const tagline = @import("tagline.zig");
const walk = @import("walk.zig");
diff --git a/src/Output.zig b/src/Output.zig
index 2e49ceb3..8f49fa4e 100644
--- a/src/Output.zig
+++ b/src/Output.zig
@@ -889,7 +889,7 @@ pub fn openBuild(p: *Pardes, id: usize) !void {
var out: std.Io.Writer.Allocating = .init(p.gpa);
errdefer out.deinit();
const w = &out.writer;
- try w.print("{s}\n", .{@import("upgrade.zig").version_line});
+ try w.print("{s}\n", .{@import("runtime").upgrade.version_line});
try w.print("commit {s}\nchange {s}\nbuilt {s}\n", .{
build_options.commit orelse "not stamped (a Debug build with -Dplatform or --prefix)",
build_options.change orelse "not stamped",
diff --git a/src/builtins.zig b/src/builtins.zig
index 0e8610ae..02718ff0 100644
--- a/src/builtins.zig
+++ b/src/builtins.zig
@@ -593,7 +593,7 @@ pub const Mount = struct {
};
// A mount that cannot be reached is said now, and taken back, not
// found out by the first look through it.
- const reached = pardes.tape.site(.probe, null, @import("9p_io.zig").Client.probeMount, .{ c.p.gpa, dial });
+ const reached = pardes.tape.site(.probe, null, @import("runtime").ninep_io.Client.probeMount, .{ c.p.gpa, dial });
reached catch |err| {
if (c.p.fs.mounts.pop()) |gone| {
c.p.gpa.free(gone.name);
diff --git a/src/fs.zig b/src/fs.zig
index dab7c8dd..d352866e 100644
--- a/src/fs.zig
+++ b/src/fs.zig
@@ -5,7 +5,7 @@ const libc = std.c;
const pardes = @import("pardes.zig");
const config = @import("config.zig");
const lsp = @import("lsp/lsp.zig");
-const ninep_io = @import("9p_io.zig");
+const ninep_io = @import("runtime").ninep_io;
const panes = @import("panes.zig");
const modal = @import("modal.zig");
const look = @import("look.zig");
@@ -58,11 +58,11 @@ const source_files = [_]Source{
.{ .path = "src/layout.zig", .contents = @embedFile("layout.zig") },
.{ .path = "src/fs.zig", .contents = @embedFile("fs.zig") },
.{ .path = "src/look.zig", .contents = @embedFile("look.zig") },
- .{ .path = "src/9p.zig", .contents = @embedFile("9p.zig") },
- .{ .path = "src/9p_io.zig", .contents = @embedFile("9p_io.zig") },
+ .{ .path = "src/9p.zig", .contents = @embedFile("runtime/9p.zig") },
+ .{ .path = "src/9p_io.zig", .contents = @embedFile("runtime/9p_io.zig") },
.{ .path = "src/host_io.zig", .contents = @embedFile("host_io.zig") },
.{ .path = "src/config.zig", .contents = @embedFile("config.zig") },
- .{ .path = "src/main.zig", .contents = @embedFile("main.zig") },
+ .{ .path = "src/main.zig", .contents = @embedFile("runtime/main.zig") },
.{ .path = "src/builtins.zig", .contents = @embedFile("builtins.zig") },
.{ .path = "src/grammar_manifest.zig", .contents = @embedFile("grammar_manifest.zig") },
.{ .path = "src/CHANGELOG.md", .contents = @embedFile("CHANGELOG.md") },
diff --git a/src/gui/gui.zig b/src/gui/gui.zig
index 4f6a58c2..c772ac1d 100644
--- a/src/gui/gui.zig
+++ b/src/gui/gui.zig
@@ -27,10 +27,10 @@ const fonts = @import("../fonts.zig"); // the fallback faces
const selection_pipe = @import("../selection_pipe.zig");
const c_heap = @import("c_heap");
-const ninep_io = @import("../9p_io.zig");
+const ninep_io = @import("runtime").ninep_io;
-const daemon = @import("../daemon.zig");
-const upgrade = @import("../upgrade.zig");
+const daemon = @import("runtime").daemon;
+const upgrade = @import("runtime").upgrade;
const replica = @import("../replica.zig");
const tracy = @import("../tracy.zig");
diff --git a/src/host_io.zig b/src/host_io.zig
index d199c839..cadcc1d2 100644
--- a/src/host_io.zig
+++ b/src/host_io.zig
@@ -5,11 +5,11 @@ const posix = std.posix;
const libc = std.c;
const pardes = @import("pardes.zig");
const selection_pipe = @import("selection_pipe.zig");
-const ninep_io = @import("9p_io.zig");
+const ninep_io = @import("runtime").ninep_io;
const filesystem = @import("fs.zig");
const file_watch = @import("file_watch.zig");
const replica = @import("replica.zig");
-const daemon = @import("daemon.zig");
+const daemon = @import("runtime").daemon;
const panes = @import("panes.zig");
pub const Host = struct {
@@ -1195,7 +1195,7 @@ pub const Shell = struct {
const pid = rcPid(name) orelse continue;
// This pid's are this process's, but in an upgraded one: those
// were its old image's (upgrade.zig), and its own come after.
- if (pid == std.c.getpid() and @import("upgrade.zig").resumed == null) continue;
+ if (pid == std.c.getpid() and @import("runtime").upgrade.resumed == null) continue;
if (pid != std.c.getpid() and std.posix.errno(std.c.kill(pid, @fromBackingInt(@intCast(0)))) != .SRCH) continue;
if (name.len >= 64 or n == dead.len) continue;
@memcpy(dead[n][0..name.len], name);
@@ -2188,7 +2188,7 @@ pub fn forkShell(
ninep_io.setCloexec(master);
// The daemon keeps a dup: this session killed outright never hangs the
// shell up (daemon.zig).
- @import("daemon.zig").pty(pid, master);
+ @import("runtime").daemon.pty(pid, master);
if (core) |c| c.acknowledgeShell(pane, std.mem.span(spawn.path), one_line == null and spawn.argv[1] != null);
return .{ .file = .{ .handle = master, .flags = .{ .nonblocking = false } }, .pid = pid };
}
diff --git a/src/look.zig b/src/look.zig
index 62f6a7da..2ca4afc3 100644
--- a/src/look.zig
+++ b/src/look.zig
@@ -1414,7 +1414,7 @@ fn lookOpenFailed(p: *Pardes, id: usize, path: []const u8, err: anyerror) void {
var cut: [miss_path_cap + "…".len]u8 = undefined;
// Not there, on a peer's mount as on this host: a miss, the write
// answered, as any path to no file is.
- const remote_missing = err == error.Remote and std.mem.indexOf(u8, @import("9p_io.zig").Client.lastSaid(), "not exist") != null;
+ const remote_missing = err == error.Remote and std.mem.indexOf(u8, @import("runtime").ninep_io.Client.lastSaid(), "not exist") != null;
if (err == error.FileNotFound or err == error.NotFound or remote_missing)
return missed(p, id, "{s}: no such file", .{missText(path, &cut)});
var said: Kind.Buf(miss_path_cap + 16) = .{};
diff --git a/src/ninep/tree.zig b/src/ninep/tree.zig
index 73468ef8..43d1a272 100644
--- a/src/ninep/tree.zig
+++ b/src/ninep/tree.zig
@@ -23,7 +23,7 @@ const layout = pardes.layout;
pub const pty = @import("pty.zig");
pub const sources = @import("sources.zig");
pub const screen = @import("screen.zig");
-const daemon = @import("../daemon.zig");
+const daemon = @import("runtime").daemon;
const panes = @import("../panes.zig");
const Plumb = @import("../Plumb.zig");
diff --git a/src/pardes.zig b/src/pardes.zig
index 0bedab03..061c0efc 100644
--- a/src/pardes.zig
+++ b/src/pardes.zig
@@ -12,7 +12,7 @@ pub const Plumb = @import("Plumb.zig");
pub const filesystem = @import("fs.zig");
pub const ctlfs = @import("ninep/tree.zig");
pub const syntax = @import("syntax.zig");
-const tracy = @import("tracy.zig");
+pub const tracy = @import("tracy.zig");
pub const panes = @import("panes.zig");
const locations = @import("locations.zig");
pub const tagline = @import("tagline.zig");
@@ -72,7 +72,7 @@ pub const builtins = @import("builtins.zig");
/// Every builtin as JSON, for the docs (tools/gen_builtins_json.zig).
pub const builtins_json = @import("builtins_json.zig");
const limits = memory.limits;
-const selection_pipe = @import("selection_pipe.zig");
+pub const selection_pipe = @import("selection_pipe.zig");
pub const config = @import("config.zig");
pub const memory = @import("memory.zig");
pub const tape = @import("tape.zig");
@@ -88,6 +88,12 @@ pub const keys = @import("keys.zig");
pub const Addon = @import("Addon.zig");
pub const dump = @import("dump.zig");
pub const lsp = @import("lsp/lsp.zig");
+/// What the runtime's files name of the core beside the above (9p_io).
+pub const ctl = @import("ninep/ctl.zig");
+pub const edit_cmd = @import("edit_cmd.zig");
+/// The frontends, named by the product's root (runtime/main.zig).
+pub const tui = @import("tui/tui.zig");
+pub const gui = @import("gui/gui.zig");
pub const host_io = @import("host_io.zig");
pub const file_watch = @import("file_watch.zig");
pub const Host = host_io.Host;
@@ -425,7 +431,6 @@ test {
_ = @import("body_layer.zig");
_ = @import("draw.zig");
_ = @import("dump.zig"); // its tests ran nowhere before
- _ = @import("upgrade.zig");
_ = @import("recent.zig");
_ = @import("Store.zig");
_ = @import("Db.zig");
@@ -438,4 +443,11 @@ test {
_ = @import("Handover.zig");
_ = @import("walk.zig");
_ = @import("views.zig");
+ // The frontends', which main.zig's test block collected: a shell's
+ // build (shell-test); the core without a terminal never compiled them.
+ if (comptime @import("term_options").terminal) {
+ if (comptime platform == .tui) _ = @import("tui/tui.zig");
+ if (comptime platform == .gui) _ = @import("gui/gui.zig");
+ _ = @import("vaxis_input.zig");
+ }
}
diff --git a/src/replica.zig b/src/replica.zig
index 2b7590ed..8b7cdaf3 100644
--- a/src/replica.zig
+++ b/src/replica.zig
@@ -28,7 +28,7 @@ const tape = @import("tape.zig");
const rollback = @import("rollback.zig");
const walk = @import("walk.zig");
const wire = @import("wire.zig");
-const daemon = @import("daemon.zig");
+const daemon = @import("runtime").daemon;
const writeAll = daemon.writeAll;
const c_heap = @import("c_heap");
const Term = pardes.Term;
diff --git a/src/tui/tui.zig b/src/tui/tui.zig
index 5714ea0c..cb709ff1 100644
--- a/src/tui/tui.zig
+++ b/src/tui/tui.zig
@@ -14,10 +14,10 @@ const look = @import("../look.zig");
const message = pardes.Messages.Message;
const file_watch = @import("../file_watch.zig");
const selection_pipe = @import("../selection_pipe.zig");
-const ninep_io = @import("../9p_io.zig");
-const daemon = @import("../daemon.zig");
+const ninep_io = @import("runtime").ninep_io;
+const daemon = @import("runtime").daemon;
const host_io = @import("../host_io.zig");
-const upgrade = @import("../upgrade.zig");
+const upgrade = @import("runtime").upgrade;
const replica = @import("../replica.zig");
extern "c" fn setenv(name: [*:0]const u8, value: [*:0]const u8, overwrite: c_int) c_int;
diff --git a/test/process.zig b/test/process.zig
index 9fad315b..254aac22 100644
--- a/test/process.zig
+++ b/test/process.zig
@@ -6,7 +6,7 @@
const std = @import("std");
const libc = std.c;
const eh = @import("e2e_harness.zig");
-const Client = @import("9p_io").Client;
+const Client = @import("runtime").ninep_io.Client;
const c9 = @import("cloud9");
extern "c" fn setenv(name: [*:0]const u8, value: [*:0]const u8, overwrite: c_int) c_int;