summaryrefslogtreecommitdiff
path: root/build/core.zig
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/core.zig
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/core.zig')
-rw-r--r--build/core.zig109
1 files changed, 48 insertions, 61 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);