Skip to content

Update to zig 14 build system #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 16, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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");
```
40 changes: 20 additions & 20 deletions build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -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 },
Expand Down Expand Up @@ -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(.{
Expand Down
4 changes: 3 additions & 1 deletion build.zig.zon
Original file line number Diff line number Diff line change
@@ -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",
Expand Down