summaryrefslogtreecommitdiff
path: root/build.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-07-01 19:56:21 -0300
committerGabriel Schneider <[email protected]>2026-08-01 15:02:07 -0300
commitcc806b11ba880d1bd326e3f1f9e69f7539c22395 (patch)
tree3b200ed4e46e2c80d2762ae2efd45bf87413133d /build.zig
parentf3618a5a3151e02db2c1e2280ab42d48c35eeba9 (diff)
downloadpardes-cc806b11ba880d1bd326e3f1f9e69f7539c22395.tar.gz
pardes-cc806b11ba880d1bd326e3f1f9e69f7539c22395.zip
more treesitter grammars
Diffstat (limited to 'build.zig')
-rw-r--r--build.zig54
1 files changed, 43 insertions, 11 deletions
diff --git a/build.zig b/build.zig
index f6647ed5..fbe8c67a 100644
--- a/build.zig
+++ b/build.zig
@@ -101,25 +101,57 @@ pub fn build(b: *std.Build) void {
const tree_sitter = b.dependency("tree_sitter", .{ .target = target, .optimize = optimize });
exe.root_module.addImport("tree-sitter", tree_sitter.module("tree_sitter"));
- const grammars = .{
- .{ "c", "ts_c", false },
- .{ "rust", "ts_rust", true },
- .{ "zig", "ts_zig", false },
+ const Grammar = struct {
+ name: []const u8,
+ dep: []const u8,
+ src: []const u8 = "src",
+ scanner: bool = false,
+ query: []const u8 = "queries/highlights.scm",
+ local_query: ?[]const u8 = null,
+ };
+ const grammars = [_]Grammar{
+ .{ .name = "ada", .dep = "ts_ada" },
+ .{ .name = "bash", .dep = "ts_bash", .scanner = true },
+ .{ .name = "c", .dep = "ts_c" },
+ .{ .name = "c_sharp", .dep = "ts_c_sharp", .scanner = true },
+ .{ .name = "clojure", .dep = "ts_clojure" },
+ .{ .name = "cpp", .dep = "ts_cpp", .scanner = true },
+ .{ .name = "css", .dep = "ts_css", .scanner = true },
+ .{ .name = "elixir", .dep = "ts_elixir", .scanner = true },
+ .{ .name = "erlang", .dep = "ts_erlang", .scanner = true },
+ .{ .name = "fortran", .dep = "ts_fortran", .scanner = true },
+ .{ .name = "go", .dep = "ts_go" },
+ .{ .name = "haskell", .dep = "ts_haskell", .scanner = true },
+ .{ .name = "html", .dep = "ts_html", .scanner = true },
+ .{ .name = "java", .dep = "ts_java" },
+ .{ .name = "javascript", .dep = "ts_javascript", .scanner = true },
+ .{ .name = "json", .dep = "ts_json" },
+ .{ .name = "kotlin", .dep = "ts_kotlin", .scanner = true },
+ .{ .name = "ocaml", .dep = "ts_ocaml", .src = "grammars/ocaml/src", .scanner = true },
+ .{ .name = "pascal", .dep = "ts_pascal" },
+ .{ .name = "php", .dep = "ts_php", .src = "php/src", .scanner = true },
+ .{ .name = "powershell", .dep = "ts_powershell", .scanner = true },
+ .{ .name = "python", .dep = "ts_python", .scanner = true },
+ .{ .name = "ruby", .dep = "ts_ruby", .scanner = true },
+ .{ .name = "rust", .dep = "ts_rust", .scanner = true },
+ .{ .name = "scala", .dep = "ts_scala", .scanner = true },
+ .{ .name = "zig", .dep = "ts_zig" },
};
const ts_queries = b.addOptions();
inline for (grammars) |g| {
- const dep = b.dependency(g[1], .{});
- const query = std.Io.Dir.cwd().readFileAlloc(io, dep.path("queries/highlights.scm").getPath(b), b.allocator, .limited(0x100000)) catch @panic("read " ++ g[0] ++ " highlights");
- ts_queries.addOption([]const u8, g[0] ++ "_highlights", query);
+ const dep = b.dependency(g.dep, .{});
+ const query_path = if (g.local_query) |p| b.path(p) else dep.path(g.query);
+ const query = std.Io.Dir.cwd().readFileAlloc(io, query_path.getPath(b), b.allocator, .limited(0x100000)) catch @panic("read " ++ g.name ++ " highlights");
+ ts_queries.addOption([]const u8, g.name ++ "_highlights", query);
const lib = b.addLibrary(.{
- .name = "tree-sitter-" ++ g[0],
+ .name = "tree-sitter-" ++ g.name,
.root_module = b.createModule(.{ .target = target, .optimize = optimize, .link_libc = true }),
.linkage = .static,
});
- lib.root_module.addCSourceFile(.{ .file = dep.path("src/parser.c") });
- if (g[2]) lib.root_module.addCSourceFile(.{ .file = dep.path("src/scanner.c") });
- lib.root_module.addIncludePath(dep.path("src"));
+ lib.root_module.addCSourceFile(.{ .file = dep.path(g.src ++ "/parser.c") });
+ if (g.scanner) lib.root_module.addCSourceFile(.{ .file = dep.path(g.src ++ "/scanner.c") });
+ lib.root_module.addIncludePath(dep.path(g.src));
exe.root_module.linkLibrary(lib);
}
exe.root_module.addOptions("ts_queries", ts_queries);