summaryrefslogtreecommitdiff
path: root/build/core.zig
diff options
context:
space:
mode:
Diffstat (limited to 'build/core.zig')
-rw-r--r--build/core.zig24
1 files changed, 17 insertions, 7 deletions
diff --git a/build/core.zig b/build/core.zig
index b668211d..63b4a5e9 100644
--- a/build/core.zig
+++ b/build/core.zig
@@ -144,6 +144,16 @@ pub fn generatedThemes(b: *std.Build, io: std.Io, target: std.Build.ResolvedTarg
});
}
+/// The grammars a build compiles in, a flag each in the manifest's order.
+pub const GrammarSet = [grammar_manifest.all.len]bool;
+
+/// A tier's (`-Dgrammars`, a dependent package's `.grammars`).
+pub fn tierSet(tier: TreeSitterGrammars) GrammarSet {
+ var set: GrammarSet = undefined;
+ for (grammar_manifest.all, &set) |g, *in| in.* = tier == .full or (tier == .minimal and g.tier == .minimal);
+ return set;
+}
+
pub const TreeSitter = struct {
mod: *std.Build.Module,
queries: *std.Build.Step.Options,
@@ -158,15 +168,15 @@ pub const TreeSitter = struct {
};
/// tree-sitter's bindings, and for each grammar of the set its queries (the
-/// `ts_queries` options syntax.zig reads) and its parser, a static library.
-/// 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 {
+/// `ts_queries` options syntax.zig reads, and by which it knows the set)
+/// and its parser, a static library. 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, set: GrammarSet) TreeSitter {
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;
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: {
+ inline for (grammar_manifest.all, set) |g, in| {
+ if (in) 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
@@ -433,7 +443,7 @@ pub fn assemble(b: *std.Build, c: struct {
// nothing else. pardes takes these whatever it builds: the missing ones
// are asked for here in one round, the grammars with them, where each
// `b.dependency` below would end the configure to fetch its own alone.
- const ts = treeSitter(b, io, target, c_optimize, c.shell_cfg.tree_sitter_grammars);
+ const ts = treeSitter(b, io, target, c_optimize, tierSet(c.shell_cfg.tree_sitter_grammars));
inline for (.{ "cloud9", "vaxis", "ghostty", "uucode", "zstbi", "mvzr", "zstd", "xitdb" }) |name| {
// A dependency by path (none of these today) has no hash and is always there.
const dep = @field(zon.dependencies, name);