From 56b987be70d2c813a9f25f02e89d386ccfb6237b Mon Sep 17 00:00:00 2001 From: Merlyn Morgan-Graham Date: Sat, 22 Mar 2025 17:35:22 -0700 Subject: [PATCH 1/4] Update to zig 14 build system --- build.zig | 40 ++++++++++++++++++++-------------------- build.zig.zon | 4 +++- 2 files changed, 23 insertions(+), 21 deletions(-) diff --git a/build.zig b/build.zig index e009386..d84be0f 100644 --- a/build.zig +++ b/build.zig @@ -19,17 +19,17 @@ pub fn build(b: *Build) !void { const build_shared = b.option(bool, "shared", "build as shared library") orelse target.result.isMinGW(); const use_readline = if (target.result.os.tag == .linux) - b.option(bool, "use_readline", "readline support for linux") orelse false - else - null; + b.option(bool, "use_readline", "readline support for linux") orelse false + else + null; const lua_src = b.dependency("lua", .{}); const lib = b.addStaticLibrary(artifactOptions( - .{ .shared = false }, - .{ .target = target, .optimize = optimize }, - )); + .{ .shared = false }, + .{ .target = target, .optimize = optimize }, + )); const shared = if (build_shared) b.addSharedLibrary(artifactOptions( .{ .shared = true }, @@ -65,44 +65,44 @@ pub fn build(b: *Build) !void { t.addIncludePath(lua_src.path("src")); switch (target.result.os.tag) { .aix => { - t.defineCMacro("LUA_USE_POSIX", null); - t.defineCMacro("LUA_USE_DLOPEN", null); + t.root_module.addCMacro("LUA_USE_POSIX", ""); + t.root_module.addCMacro("LUA_USE_DLOPEN", ""); t.linkSystemLibrary("dl"); }, .freebsd, .netbsd, .openbsd => { - t.defineCMacro("LUA_USE_LINUX", null); - t.defineCMacro("LUA_USE_READLINE", null); + t.root_module.addCMacro("LUA_USE_LINUX", ""); + t.root_module.addCMacro("LUA_USE_READLINE", ""); t.addIncludePath(.{ .cwd_relative = "/usr/include/edit" }); t.linkSystemLibrary("edit"); }, .ios => { - t.defineCMacro("LUA_USE_IOS", null); + t.root_module.addCMacro("LUA_USE_IOS", ""); }, .linux => { - t.defineCMacro("LUA_USE_LINUX", null); + t.root_module.addCMacro("LUA_USE_LINUX", ""); t.linkSystemLibrary("dl"); if (use_readline.?) { - t.defineCMacro("LUA_USE_READLINE", null); + t.root_module.addCMacro("LUA_USE_READLINE", ""); t.linkSystemLibrary("readline"); } }, .macos => { - t.defineCMacro("LUA_USE_MACOSX", null); - t.defineCMacro("LUA_USE_READLINE", null); + t.root_module.addCMacro("LUA_USE_MACOSX", ""); + t.root_module.addCMacro("LUA_USE_READLINE", ""); t.linkSystemLibrary("readline"); }, .solaris => { - t.defineCMacro("LUA_USE_POSIX", null); - t.defineCMacro("LUA_USE_DLOPEN", null); - t.defineCMacro("_REENTRANT", null); + t.root_module.addCMacro("LUA_USE_POSIX", ""); + t.root_module.addCMacro("LUA_USE_DLOPEN", ""); + t.root_module.addCMacro("_REENTRANT", ""); t.linkSystemLibrary("dl"); }, else => {}, } } if (target.result.isMinGW()) { - lib.defineCMacro("LUA_BUILD_AS_DLL", null); - exe.defineCMacro("LUA_BUILD_AS_DLL", null); + lib.root_module.addCMacro("LUA_BUILD_AS_DLL", ""); + exe.root_module.addCMacro("LUA_BUILD_AS_DLL", ""); } if (shared) |s| { s.addCSourceFiles(.{ diff --git a/build.zig.zon b/build.zig.zon index 4404da6..11785a6 100644 --- a/build.zig.zon +++ b/build.zig.zon @@ -1,8 +1,10 @@ .{ - .name = "lua", + .name = .lua, .version = "5.4.7", + .fingerprint = 0xd671372bcadcaace, + .dependencies = .{ .lua = .{ .url = "https://www.lua.org/ftp/lua-5.4.7.tar.gz", From 7697bec84130e498624a51ef3b3cc5a05741f4f3 Mon Sep 17 00:00:00 2001 From: Merlyn Morgan-Graham Date: Sat, 22 Mar 2025 17:48:16 -0700 Subject: [PATCH 2/4] Fix Windows artifact name in build.zig instructions --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 72eaf8a..5e9442b 100644 --- a/README.md +++ b/README.md @@ -35,5 +35,5 @@ const lua_dep = b.dependency("lua", .{ .target = target, .release = optimize != .Debug, }); -const lua_lib = lua_dep.artifact("lua"); +const lua_lib = lua_dep.artifact(if (target.result.os.tag == .windows) "lua54" else "lua"); ``` From 0b43bb02790d9dc80922f2d9bbdb923a2a51f95b Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Fri, 16 May 2025 15:53:01 -0700 Subject: [PATCH 3/4] update lua hash --- build.zig.zon | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.zig.zon b/build.zig.zon index 11785a6..7a153bd 100644 --- a/build.zig.zon +++ b/build.zig.zon @@ -8,7 +8,7 @@ .dependencies = .{ .lua = .{ .url = "https://www.lua.org/ftp/lua-5.4.7.tar.gz", - .hash = "12206df90729936e110f5d2574437be370fc4367b5f44afcc77749ac421547bc8ff0", + .hash = "N-V-__8AAIMvFABt-Qcpk24RD10ldEN743D8Q2e19Er8x3dJ", }, }, From 5a5a4135cbb8991f27c01bce341fd93134dbecd1 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Fri, 16 May 2025 15:55:52 -0700 Subject: [PATCH 4/4] add minimum_zig_version field --- README.md | 3 --- build.zig.zon | 4 ++-- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 5e9442b..28f59ba 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,6 @@ # Lua ## 5.4.7 -## Warning -due to a bug in the 0.13.0 release of the zig compiler you will need the development version of zig in order to build the lua54.dll on windows. - ## Build Instructions To build all targets run ```sh diff --git a/build.zig.zon b/build.zig.zon index 7a153bd..2b6560b 100644 --- a/build.zig.zon +++ b/build.zig.zon @@ -1,10 +1,10 @@ .{ .name = .lua, - .version = "5.4.7", - .fingerprint = 0xd671372bcadcaace, + .minimum_zig_version = "0.14.0", + .dependencies = .{ .lua = .{ .url = "https://www.lua.org/ftp/lua-5.4.7.tar.gz",