diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-20 03:57:20 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-20 04:33:18 -0300 |
| commit | 852299dd8d056b90446508757d8c6dacf8975abe (patch) | |
| tree | c8318551828a1e4897fbcc46791c9e9f87d2e61c /build | |
| parent | 1e127c3968205f0e42faa4eb5b894cea296346d0 (diff) | |
| download | pardes-852299dd8d056b90446508757d8c6dacf8975abe.tar.gz pardes-852299dd8d056b90446508757d8c6dacf8975abe.zip | |
build: the `-Dtree-sitter=disabled` tier is deleted (pardes-build-2 item 2; P31's Q5, decided on the evidence 2026-11-20): a pardes with no tree-sitter at all, whose syntax.zig stubbed `ts` with four opaque types and answered every call empty; it did not compile on the base (`zig build install -Dplatform=tui -Dtree-sitter=disabled`: core/indent.zig:48 `struct 'syntax.ts__struct_3541' has no member named 'Tree'`, since indent.zig reads the parse tree the stub never had) and nobody set it; out with it: the `disabled` value of `TreeSitterGrammars`, build/core.zig's `treeSitter` made always (its module and its queries no longer optional, so `TreeSitter.wire` and `core.module` add them plainly), the stub `ts` and `ts_queries`, `syntax.enabled` and every branch that was for it: 32 guard lines and 16 terms of a condition in core/syntax.zig (its `start` and `stop` unwrapped), whole test guards in core/draw.zig, Stream.zig, File.zig, Query.zig, Core.zig (2), mouse.zig, replica.zig (2), test/output.zig (7), test/panes.zig (11) and test/behaviour/{panes,settings}.zig, a term in Stream.zig's two worker tests, `TreeContext.enabled` (builtins.zig) and the config table's condition on it (config.zig), test/output.zig's two conditions on the grammars; abi/wire.zig hashes the grammar set as the same four words (`true true` for highlighting and the Zig grammar, which every set has now), so `pardes version`'s semantics line did not move: 8b6382fddba7b382 on tui, gui, the bare build's two, both statics and FreeBSD, 0520895ac88d25ad with -Dtree-sitter=minimal, as at item 1; the manual's option table and the changelog say it; build.zig and build/ 2,981 -> 2,974 lines; every shape configures (11) and builds (tui, gui, bare, static musl and gui, FreeBSD, -Dtree-sitter=minimal, the macOS library for Linux and aarch64-macos); tui core-test 856/1006 (150 skipped), shell-test 1046/1049, pane-test 183/184, behaviour-test 275/275 and -- --replay 275/275, term-test 17/17, kitty-test 45/45, addon-test 5/5, lib-test, hxlib 538 cases 0 mismatches, process-test 0 of 144 failed (diffstack failed once and passed on the runner's own retry), gui unit-test 1643/1647 (the perf check's BaselineHarnessMismatch, the base's); load 5-26 on 16 cores
Co-Authored-By: Claude Opus <[email protected]>
Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T
Diffstat (limited to 'build')
| -rw-r--r-- | build/core.zig | 109 | ||||
| -rw-r--r-- | build/library.zig | 2 |
2 files changed, 52 insertions, 59 deletions
diff --git a/build/core.zig b/build/core.zig index 4e619243..903b5602 100644 --- a/build/core.zig +++ b/build/core.zig @@ -145,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); } }; @@ -162,61 +162,54 @@ 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 != .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 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 @@ -365,7 +358,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(); @@ -377,8 +370,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 index 8a23debc..cabb175b 100644 --- a/build/library.zig +++ b/build/library.zig @@ -12,7 +12,7 @@ const patches = @import("patches.zig"); 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; + const tree_sitter_grammars = b.option(TreeSitterGrammars, "tree-sitter", "tree-sitter grammar set: zig, minimal (c/c++/zig), full") orelse .full; var threaded: std.Io.Threaded = .init(b.allocator, .{}); defer threaded.deinit(); const io = threaded.io(); |
