diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-18 21:23:22 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-18 21:43:03 -0300 |
| commit | f9a3179542012ec1a700e2020ac9f616b819f972 (patch) | |
| tree | 73f4cb241876196331f7b28c9f773301bd341a7f /build | |
| parent | a75956bb3443aa8aac778d2ff12c42f5ef99e0e9 (diff) | |
| download | pardes-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 'build')
| -rw-r--r-- | build/core.zig | 17 | ||||
| -rw-r--r-- | build/gui.zig | 14 | ||||
| -rw-r--r-- | build/macos.zig | 18 | ||||
| -rw-r--r-- | build/tests.zig | 16 |
4 files changed, 34 insertions, 31 deletions
diff --git a/build/core.zig b/build/core.zig index 8749d612..56a047c0 100644 --- a/build/core.zig +++ b/build/core.zig @@ -318,18 +318,19 @@ pub const Core = struct { util: bool = false, }; -/// What `module` makes: the core and the runtime, each naming the other -/// (`core`, `runtime`), and the module a compile roots at. +/// What `module` makes: the core, the devices and the runtime, each naming +/// the others (`core`, `dev`, `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, + dev: *std.Build.Module, runtime: *std.Build.Module, }; -/// A core and the runtime beside it, everything they import and link -/// named here and nowhere else. +/// A core and the devices and 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 }); @@ -356,9 +357,10 @@ pub fn module(b: *std.Build, p: Parts, c: Core) Modules { 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| + if (p.embed_sources) for ([_][]const u8{ "runtime/9p.zig", "runtime/9p_io.zig", "runtime/main.zig", "dev/host_io.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 dev = b.createModule(.{ .target = p.target, .optimize = p.optimize, .root_source_file = b.path("dev/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. @@ -368,7 +370,7 @@ pub fn module(b: *std.Build, p: Parts, c: Core) Modules { 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| { + for ([_]*std.Build.Module{ m, dev, 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); @@ -390,9 +392,10 @@ pub fn module(b: *std.Build, p: Parts, c: Core) Modules { x.addImport("pardes_isolation", pardes_isolation); x.addImport("builtin_addons", builtin_addons); x.addImport("core", m); + x.addImport("dev", dev); x.addImport("runtime", runtime); } - return .{ .root = root, .core = m, .runtime = runtime }; + return .{ .root = root, .core = m, .dev = dev, .runtime = runtime }; } /// What `assemble` makes besides the parts: the shells' options, the diff --git a/build/gui.zig b/build/gui.zig index cc90bd0a..bec26c0c 100644 --- a/build/gui.zig +++ b/build/gui.zig @@ -30,7 +30,7 @@ pub const Window = struct { gm.addIncludePath(sdl.include); if (w.sketchbook) |sb| { gm.addImport("gui_c", sb.module("c")); - gm.addImport("dev", sb.module("dev")); + gm.addImport("sketchbook", sb.module("dev")); } if (sdl.trackpad) |object| { gm.addObjectFile(object); @@ -47,7 +47,7 @@ pub const Window = struct { gm.addRPath(.{ .cwd_relative = "/usr/local/lib" }); if (w.sketchbook) |sb| gm.addCSourceFile(.{ .file = sb.namedLazyPath("font.c") }); // the embedded UI font: provided as a build import since assets/ lives - // outside the src/ module root (@embedFile can't escape it) + // outside the dev/ module root (@embedFile can't escape it) gm.addAnonymousImport("AdwaitaMono-Regular.ttf", .{ .root_source_file = b.path("assets/AdwaitaMono-Regular.ttf"), }); @@ -77,7 +77,7 @@ pub fn make(b: *std.Build, target: std.Build.ResolvedTarget, optimize: std.lang. \\#include "macos_trackpad.h" \\ ); - const include: []const std.Build.LazyPath = &.{ dep.path("include"), b.path("src/gui") }; + const include: []const std.Build.LazyPath = &.{ dep.path("include"), b.path("dev/gui") }; w.sketchbook = b.lazyDependency("sketchbook", .{ .target = target, .optimize = optimize, .@"c-header" = header, .@"c-include" = include, .@"prebuilt-shaders" = prebuilt_shaders }); var sdl: Window.Sdl = .{ .lib = sdl_lib, .include = dep.path("include") }; if (target.result.os.tag == .macos) { @@ -85,9 +85,9 @@ pub fn make(b: *std.Build, target: std.Build.ResolvedTarget, optimize: std.lang. const shim = b.addSystemCommand(&.{ "xcrun", "clang", "-fobjc-arc", "-O2", "-target", b.fmt("{s}-apple-macos13.0", .{arch}), "-I" }); shim.addDirectoryArg(dep.path("include")); shim.addArg("-c"); - shim.addFileArg(b.path("src/gui/macos_trackpad.m")); + shim.addFileArg(b.path("dev/gui/macos_trackpad.m")); // Header changes invalidate the independently compiled adapter. - shim.addFileInput(b.path("src/gui/macos_trackpad.h")); + shim.addFileInput(b.path("dev/gui/macos_trackpad.h")); shim.addArg("-o"); sdl.trackpad = shim.addOutputFileArg("macos_trackpad.o"); } @@ -136,8 +136,8 @@ pub fn make(b: *std.Build, target: std.Build.ResolvedTarget, optimize: std.lang. const adapter_test = b.addSystemCommand(&.{ "xcrun", "clang", "-fobjc-arc", "-O1", "-framework", "Cocoa", "-I" }); adapter_test.addDirectoryArg(sdl.include); adapter_test.addFileArg(b.path("test/macos_trackpad.m")); - adapter_test.addFileInput(b.path("src/gui/macos_trackpad.m")); - adapter_test.addFileInput(b.path("src/gui/macos_trackpad.h")); + adapter_test.addFileInput(b.path("dev/gui/macos_trackpad.m")); + adapter_test.addFileInput(b.path("dev/gui/macos_trackpad.h")); adapter_test.addArg("-o"); const adapter_bin = adapter_test.addOutputFileArg("macos-trackpad-test"); const run_adapter = std.Build.Step.Run.create(b, "run macos-trackpad-test"); diff --git a/build/macos.zig b/build/macos.zig index 7289e70a..b865740e 100644 --- a/build/macos.zig +++ b/build/macos.zig @@ -23,7 +23,7 @@ pub fn add(b: *std.Build, c: struct { }); 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") }); + c.root_mod.addAnonymousImport("macos/Sources/FileWatcher.swift", .{ .root_source_file = b.path("dev/macos/Sources/FileWatcher.swift") }); const lib = b.addLibrary(.{ .name = "pardes", @@ -68,7 +68,7 @@ pub fn add(b: *std.Build, c: struct { "ScenePostprocessor.swift", "FileWatcher.swift", }) |src| - link.addFileArg(b.path(b.fmt("src/macos/Sources/{s}", .{src}))); + link.addFileArg(b.path(b.fmt("dev/macos/Sources/{s}", .{src}))); link.addFileArg(lib_archive); link.addArgs(&.{ "-lc++", @@ -86,17 +86,17 @@ pub fn add(b: *std.Build, c: struct { const icon_build = b.addSystemCommand(&.{ "swiftc", "-O", "-target", triple, "-o" }); const icon_bin = icon_build.addOutputFileArg("pardes-icon"); - icon_build.addFileArg(b.path("src/macos/icon.swift")); + icon_build.addFileArg(b.path("dev/macos/icon.swift")); const icon_run = std.Build.Step.Run.create(b, "pardes-icon"); icon_run.addFileArg(icon_bin); - icon_run.addFileArg(b.path("src/macos/icon.png")); + icon_run.addFileArg(b.path("dev/macos/icon.png")); const icon_dir = icon_run.addOutputDirectoryArg("Resources"); const plist = b.addSystemCommand(&.{ "plutil", "-replace", "LSMinimumSystemVersion", "-string", min_version, "-o", }); const plist_out = plist.addOutputFileArg("Info.plist"); - plist.addFileArg(b.path("src/macos/Info.plist")); + plist.addFileArg(b.path("dev/macos/Info.plist")); const version_plist = b.addSystemCommand(&.{ "plutil", "-replace", "CFBundleShortVersionString", "-string", display_version, "-o", @@ -149,10 +149,10 @@ pub fn add(b: *std.Build, c: struct { e2e.addArg("-o"); const e2e_bin = e2e.addOutputFileArg("pardes-macos-e2e"); for ([_][]const u8{ - "src/macos/Sources/PardesView.swift", - "src/macos/Sources/ScenePostprocessor.swift", - "src/macos/Sources/FileWatcher.swift", - "src/macos/Sources/AppDelegate.swift", + "dev/macos/Sources/PardesView.swift", + "dev/macos/Sources/ScenePostprocessor.swift", + "dev/macos/Sources/FileWatcher.swift", + "dev/macos/Sources/AppDelegate.swift", "test/macos_e2e.swift", }) |source| e2e.addFileArg(b.path(source)); e2e.addFileArg(lib_archive); diff --git a/build/tests.zig b/build/tests.zig index 2d43d743..d351684d 100644 --- a/build/tests.zig +++ b/build/tests.zig @@ -9,9 +9,9 @@ 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, - /// The core without a terminal and the runtime beside it: core-test. + /// The core without a terminal and the devices and runtime beside it: core-test. core_lean: core.Modules, - /// The shell's root, core and runtime: shell-test. + /// The shell's root, core, devices 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. @@ -63,9 +63,9 @@ 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_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_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 devices' 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| { + for ([_]*std.Build.Module{ c.core_lean.core, c.core_lean.dev, 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; @@ -211,18 +211,18 @@ pub fn add(b: *std.Build, c: struct { 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); - _ = units.add(b, units.root(b, "src/fonts.zig", true, cloud9), null); + _ = units.add(b, units.root(b, "dev/fonts.zig", true, cloud9), null); _ = units.add(b, units.root(b, "src/c_heap.zig", false, cloud9), null); // Its lookup goes wrong only where the optimizer folds it. _ = units.add(b, b.addTest(.{ .root_module = b.createModule(.{ .target = c.target, .optimize = .safe, .root_source_file = b.path("src/c_heap.zig"), .link_libc = false, .imports = cloud9 }), .filters = c.test_filters }), null); - _ = 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); + _ = 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("dev/gui/deck.zig") }) }}), null); if (c.platform == .tui or c.platform == .gui) { // The native shell's tests alone, without the perf gate's // ReleaseFast build: what a -Dtest-filter iteration wants. - 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| + const shell_test_step = b.step("shell-test", "run the native shell's unit tests (runtime/main.zig's, and its core's, devices' and runtime's)"); + for ([_]*std.Build.Module{ c.root_set.root, c.root_set.core, c.root_set.dev, 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", |
