diff options
| author | Chinmay Dalal <dalal.chinmay.0101@gmail.com> | 2026-01-05 15:35:47 -0500 |
|---|---|---|
| committer | bfredl <bjorn.linse@gmail.com> | 2026-04-21 11:18:43 +0200 |
| commit | 427d62c43404c3da8f267a44849c3dc8bc4254f8 (patch) | |
| tree | 31787183a62ed54aac6990df5aa3acddd2587e74 /src | |
| parent | 32e249dfa6fcf2d079df962473bd257bf04c2a16 (diff) | |
feat(build.zig): update to zig 0.16
Diffstat (limited to 'src')
| -rw-r--r-- | src/build_lua.zig | 37 | ||||
| -rw-r--r-- | src/gen/gen_steps.zig | 7 |
2 files changed, 24 insertions, 20 deletions
diff --git a/src/build_lua.zig b/src/build_lua.zig index 3d9b634ab1..f1dce0f21c 100644 --- a/src/build_lua.zig +++ b/src/build_lua.zig @@ -4,6 +4,7 @@ const LazyPath = std.Build.LazyPath; pub fn build_nlua0( b: *std.Build, + io: std.Io, target: std.Build.ResolvedTarget, optimize: std.builtin.OptimizeMode, use_luajit: bool, @@ -59,7 +60,7 @@ pub fn build_nlua0( mod.addIncludePath(b.path("src")); mod.addIncludePath(b.path("src/includes_fixmelater")); - try add_lua_modules(b, target.result, mod, lpeg, use_luajit, true, system_integration_options); + try add_lua_modules(b, io, target.result, mod, lpeg, use_luajit, true, system_integration_options); } // for debugging the nlua0 environment @@ -83,6 +84,7 @@ pub fn build_nlua0( pub fn add_lua_modules( b: *std.Build, + io: std.Io, target: std.Target, mod: *std.Build.Module, lpeg_dep: ?*std.Build.Dependency, @@ -110,7 +112,7 @@ pub fn add_lua_modules( .flags = &flags, }); if (system_integration_options.lpeg) { - if (try findLpeg(b, target)) |lpeg_lib| { + if (try findLpeg(b, io, target)) |lpeg_lib| { mod.addLibraryPath(.{ .cwd_relative = std.fs.path.dirname(lpeg_lib).? }); mod.addObjectFile(.{ .cwd_relative = lpeg_lib }); } @@ -149,33 +151,34 @@ pub fn build_libluv( ) !*std.Build.Step.Compile { const upstream = b.lazyDependency("luv", .{}); const compat53 = b.lazyDependency("lua_compat53", .{}); + var root_module = b.createModule(.{ + .target = target, + .optimize = optimize, + }); const lib = b.addLibrary(.{ .name = "luv", .linkage = .static, - .root_module = b.createModule(.{ - .target = target, - .optimize = optimize, - }), + .root_module = root_module, }); if (lua) |lua_lib| { - lib.root_module.linkLibrary(lua_lib); + root_module.linkLibrary(lua_lib); } else { const system_lua_lib = if (use_luajit) "luajit" else "lua5.1"; - lib.root_module.linkSystemLibrary(system_lua_lib, .{}); + root_module.linkSystemLibrary(system_lua_lib, .{}); } - lib.linkLibrary(libuv); + root_module.linkLibrary(libuv); if (upstream) |dep| { - lib.addIncludePath(dep.path("src")); + root_module.addIncludePath(dep.path("src")); lib.installHeader(dep.path("src/luv.h"), "luv/luv.h"); - lib.addCSourceFiles(.{ .root = dep.path("src/"), .files = &.{ + root_module.addCSourceFiles(.{ .root = dep.path("src/"), .files = &.{ "luv.c", } }); } if (compat53) |dep| { - lib.addIncludePath(dep.path("c-api")); - lib.addCSourceFiles(.{ .root = dep.path("c-api"), .files = &.{ + root_module.addIncludePath(dep.path("c-api")); + root_module.addCSourceFiles(.{ .root = dep.path("c-api"), .files = &.{ "compat-5.3.c", } }); } @@ -183,7 +186,7 @@ pub fn build_libluv( return lib; } -fn findLpeg(b: *std.Build, target: std.Target) !?[]const u8 { +fn findLpeg(b: *std.Build, io: std.Io, target: std.Target) !?[]const u8 { const filenames = [_][]const u8{ "lpeg_a", "lpeg", @@ -205,10 +208,10 @@ fn findLpeg(b: *std.Build, target: std.Target) !?[]const u8 { try paths.append(b.allocator, b.fmt("{s}/lua/5.1", .{dir})); } for (paths.items) |path| { - var dir = std.fs.openDirAbsolute(path, .{}) catch continue; - defer dir.close(); + var dir = std.Io.Dir.openDirAbsolute(io, path, .{}) catch continue; + defer dir.close(io); for (filenames) |filename| { - dir.access(filename, .{}) catch continue; + dir.access(io, filename, .{}) catch continue; return b.fmt("{s}/{s}", .{ path, filename }); } } diff --git a/src/gen/gen_steps.zig b/src/gen/gen_steps.zig index 794beb8df7..e0f4037641 100644 --- a/src/gen/gen_steps.zig +++ b/src/gen/gen_steps.zig @@ -5,6 +5,7 @@ pub const SourceItem = struct { name: []u8, api_export: bool }; pub fn nvim_gen_sources( b: *std.Build, + io: std.Io, nlua0: *std.Build.Step.Compile, nvim_sources: *std.ArrayList(SourceItem), nvim_headers: *std.ArrayList([]u8), @@ -85,15 +86,15 @@ pub fn nvim_gen_sources( } // Dynamically add all Lua _core/ modules (like CMakeLists.txt does) - if (b.build_root.handle.openDir("runtime/lua/vim/_core", .{ .iterate = true })) |core_dir_handle| { + if (b.build_root.handle.openDir(io, "runtime/lua/vim/_core", .{ .iterate = true })) |core_dir_handle| { var core_dir = core_dir_handle; - defer core_dir.close(); + defer core_dir.close(io); var iter = core_dir.iterate(); var core_files = try std.ArrayList([]const u8).initCapacity(b.allocator, 0); defer core_files.deinit(b.allocator); - while (try iter.next()) |entry| { + while (try iter.next(io)) |entry| { if (entry.kind == .file and std.mem.endsWith(u8, entry.name, ".lua")) { const module_name = try b.allocator.dupe(u8, entry.name[0 .. entry.name.len - 4]); try core_files.append(b.allocator, module_name); |
