summaryrefslogtreecommitdiff
path: root/build
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-20 06:33:52 -0300
committerGabriel Schneider <[email protected]>2026-11-20 06:33:53 -0300
commitffe05cceb897b3ae6a6d36491f9318a8aa3426e7 (patch)
tree352414579559060b3e8486af34e29d49fd5df781 /build
parent5b7124d10f9b2db8d1c5e99eacb9b6d2fffff0cc (diff)
parenta403340ec5c90238b136ca85fc64d65809b29a65 (diff)
downloadpardes-ffe05cceb897b3ae6a6d36491f9318a8aa3426e7.tar.gz
pardes-ffe05cceb897b3ae6a6d36491f9318a8aa3426e7.zip
integration: the build's second pass on the handle and the devices once: pardes-build-pass2 (pardes-isolate and the tree-sitter=disabled tier deleted; one option, grammars = none | minimal | full; build.zig with the consumer's lines as its head comment; test/lib -> test/consumer; the manual's library section) and pardes-merge31, merged without a textual conflict; one line follows a deletion: dev/file_watch.zig's end-to-end test of a session's watches (written since on the base) guarded on fs.platform_has_fs, which the first of these changes deleted: the guard reads as the file's other tests' (comptime !supported); tui core-test 857/1008 (151 skipped), shell-test 1048/1051, the window builds; the coordinator's gate in the ledger (reorg/merge32)
Co-Authored-By: Claude Fable 5.2 <[email protected]> Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T
Diffstat (limited to 'build')
-rw-r--r--build/core.zig109
-rw-r--r--build/library.zig49
-rw-r--r--build/tools.zig7
3 files changed, 52 insertions, 113 deletions
diff --git a/build/core.zig b/build/core.zig
index 4e4a748b..b668211d 100644
--- a/build/core.zig
+++ b/build/core.zig
@@ -83,7 +83,6 @@ pub fn options(b: *std.Build, cfg: ShellConfig, c: Core, pdf: bool) *std.Build.S
o.addOption(Platform, "platform", c.platform);
o.addOption(TreeSitterGrammars, "grammars", cfg.tree_sitter_grammars);
o.addOption(bool, "terminal", c.terminal);
- o.addOption(bool, "isolated", c.isolated);
o.addOption(bool, "builtin_addons", c.builtin_addons);
// ...the pdf one only when it is built (-Dpdf=false leaves it out).
o.addOption(bool, "builtin_pdf", c.builtin_addons and pdf);
@@ -146,15 +145,15 @@ pub fn generatedThemes(b: *std.Build, io: std.Io, target: std.Build.ResolvedTarg
}
pub const TreeSitter = struct {
- mod: ?*std.Build.Module,
- queries: ?*std.Build.Step.Options,
+ mod: *std.Build.Module,
+ queries: *std.Build.Step.Options,
libs: std.ArrayList(*std.Build.Step.Compile),
/// tree-sitter, the grammars' parsers and their queries, into `m`.
pub fn wire(ts: TreeSitter, m: *std.Build.Module) void {
- if (ts.mod) |x| m.addImport("tree-sitter", x);
+ m.addImport("tree-sitter", ts.mod);
for (ts.libs.items) |lib| m.linkLibrary(lib);
- if (ts.queries) |x| m.addOptions("ts_queries", x);
+ m.addOptions("ts_queries", ts.queries);
}
};
@@ -163,61 +162,51 @@ pub const TreeSitter = struct {
/// A grammar not fetched yet is asked for and left out: the configure runs
/// again once it is there.
pub fn treeSitter(b: *std.Build, io: std.Io, target: std.Build.ResolvedTarget, c_optimize: std.lang.Optimize, tree_sitter_grammars: TreeSitterGrammars) TreeSitter {
- var ts_mod: ?*std.Build.Module = null;
- var ts_queries_opts: ?*std.Build.Step.Options = null;
+ const tree_sitter_mod = b.dependency("tree_sitter", .{ .target = target, .optimize = c_optimize }).module("tree_sitter");
var ts_libs: std.ArrayList(*std.Build.Step.Compile) = .empty;
- if (tree_sitter_grammars != .disabled) {
- const tree_sitter_mod = b.dependency("tree_sitter", .{ .target = target, .optimize = c_optimize }).module("tree_sitter");
- ts_mod = tree_sitter_mod;
+ const ts_queries = b.addOptions();
+ inline for (grammar_manifest.all) |g| {
+ if (tree_sitter_grammars == .full or (tree_sitter_grammars == .minimal and g.tier == .minimal)) grammar: {
+ const dep = b.dependencyLazy(g.dep, .{}) catch break :grammar;
+ const upstream = configureRead(b, io, dep.builder.root, g.query, 0x100000) catch @panic("read " ++ g.name ++ " highlights");
+ // the patterns that colour, filtered here once and not in
+ // every compile, and the whole query, the filter's test's
+ const query = std.mem.concat(b.allocator, u8, &.{ upstream, g.highlights_extra }) catch @panic("OOM");
+ ts_queries.addOption([]const u8, g.name ++ "_highlights_unfiltered", query);
+ ts_queries.addOption([]const u8, g.name ++ "_highlights", grammar_manifest.colorQuery(query, b.allocator.alloc(u8, query.len) catch @panic("OOM")));
+ // helix's textobject queries, vendored (vendor/queries); a
+ // grammar without one gets none
+ const objects = configureRead(b, io, b.root, "vendor/queries/" ++ g.name ++ "/textobjects.scm", 0x100000) catch "";
+ ts_queries.addOption([]const u8, g.name ++ "_textobjects", objects);
+ // and their indent queries, beside them
+ const indents = configureRead(b, io, b.root, "vendor/queries/" ++ g.name ++ "/indents.scm", 0x100000) catch "";
+ ts_queries.addOption([]const u8, g.name ++ "_indents", indents);
- const ts_queries = b.addOptions();
- inline for (grammar_manifest.all) |g| {
- if (tree_sitter_grammars == .full or
- (tree_sitter_grammars == .minimal and g.tier != .full) or
- (tree_sitter_grammars == .zig and g.tier == .zig))
- grammar: {
- const dep = b.dependencyLazy(g.dep, .{}) catch break :grammar;
- const upstream = configureRead(b, io, dep.builder.root, g.query, 0x100000) catch @panic("read " ++ g.name ++ " highlights");
- // the patterns that colour, filtered here once and not in
- // every compile, and the whole query, the filter's test's
- const query = std.mem.concat(b.allocator, u8, &.{ upstream, g.highlights_extra }) catch @panic("OOM");
- ts_queries.addOption([]const u8, g.name ++ "_highlights_unfiltered", query);
- ts_queries.addOption([]const u8, g.name ++ "_highlights", grammar_manifest.colorQuery(query, b.allocator.alloc(u8, query.len) catch @panic("OOM")));
- // helix's textobject queries, vendored (vendor/queries); a
- // grammar without one gets none
- const objects = configureRead(b, io, b.root, "vendor/queries/" ++ g.name ++ "/textobjects.scm", 0x100000) catch "";
- ts_queries.addOption([]const u8, g.name ++ "_textobjects", objects);
- // and their indent queries, beside them
- const indents = configureRead(b, io, b.root, "vendor/queries/" ++ g.name ++ "/indents.scm", 0x100000) catch "";
- ts_queries.addOption([]const u8, g.name ++ "_indents", indents);
-
- const lib = b.addLibrary(.{
- .name = "tree-sitter-" ++ g.name,
- .root_module = b.createModule(.{ .target = target, .optimize = c_optimize, .link_libc = true }),
- .linkage = .static,
- });
- // Every allocation a grammar's external scanner makes goes to the
- // runtime's allocator, which syntax.zig points at a Zig one:
- // TREE_SITTER_REUSE_ALLOCATOR for the scanners that use
- // ts_malloc, and core/tree_sitter_heap.h for the ones that call
- // malloc themselves.
- const ts_cflags = [_][]const u8{
- "-fno-sanitize=function",
- "-DTREE_SITTER_REUSE_ALLOCATOR",
- // From the compiler's working directory, the root
- // package's: pardes's own, or the one that depends on it.
- "-include",
- b.root.joinString(b.allocator, "core/tree_sitter_heap.h") catch @panic("OOM"),
- };
- lib.root_module.addCSourceFile(.{ .file = dep.path(g.src ++ "/parser.c"), .flags = &ts_cflags });
- if (g.scanner) lib.root_module.addCSourceFile(.{ .file = dep.path(g.src ++ "/scanner.c"), .flags = &ts_cflags });
- lib.root_module.addIncludePath(dep.path(g.src));
- ts_libs.append(b.allocator, lib) catch @panic("OOM");
- }
+ const lib = b.addLibrary(.{
+ .name = "tree-sitter-" ++ g.name,
+ .root_module = b.createModule(.{ .target = target, .optimize = c_optimize, .link_libc = true }),
+ .linkage = .static,
+ });
+ // Every allocation a grammar's external scanner makes goes to the
+ // runtime's allocator, which syntax.zig points at a Zig one:
+ // TREE_SITTER_REUSE_ALLOCATOR for the scanners that use
+ // ts_malloc, and core/tree_sitter_heap.h for the ones that call
+ // malloc themselves.
+ const ts_cflags = [_][]const u8{
+ "-fno-sanitize=function",
+ "-DTREE_SITTER_REUSE_ALLOCATOR",
+ // From the compiler's working directory, the root
+ // package's: pardes's own, or the one that depends on it.
+ "-include",
+ b.root.joinString(b.allocator, "core/tree_sitter_heap.h") catch @panic("OOM"),
+ };
+ lib.root_module.addCSourceFile(.{ .file = dep.path(g.src ++ "/parser.c"), .flags = &ts_cflags });
+ if (g.scanner) lib.root_module.addCSourceFile(.{ .file = dep.path(g.src ++ "/scanner.c"), .flags = &ts_cflags });
+ lib.root_module.addIncludePath(dep.path(g.src));
+ ts_libs.append(b.allocator, lib) catch @panic("OOM");
}
- ts_queries_opts = ts_queries;
}
- return .{ .mod = ts_mod, .queries = ts_queries_opts, .libs = ts_libs };
+ return .{ .mod = tree_sitter_mod, .queries = ts_queries, .libs = ts_libs };
}
/// uucode with pardes's configuration (uucode_config.zig), which ghostty
@@ -308,8 +297,6 @@ pub const Core = struct {
platform: Platform,
/// The terminal module; without it (core-test) a shell boot is a scratch pane.
terminal: bool = true,
- /// pardes-isolate's: no host but the terminal.
- isolated: bool = false,
/// The addons compiled in and registered at start (Addon.zig): the
/// static step's, and every core off Linux, whose loader has no memfd.
builtin_addons: bool = false,
@@ -368,7 +355,7 @@ pub fn module(b: *std.Build, p: Parts, c: Core) Modules {
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 ts_queries = if (p.ts.queries) |q| q.createModule() else null;
+ const ts_queries = p.ts.queries.createModule();
const doc_typ = p.doc_typ.createModule();
const pardes_options = options(b, p.cfg, c, p.pdf != null).createModule();
const build_info = p.info.createModule();
@@ -380,8 +367,8 @@ pub fn module(b: *std.Build, p: Parts, c: Core) Modules {
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("tree-sitter", p.ts.mod);
+ x.addImport("ts_queries", ts_queries);
x.addImport("mvzr", p.mvzr);
x.addImport("c_heap", p.c_heap);
x.addImport("vaxis", p.vaxis);
diff --git a/build/library.zig b/build/library.zig
deleted file mode 100644
index 8a23debc..00000000
--- a/build/library.zig
+++ /dev/null
@@ -1,49 +0,0 @@
-const std = @import("std");
-const TreeSitterGrammars = @import("../build.zig").TreeSitterGrammars;
-const core = @import("core.zig");
-const patches = @import("patches.zig");
-
-/// pardes as a library, all a package that depends on it is given: the
-/// `pardes-syntax` module (core/lib_syntax.zig), the grammars, highlighting
-/// and themes for a program that draws source text itself. It takes
-/// tree-sitter and the grammars of its `tree-sitter` option and no other
-/// dependency, so nothing else is fetched (build.zig.zon). test/lib is such
-/// a package, which `lib-test` builds.
-pub fn build(b: *std.Build) void {
- const target = b.standardTargetOptions(.{});
- const optimize = b.standardOptimizeOption(.{});
- const tree_sitter_grammars = b.option(TreeSitterGrammars, "tree-sitter", "tree-sitter grammar set: disabled, zig, minimal (c/c++/zig), full") orelse .full;
- var threaded: std.Io.Threaded = .init(b.allocator, .{});
- defer threaded.deinit();
- const io = threaded.io();
- const mod = b.addModule("pardes-syntax", .{
- .target = target,
- .optimize = optimize,
- .root_source_file = b.path("core/lib_syntax.zig"),
- .link_libc = true,
- });
- // A library's options: its grammars, nothing stamped, no window.
- const cfg: core.ShellConfig = .{ .tree_sitter_grammars = tree_sitter_grammars };
- mod.addOptions("pardes_options", core.options(b, cfg, .{ .root = "core/lib_syntax.zig", .platform = .tui, .terminal = false }, false));
- const ts = core.treeSitter(b, io, target, if (optimize == .debug) .fast else optimize, tree_sitter_grammars);
- const themes = core.generatedThemes(b, io, target, optimize);
- mod.addImport("generated_themes", themes);
- ts.wire(mod);
- mod.addImport("c_heap", b.createModule(.{ .target = target, .optimize = optimize, .root_source_file = b.path("core/c_heap.zig") }));
- // The editor, `pardes-editor`, to a package that asks for it: uucode,
- // mvzr and vaxis (with what its build names) are fetched then and only
- // then. Of vaxis it takes the grapheme width, which uucode alone feeds.
- if (!(b.option(bool, "editor", "also export `pardes-editor`, the text pane as a library (fetches uucode, mvzr and vaxis)") orelse false)) return;
- const uucode = core.uucodeModule(b, target, optimize) orelse return;
- const mvzr = patches.mvzr(b, patches.tool(b), b.dependencyLazy("mvzr", .{ .target = target, .optimize = optimize }) catch return, target, optimize);
- const vaxis_dep = b.dependencyLazy("vaxis", .{ .target = target, .optimize = optimize, .external_uucode = true }) catch return;
- const width = b.addWriteFiles();
- _ = width.addCopyFile(vaxis_dep.path("src/gwidth.zig"), "gwidth.zig");
- const vaxis = b.createModule(.{
- .target = target,
- .optimize = optimize,
- .root_source_file = width.add("vaxis.zig", "pub const gwidth = @import(\"gwidth.zig\");\n"),
- .imports = &.{.{ .name = "uucode", .module = uucode }},
- });
- _ = core.editorModule(b, "pardes-editor", target, optimize, cfg, .{ .themes = themes, .ts = ts, .uucode = uucode, .mvzr = mvzr, .vaxis = vaxis });
-}
diff --git a/build/tools.zig b/build/tools.zig
index 62e9817a..a4b41dd7 100644
--- a/build/tools.zig
+++ b/build/tools.zig
@@ -250,12 +250,13 @@ pub fn add(b: *std.Build, c: struct {
if (testMatch(b, c.unit_profile, c.test_filters, syntax_test_step)) |check| check.addArtifactArg(syntax_test);
// The library as a package that depends on pardes is given it
- // (`library`): test/lib's own `zig build test`, over the packages
+ // (`library`): test/consumer's own `zig build test`, over the packages
// this checkout has fetched.
const lib_test = b.addSystemCommand(&.{ b.graph.zig_exe, "build", "test", "--pkg-dir", "../../zig-pkg" });
- lib_test.setCwd(b.path("test/lib"));
+ lib_test.setName("zig build test in test/consumer, a package that depends on pardes");
+ lib_test.setCwd(b.path("test/consumer"));
lib_test.has_side_effects = true;
- const lib_test_step = b.step("lib-test", "build and test the library from a package that depends on pardes (test/lib)");
+ const lib_test_step = b.step("lib-test", "build and test the library from a package that depends on pardes (test/consumer)");
lib_test_step.dependOn(&lib_test.step);
const history = b.addExecutable(.{