From 968b1a5b69a1eb6c7c880778106725ed73b004e2 Mon Sep 17 00:00:00 2001 From: PegaFox Date: Fri, 24 Apr 2026 10:55:36 -0400 Subject: [PATCH 1/3] Replace deprecated functions with root_module interactions --- build.zig | 76 ++++++++++++++++++++++++++----------------------------- 1 file changed, 36 insertions(+), 40 deletions(-) diff --git a/build.zig b/build.zig index d84be0f..6af4ee4 100644 --- a/build.zig +++ b/build.zig @@ -26,29 +26,31 @@ pub fn build(b: *Build) !void { const lua_src = b.dependency("lua", .{}); const lib = - b.addStaticLibrary(artifactOptions( + b.addLibrary(artifactOptions( + b, .{ .shared = false }, .{ .target = target, .optimize = optimize }, )); const shared = if (build_shared) - b.addSharedLibrary(artifactOptions( + b.addLibrary(artifactOptions( + b, .{ .shared = true }, .{ .target = target, .optimize = optimize }, )) else null; - const exe = b.addExecutable(artifactOptions(.exe, .{ + const exe = b.addExecutable(artifactOptions(b, .exe, .{ .target = target, .optimize = optimize, })); - const exec = b.addExecutable(artifactOptions(.exec, .{ + const exec = b.addExecutable(artifactOptions(b, .exec, .{ .target = target, .optimize = optimize, })); if (!target.result.isMinGW()) { - lib.linkSystemLibrary("m"); - exe.linkSystemLibrary("m"); - exec.linkSystemLibrary("m"); + lib.root_module.linkSystemLibrary("m", .{}); + exe.root_module.linkSystemLibrary("m", .{}); + exec.root_module.linkSystemLibrary("m", .{}); } const build_targets = [_]?*Build.Step.Compile{ lib, @@ -61,8 +63,8 @@ pub fn build(b: *Build) !void { if (tr == null) continue; const t = tr.?; - t.linkLibC(); - t.addIncludePath(lua_src.path("src")); + t.root_module.link_libc = true; + t.root_module.addIncludePath(lua_src.path("src")); switch (target.result.os.tag) { .aix => { t.root_module.addCMacro("LUA_USE_POSIX", ""); @@ -180,50 +182,44 @@ const ArtifactTargetOptions = struct { target: ResolvedTarget, optimize: OptimizeMode, }; -fn artifactOptions(comptime options: ArtifactTarget, opts: ArtifactTargetOptions) switch (options) { +fn artifactOptions(b: *Build, comptime options: ArtifactTarget, opts: ArtifactTargetOptions) switch (options) { .exe, .exec => Build.ExecutableOptions, - .shared => |shared| if (shared) - Build.SharedLibraryOptions - else - Build.StaticLibraryOptions, + .shared => Build.LibraryOptions } { const t = opts.target.result.os.tag; return switch (options) { - .shared => |shared| if (shared) blk: { - switch (t) { - .windows => break :blk .{ - .name = lib_name ++ "54", - .target = opts.target, - .optimize = opts.optimize, - .strip = true, - }, - else => break :blk .{ - .name = lib_name, - .target = opts.target, - .optimize = opts.optimize, - }, - } - } else blk: { - switch (t) { - else => break :blk .{ - .name = lib_name, - .target = opts.target, - .optimize = opts.optimize, - }, - } + .shared => |shared| if (shared and t == .windows) .{ + .name = lib_name ++ "54", + .linkage = if (shared) .dynamic else .static, + .root_module = b.createModule(.{ + .target = opts.target, + .optimize = opts.optimize, + .strip = true, + }), + } else .{ + .name = lib_name, + .linkage = if (shared) .dynamic else .static, + .root_module = b.createModule(.{ + .target = opts.target, + .optimize = opts.optimize, + }), }, .exe => switch (t) { else => .{ .name = exe_name, - .target = opts.target, - .optimize = opts.optimize, + .root_module = b.createModule(.{ + .target = opts.target, + .optimize = opts.optimize, + }), }, }, .exec => switch (t) { else => .{ .name = compiler_name, - .target = opts.target, - .optimize = opts.optimize, + .root_module = b.createModule(.{ + .target = opts.target, + .optimize = opts.optimize, + }), }, }, }; From 4f814ff7619f8ee5296b6e557e19e3529744783f Mon Sep 17 00:00:00 2001 From: PegaFox Date: Fri, 24 Apr 2026 10:57:15 -0400 Subject: [PATCH 2/3] Remove unsupported operating systems --- build.zig | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/build.zig b/build.zig index 6af4ee4..43af11e 100644 --- a/build.zig +++ b/build.zig @@ -66,11 +66,6 @@ pub fn build(b: *Build) !void { t.root_module.link_libc = true; t.root_module.addIncludePath(lua_src.path("src")); switch (target.result.os.tag) { - .aix => { - t.root_module.addCMacro("LUA_USE_POSIX", ""); - t.root_module.addCMacro("LUA_USE_DLOPEN", ""); - t.linkSystemLibrary("dl"); - }, .freebsd, .netbsd, .openbsd => { t.root_module.addCMacro("LUA_USE_LINUX", ""); t.root_module.addCMacro("LUA_USE_READLINE", ""); @@ -93,12 +88,6 @@ pub fn build(b: *Build) !void { t.root_module.addCMacro("LUA_USE_READLINE", ""); t.linkSystemLibrary("readline"); }, - .solaris => { - t.root_module.addCMacro("LUA_USE_POSIX", ""); - t.root_module.addCMacro("LUA_USE_DLOPEN", ""); - t.root_module.addCMacro("_REENTRANT", ""); - t.linkSystemLibrary("dl"); - }, else => {}, } } From 9d12e6d06f80d90d5cb478b79fe086b9b1df042f Mon Sep 17 00:00:00 2001 From: PegaFox Date: Fri, 24 Apr 2026 11:27:11 -0400 Subject: [PATCH 3/3] Replace deprecated functions with root_module interactions --- build.zig | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/build.zig b/build.zig index 43af11e..56a84c8 100644 --- a/build.zig +++ b/build.zig @@ -69,24 +69,24 @@ pub fn build(b: *Build) !void { .freebsd, .netbsd, .openbsd => { t.root_module.addCMacro("LUA_USE_LINUX", ""); t.root_module.addCMacro("LUA_USE_READLINE", ""); - t.addIncludePath(.{ .cwd_relative = "/usr/include/edit" }); - t.linkSystemLibrary("edit"); + t.root_module.addIncludePath(.{ .cwd_relative = "/usr/include/edit" }); + t.root_module.linkSystemLibrary("edit", .{}); }, .ios => { t.root_module.addCMacro("LUA_USE_IOS", ""); }, .linux => { t.root_module.addCMacro("LUA_USE_LINUX", ""); - t.linkSystemLibrary("dl"); + t.root_module.linkSystemLibrary("dl", .{}); if (use_readline.?) { t.root_module.addCMacro("LUA_USE_READLINE", ""); - t.linkSystemLibrary("readline"); + t.root_module.linkSystemLibrary("readline", .{}); } }, .macos => { t.root_module.addCMacro("LUA_USE_MACOSX", ""); t.root_module.addCMacro("LUA_USE_READLINE", ""); - t.linkSystemLibrary("readline"); + t.root_module.linkSystemLibrary("readline", .{}); }, else => {}, } @@ -96,7 +96,7 @@ pub fn build(b: *Build) !void { exe.root_module.addCMacro("LUA_BUILD_AS_DLL", ""); } if (shared) |s| { - s.addCSourceFiles(.{ + s.root_module.addCSourceFiles(.{ .root = lua_src.path("src"), .files = &base_src, .flags = &cflags, @@ -109,7 +109,7 @@ pub fn build(b: *Build) !void { ); } - lib.addCSourceFiles(.{ + lib.root_module.addCSourceFiles(.{ .root = lua_src.path("src"), .files = &base_src, .flags = &cflags, @@ -121,26 +121,26 @@ pub fn build(b: *Build) !void { .{ .include_extensions = &lua_inc }, ); - exe.addCSourceFile(.{ + exe.root_module.addCSourceFile(.{ .file = lua_src.path("src/lua.c"), .flags = &cflags, }); - exec.addCSourceFile(.{ + exec.root_module.addCSourceFile(.{ .file = lua_src.path("src/luac.c"), .flags = &cflags, }); if (shared) |s| { - exe.linkLibrary(s); + exe.root_module.linkLibrary(s); b.installArtifact(s); } else { - exe.linkLibrary(lib); + exe.root_module.linkLibrary(lib); b.installArtifact(lib); } b.installArtifact(exe); - exec.linkLibrary(lib); + exec.root_module.linkLibrary(lib); b.installArtifact(exec); b.installDirectory(.{