Skip to content
Closed
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
5 changes: 2 additions & 3 deletions build/lua.zig
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ pub fn configure(
const lib = b.createModule(.{
.target = target,
.optimize = optimize,
.link_libc = true,
});
const library = b.addLibrary(.{
.name = library_name,
Expand Down Expand Up @@ -103,15 +104,13 @@ pub fn configure(
lib.addCSourceFile(.{ .file = patched.output, .flags = &flags });
}

library.linkLibC();

library.installHeader(upstream.path("src/lua.h"), "lua.h");
library.installHeader(upstream.path("src/lualib.h"), "lualib.h");
library.installHeader(upstream.path("src/lauxlib.h"), "lauxlib.h");
library.installHeader(upstream.path("src/luaconf.h"), "luaconf.h");

if (lua_user_h) |user_h| {
library.addIncludePath(user_h.dirname());
library.root_module.addIncludePath(user_h.dirname());
library.installHeader(user_h, user_header);
}

Expand Down
54 changes: 19 additions & 35 deletions build/luajit.zig
Original file line number Diff line number Diff line change
Expand Up @@ -23,20 +23,14 @@ pub fn configure(b: *Build, target: Build.ResolvedTarget, optimize: std.builtin.
const minilua_mod = b.createModule(.{
.target = b.graph.host, // Use host target for cross build
.optimize = .ReleaseSafe,
.link_libc = true,
.sanitize_c = .off,
});
const minilua = b.addExecutable(.{
.name = "minilua",
.root_module = minilua_mod,
});
minilua.linkLibC();
// FIXME: remove branch when zig-0.15 is released and 0.14 can be dropped
const builtin = @import("builtin");
if (builtin.zig_version.major == 0 and builtin.zig_version.minor < 15) {
minilua.root_module.sanitize_c = false;
} else {
minilua.root_module.sanitize_c = .off;
}
minilua.addCSourceFile(.{ .file = upstream.path("src/host/minilua.c") });
minilua.root_module.addCSourceFile(.{ .file = upstream.path("src/host/minilua.c") });

// Generate the buildvm_arch.h file using minilua
const dynasm_run = b.addRunArtifact(minilua);
Expand Down Expand Up @@ -108,18 +102,13 @@ pub fn configure(b: *Build, target: Build.ResolvedTarget, optimize: std.builtin.
const vm_mod = b.createModule(.{
.target = b.graph.host, // Use host target for cross build
.optimize = .ReleaseSafe,
.link_libc = true,
.sanitize_c = .off,
});
const buildvm = b.addExecutable(.{
.name = "buildvm",
.root_module = vm_mod,
});
buildvm.linkLibC();
// FIXME: remove branch when zig-0.15 is released and 0.14 can be dropped
if (builtin.zig_version.major == 0 and builtin.zig_version.minor < 15) {
buildvm.root_module.sanitize_c = false;
} else {
buildvm.root_module.sanitize_c = .off;
}

// Needs to run after the buildvm_arch.h and luajit.h files are generated
buildvm.step.dependOn(&dynasm_run.step);
Expand All @@ -136,7 +125,7 @@ pub fn configure(b: *Build, target: Build.ResolvedTarget, optimize: std.builtin.
else
&.{};

buildvm.addCSourceFiles(.{
buildvm.root_module.addCSourceFiles(.{
.root = .{ .dependency = .{
.dependency = upstream,
.sub_path = "",
Expand All @@ -145,10 +134,10 @@ pub fn configure(b: *Build, target: Build.ResolvedTarget, optimize: std.builtin.
.flags = std.mem.concat(b.allocator, []const u8, &.{ buildvm_c_flags, buildvm_windows_c_flags }) catch @panic("OOM!"),
});

buildvm.addIncludePath(upstream.path("src"));
buildvm.addIncludePath(upstream.path("src/host"));
buildvm.addIncludePath(buildvm_arch_h.dirname());
buildvm.addIncludePath(luajit_h.dirname());
buildvm.root_module.addIncludePath(upstream.path("src"));
buildvm.root_module.addIncludePath(upstream.path("src/host"));
buildvm.root_module.addIncludePath(buildvm_arch_h.dirname());
buildvm.root_module.addIncludePath(luajit_h.dirname());

// Use buildvm to generate files and headers used in the final vm
const buildvm_bcdef = b.addRunArtifact(buildvm);
Expand Down Expand Up @@ -213,19 +202,19 @@ pub fn configure(b: *Build, target: Build.ResolvedTarget, optimize: std.builtin.
library.step.dependOn(&buildvm_folddef.step);
library.step.dependOn(&buildvm_ljvm.step);

library.linkLibC();
library.is_linking_libc = true;

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

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

library.addIncludePath(upstream.path("src"));
library.addIncludePath(luajit_h.dirname());
library.addIncludePath(bcdef_header.dirname());
library.addIncludePath(ffdef_header.dirname());
library.addIncludePath(libdef_header.dirname());
library.addIncludePath(recdef_header.dirname());
library.addIncludePath(folddef_header.dirname());
library.root_module.addIncludePath(upstream.path("src"));
library.root_module.addIncludePath(luajit_h.dirname());
library.root_module.addIncludePath(bcdef_header.dirname());
library.root_module.addIncludePath(ffdef_header.dirname());
library.root_module.addIncludePath(libdef_header.dirname());
library.root_module.addIncludePath(recdef_header.dirname());
library.root_module.addIncludePath(folddef_header.dirname());

lib.addCSourceFiles(.{
.root = .{ .dependency = .{
Expand All @@ -235,12 +224,7 @@ pub fn configure(b: *Build, target: Build.ResolvedTarget, optimize: std.builtin.
.files = &luajit_vm,
});

// FIXME: remove branch when zig-0.15 is released and 0.14 can be dropped
if (builtin.zig_version.major == 0 and builtin.zig_version.minor < 15) {
lib.sanitize_c = false;
} else {
lib.sanitize_c = .off;
}
lib.sanitize_c = .off;

library.installHeader(upstream.path("src/lua.h"), "lua.h");
library.installHeader(upstream.path("src/lualib.h"), "lualib.h");
Expand Down
2 changes: 1 addition & 1 deletion build/luau.zig
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ pub fn configure(b: *Build, target: Build.ResolvedTarget, optimize: std.builtin.
const lib = b.createModule(.{
.target = target,
.optimize = optimize,
.link_libcpp = true,
});
const library = b.addLibrary(.{
.name = "luau",
Expand Down Expand Up @@ -37,7 +38,6 @@ pub fn configure(b: *Build, target: Build.ResolvedTarget, optimize: std.builtin.
.flags = &flags,
});
lib.addCSourceFile(.{ .file = b.path("src/luau.cpp"), .flags = &flags });
library.linkLibCpp();

library.installHeader(upstream.path("VM/include/lua.h"), "lua.h");
library.installHeader(upstream.path("VM/include/lualib.h"), "lualib.h");
Expand Down
Loading