From 03e666dcd2c11e2588baa745a24b8c4268947314 Mon Sep 17 00:00:00 2001 From: Morgan Moore Date: Sun, 11 Jan 2026 17:29:04 -0500 Subject: [PATCH] Update build.zig for 0.16 --- build.zig | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/build.zig b/build.zig index bd7a0721..7d8d4820 100644 --- a/build.zig +++ b/build.zig @@ -20,23 +20,23 @@ pub fn build(b: *std.Build) !void { }); if (amalgamated) { - lib.addCSourceFile(.{ + lib.root_module.addCSourceFile(.{ .file = b.path("lib/src/lib.c"), .flags = &.{"-std=c11"}, }); } else { const files = try findSourceFiles(b); defer b.allocator.free(files); - lib.addCSourceFiles(.{ + lib.root_module.addCSourceFiles(.{ .root = b.path("lib/src"), .files = files, .flags = &.{"-std=c11"}, }); } - lib.addIncludePath(b.path("lib/include")); - lib.addIncludePath(b.path("lib/src")); - lib.addIncludePath(b.path("lib/src/wasm")); + lib.root_module.addIncludePath(b.path("lib/include")); + lib.root_module.addIncludePath(b.path("lib/src")); + lib.root_module.addIncludePath(b.path("lib/src/wasm")); lib.root_module.addCMacro("_POSIX_C_SOURCE", "200112L"); lib.root_module.addCMacro("_DEFAULT_SOURCE", ""); @@ -45,9 +45,9 @@ pub fn build(b: *std.Build) !void { if (wasm) { if (b.lazyDependency(wasmtimeDep(target.result), .{})) |wasmtime| { lib.root_module.addCMacro("TREE_SITTER_FEATURE_WASM", ""); - lib.addSystemIncludePath(wasmtime.path("include")); - lib.addLibraryPath(wasmtime.path("lib")); - if (shared) lib.linkSystemLibrary("wasmtime"); + lib.root_module.addSystemIncludePath(wasmtime.path("include")); + lib.root_module.addLibraryPath(wasmtime.path("lib")); + if (shared) lib.root_module.linkSystemLibrary("wasmtime", .{}); } } @@ -124,11 +124,12 @@ pub fn wasmtimeDep(target: std.Target) []const u8 { fn findSourceFiles(b: *std.Build) ![]const []const u8 { var sources: std.ArrayListUnmanaged([]const u8) = .empty; - var dir = try b.build_root.handle.openDir("lib/src", .{ .iterate = true }); + const io = b.graph.io; + var dir = try b.build_root.handle.openDir(io, "lib/src", .{ .iterate = true }); var iter = dir.iterate(); - defer dir.close(); + defer dir.close(io); - while (try iter.next()) |entry| { + while (try iter.next(io)) |entry| { if (entry.kind != .file) continue; const file = entry.name; const ext = std.fs.path.extension(file);