Skip to content
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
3 changes: 2 additions & 1 deletion build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ pub fn build(b: *Build) void {
std.debug.panic("Luau does not support compiling or loading shared modules", .{});
}

if (lua_user_h != null and (lang == .luajit or lang == .luau)) {
if (lua_user_h != null and (lang == .luajit or lang == .luau or lang == .lua55)) {
std.debug.panic("Only basic lua supports a user provided header file", .{});
}

Expand Down Expand Up @@ -58,6 +58,7 @@ pub fn build(b: *Build) void {
.lua52 => zlua.linkSystemLibrary("lua5.2", .{ .preferred_link_mode = link_mode }),
.lua53 => zlua.linkSystemLibrary("lua5.3", .{ .preferred_link_mode = link_mode }),
.lua54 => zlua.linkSystemLibrary("lua5.4", .{ .preferred_link_mode = link_mode }),
.lua55 => zlua.linkSystemLibrary("lua5.5", .{ .preferred_link_mode = link_mode }),
.luajit => zlua.linkSystemLibrary("luajit", .{ .preferred_link_mode = link_mode }),
.luau => @panic("luau not supported for system lua"),
}
Expand Down
6 changes: 6 additions & 0 deletions build.zig.zon
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@
.lazy = true,
},

.lua55 = .{
.url = "https://www.lua.org/ftp/lua-5.5.0.tar.gz",
.hash = "N-V-__8AAGuAFQAFQL34FRuOIGC9klkZq44uTTan4cUS9vas",
.lazy = true,
},

.luajit = .{
.url = "https://github.com/LuaJIT/LuaJIT/archive/c525bcb9024510cad9e170e12b6209aedb330f83.tar.gz",
.hash = "N-V-__8AACcgQgCuLYTPzCp6pnBmFJHyG77RAtM13hjOfTaG",
Expand Down
10 changes: 10 additions & 0 deletions build/lua.zig
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ pub const Language = enum {
lua52,
lua53,
lua54,
lua55,
luajit,
luau,
};
Expand Down Expand Up @@ -38,6 +39,7 @@ pub fn configure(
.lua52 => .{ .major = 5, .minor = 2, .patch = 4 },
.lua53 => .{ .major = 5, .minor = 3, .patch = 6 },
.lua54 => .{ .major = 5, .minor = 4, .patch = 8 },
.lua55 => .{ .major = 5, .minor = 5, .patch = 0 },
else => unreachable,
};

Expand Down Expand Up @@ -83,6 +85,7 @@ pub fn configure(
.lua52 => &lua_52_source_files,
.lua53 => &lua_53_source_files,
.lua54 => &lua_54_source_files,
.lua55 => &lua_55_source_files,
else => unreachable,
};

Expand Down Expand Up @@ -169,3 +172,10 @@ const lua_54_source_files = lua_base_source_files ++ [_][]const u8{
"src/lcorolib.c",
"src/lutf8lib.c",
};

const lua_55_source_files = lua_base_source_files ++ [_][]const u8{
"src/ldo.c",
"src/lctype.c",
"src/lcorolib.c",
"src/lutf8lib.c",
};
4 changes: 0 additions & 4 deletions build/luajit.zig
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,6 @@ pub fn configure(b: *Build, target: Build.ResolvedTarget, optimize: std.builtin.

const buildvm_os_c_flags: []const []const u8 = if (target.result.os.tag == .windows)
&.{"-DLUAJIT_OS=1"}
else if (target.result.os.tag.isDarwin())
// FIXME: this can be removed once https://codeberg.org/ziglang/zig/issues/30669 is successfully resolved
&.{"-DLJ_NO_UNWIND=1"}
else
&.{};

Expand Down Expand Up @@ -208,7 +205,6 @@ pub fn configure(b: *Build, target: Build.ResolvedTarget, optimize: std.builtin.
library.is_linking_libc = true;

lib.addCMacro("LUAJIT_UNWIND_EXTERNAL", "");

lib.linkSystemLibrary("unwind", .{});

library.root_module.addIncludePath(upstream.path("src"));
Expand Down
16 changes: 10 additions & 6 deletions build/patch.zig
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//! A simple script to apply a patch to a file
//! Does minimal validation and is just enough for patching Lua 5.1

pub fn main() !void {
pub fn main(init: std.process.Init.Minimal) !void {
var arena = std.heap.ArenaAllocator.init(std.heap.page_allocator);
defer arena.deinit();
const allocator = arena.allocator();
Expand All @@ -10,12 +10,16 @@ pub fn main() !void {
defer threaded.deinit();
const io = threaded.io();

const args = try std.process.argsAlloc(allocator);
if (args.len != 4) @panic("Wrong number of arguments");
var iter = init.args.iterate();

const file_path = args[1];
const patch_file_path = args[2];
const output_path = args[3];
// Skip executable name
_ = iter.next();

const file_path = iter.next() orelse @panic("Missing file_path argument");
const patch_file_path = iter.next() orelse @panic("Missing patch_file_path argument");
const output_path = iter.next() orelse @panic("Missing output_path argument");

if (iter.next() != null) @panic("Too many arguments");

const patch_file = patch_file: {
const patch_file = try Io.Dir.cwd().openFile(io, patch_file_path, .{ .mode = .read_only });
Expand Down
2 changes: 2 additions & 0 deletions makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ test_zig_nightly:
zig build test --summary failures -Dlang=lua52
zig build test --summary failures -Dlang=lua53
zig build test --summary failures -Dlang=lua54
zig build test --summary failures -Dlang=lua55
zig build test --summary failures -Dlang=luau

zig build install-example-interpreter
Expand All @@ -21,6 +22,7 @@ test_zig_stable:
zig build test --summary failures -Dlang=lua52
zig build test --summary failures -Dlang=lua53
zig build test --summary failures -Dlang=lua54
zig build test --summary failures -Dlang=lua55
zig build test --summary failures -Dlang=luau

zig build install-example-interpreter
Expand Down
2 changes: 1 addition & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
[![shield showing current tests status](https://github.com/natecraddock/ziglua/actions/workflows/tests.yml/badge.svg)](https://github.com/natecraddock/ziglua/actions/workflows/tests.yml)
[![Discord](https://img.shields.io/discord/1196908820140671077?style=flat&logo=discord)](https://discord.com/invite/XpZqDFvAtK)

Zig bindings for the [Lua C API](https://www.lua.org/manual/5.4/manual.html#4). Ziglua currently supports the latest releases of Lua 5.1, 5.2, 5.3, 5.4, and [Luau](https://luau-lang.org).
Zig bindings for the [Lua C API](https://www.lua.org/manual/5.4/manual.html#4). Ziglua currently supports the latest releases of Lua 5.1, 5.2, 5.3, 5.4, 5.5, [LuaJIT](https://luajit.org) and [Luau](https://luau-lang.org).

Ziglua can be used in two ways, either
* **embedded** to statically embed the Lua VM in a Zig program,
Expand Down
Loading