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
4 changes: 2 additions & 2 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ jobs:
uses: actions/checkout@v3
- name: Setup Pages
uses: actions/configure-pages@v5
- uses: mlugg/setup-zig@v1
- uses: mlugg/setup-zig@v2
with:
version: 0.15.0-dev.441+c1649d586
version: master
- run: make docs
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
Expand Down
12 changes: 5 additions & 7 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
zig: ["0.14.0", "0.15.0-dev.441+c1649d586"]

runs-on: ${{matrix.os}}

Expand All @@ -20,9 +19,9 @@ jobs:
uses: actions/checkout@v3

- name: Setup Zig
uses: mlugg/setup-zig@v1
uses: mlugg/setup-zig@v2
with:
version: ${{ matrix.zig }}
version: master

- name: Run tests
run: make test
Expand All @@ -31,7 +30,6 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
zig: ["0.14.0", "0.15.0-dev.441+c1649d586"]

runs-on: ${{matrix.os}}

Expand All @@ -40,9 +38,9 @@ jobs:
uses: actions/checkout@v3

- name: Setup Zig
uses: mlugg/setup-zig@v1
uses: mlugg/setup-zig@v2
with:
version: ${{ matrix.zig }}
version: master

- name: Run tests
run: make test_cross
run: make test_cross
30 changes: 19 additions & 11 deletions build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,11 @@ pub fn build(b: *Build) void {

// Tests
const tests = b.addTest(.{
.root_source_file = b.path("src/tests.zig"),
.target = target,
.optimize = optimize,
.root_module = b.createModule(.{
.root_source_file = b.path("src/tests.zig"),
.target = target,
.optimize = optimize,
}),
});
tests.root_module.addImport("zlua", zlua);

Expand All @@ -123,9 +125,11 @@ pub fn build(b: *Build) void {
for (examples) |example| {
const exe = b.addExecutable(.{
.name = example[0],
.root_source_file = b.path(example[1]),
.target = target,
.optimize = optimize,
.root_module = b.createModule(.{
.root_source_file = b.path(example[1]),
.target = target,
.optimize = optimize,
}),
});
exe.root_module.addImport("zlua", zlua);

Expand All @@ -143,9 +147,11 @@ pub fn build(b: *Build) void {

const docs = b.addObject(.{
.name = "ziglua",
.root_source_file = b.path("src/lib.zig"),
.target = target,
.optimize = optimize,
.root_module = b.createModule(.{
.root_source_file = b.path("src/lib.zig"),
.target = target,
.optimize = optimize,
}),
});

const install_docs = b.addInstallDirectory(.{
Expand All @@ -159,9 +165,11 @@ pub fn build(b: *Build) void {

// definitions example
const def_exe = b.addExecutable(.{
.root_source_file = b.path("examples/define-exe.zig"),
.name = "define-zig-types",
.target = target,
.root_module = b.createModule(.{
.root_source_file = b.path("examples/define-exe.zig"),
.target = target,
}),
});
def_exe.root_module.addImport("zlua", zlua);
var run_def_exe = b.addRunArtifact(def_exe);
Expand Down
42 changes: 19 additions & 23 deletions build/lua.zig
Original file line number Diff line number Diff line change
Expand Up @@ -41,20 +41,16 @@ pub fn configure(
else => unreachable,
};

const lib = if (shared)
b.addSharedLibrary(.{
.name = library_name,
.target = target,
.optimize = optimize,
.version = version,
})
else
b.addStaticLibrary(.{
.name = library_name,
.target = target,
.optimize = optimize,
.version = version,
});
const lib = b.createModule(.{
.target = target,
.optimize = optimize,
});
const library = b.addLibrary(.{
.name = library_name,
.version = version,
.linkage = if (shared) .dynamic else .static,
.root_module = lib,
});

lib.addIncludePath(upstream.path("src"));

Expand Down Expand Up @@ -102,24 +98,24 @@ pub fn configure(
if (lang == .lua51) {
const patched = applyPatchToFile(b, b.graph.host, upstream.path("src/ldo.c"), b.path("build/lua-5.1.patch"), "ldo.c");

lib.step.dependOn(&patched.run.step);
library.step.dependOn(&patched.run.step);

lib.addCSourceFile(.{ .file = patched.output, .flags = &flags });
}

lib.linkLibC();
library.linkLibC();

lib.installHeader(upstream.path("src/lua.h"), "lua.h");
lib.installHeader(upstream.path("src/lualib.h"), "lualib.h");
lib.installHeader(upstream.path("src/lauxlib.h"), "lauxlib.h");
lib.installHeader(upstream.path("src/luaconf.h"), "luaconf.h");
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| {
lib.addIncludePath(user_h.dirname());
lib.installHeader(user_h, user_header);
library.addIncludePath(user_h.dirname());
library.installHeader(user_h, user_header);
}

return lib;
return library;
}

const lua_base_source_files = [_][]const u8{
Expand Down
88 changes: 45 additions & 43 deletions build/luajit.zig
Original file line number Diff line number Diff line change
Expand Up @@ -8,27 +8,26 @@ const applyPatchToFile = @import("utils.zig").applyPatchToFile;
pub fn configure(b: *Build, target: Build.ResolvedTarget, optimize: std.builtin.OptimizeMode, upstream: *Build.Dependency, shared: bool) *Step.Compile {
// TODO: extract this to the main build function because it is shared between all specialized build functions

const lib: *Step.Compile = if (shared)
b.addSharedLibrary(.{
.name = "lua",
.target = target,
.optimize = optimize,
.unwind_tables = .sync,
})
else
b.addStaticLibrary(.{
.name = "lua",
.target = target,
.optimize = optimize,
.unwind_tables = .sync,
});
const lib = b.createModule(.{
.target = target,
.optimize = optimize,
.unwind_tables = .sync,
});
const library = b.addLibrary(.{
.name = "lua",
.root_module = lib,
.linkage = if (shared) .dynamic else .static,
});

// Compile minilua interpreter used at build time to generate files
const minilua = b.addExecutable(.{
.name = "minilua",
const minilua_mod = b.createModule(.{
.target = b.graph.host, // Use host target for cross build
.optimize = .ReleaseSafe,
});
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");
Expand Down Expand Up @@ -106,11 +105,14 @@ pub fn configure(b: *Build, target: Build.ResolvedTarget, optimize: std.builtin.
const luajit_h = genversion_run.addOutputFileArg("luajit.h");

// Compile the buildvm executable used to generate other files
const buildvm = b.addExecutable(.{
.name = "buildvm",
const vm_mod = b.createModule(.{
.target = b.graph.host, // Use host target for cross build
.optimize = .ReleaseSafe,
});
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) {
Expand Down Expand Up @@ -197,27 +199,27 @@ pub fn configure(b: *Build, target: Build.ResolvedTarget, optimize: std.builtin.
}

// Finally build LuaJIT after generating all the files
lib.step.dependOn(&genversion_run.step);
lib.step.dependOn(&buildvm_bcdef.step);
lib.step.dependOn(&buildvm_ffdef.step);
lib.step.dependOn(&buildvm_libdef.step);
lib.step.dependOn(&buildvm_recdef.step);
lib.step.dependOn(&buildvm_folddef.step);
lib.step.dependOn(&buildvm_ljvm.step);
library.step.dependOn(&genversion_run.step);
library.step.dependOn(&buildvm_bcdef.step);
library.step.dependOn(&buildvm_ffdef.step);
library.step.dependOn(&buildvm_libdef.step);
library.step.dependOn(&buildvm_recdef.step);
library.step.dependOn(&buildvm_folddef.step);
library.step.dependOn(&buildvm_ljvm.step);

lib.linkLibC();
library.linkLibC();

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

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

lib.addIncludePath(upstream.path("src"));
lib.addIncludePath(luajit_h.dirname());
lib.addIncludePath(bcdef_header.dirname());
lib.addIncludePath(ffdef_header.dirname());
lib.addIncludePath(libdef_header.dirname());
lib.addIncludePath(recdef_header.dirname());
lib.addIncludePath(folddef_header.dirname());
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());

lib.addCSourceFiles(.{
.root = .{ .dependency = .{
Expand All @@ -229,18 +231,18 @@ pub fn configure(b: *Build, target: Build.ResolvedTarget, optimize: std.builtin.

// 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.root_module.sanitize_c = false;
lib.sanitize_c = false;
} else {
lib.root_module.sanitize_c = .off;
lib.sanitize_c = .off;
}

lib.installHeader(upstream.path("src/lua.h"), "lua.h");
lib.installHeader(upstream.path("src/lualib.h"), "lualib.h");
lib.installHeader(upstream.path("src/lauxlib.h"), "lauxlib.h");
lib.installHeader(upstream.path("src/luaconf.h"), "luaconf.h");
lib.installHeader(luajit_h, "luajit.h");
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");
library.installHeader(luajit_h, "luajit.h");

return lib;
return library;
}

const luajit_lib = [_][]const u8{
Expand Down
20 changes: 12 additions & 8 deletions build/luau.zig
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,15 @@ const Build = std.Build;
const Step = std.Build.Step;

pub fn configure(b: *Build, target: Build.ResolvedTarget, optimize: std.builtin.OptimizeMode, upstream: *Build.Dependency, luau_use_4_vector: bool) *Step.Compile {
const lib = b.addStaticLibrary(.{
.name = "luau",
const lib = b.createModule(.{
.target = target,
.optimize = optimize,
});
const library = b.addLibrary(.{
.name = "luau",
.linkage = .static,
.version = std.SemanticVersion{ .major = 0, .minor = 653, .patch = 0 },
.root_module = lib,
});

lib.addIncludePath(upstream.path("Common/include"));
Expand All @@ -33,14 +37,14 @@ pub fn configure(b: *Build, target: Build.ResolvedTarget, optimize: std.builtin.
.flags = &flags,
});
lib.addCSourceFile(.{ .file = b.path("src/luau.cpp"), .flags = &flags });
lib.linkLibCpp();
library.linkLibCpp();

lib.installHeader(upstream.path("VM/include/lua.h"), "lua.h");
lib.installHeader(upstream.path("VM/include/lualib.h"), "lualib.h");
lib.installHeader(upstream.path("VM/include/luaconf.h"), "luaconf.h");
lib.installHeader(upstream.path("Compiler/include/luacode.h"), "luacode.h");
library.installHeader(upstream.path("VM/include/lua.h"), "lua.h");
library.installHeader(upstream.path("VM/include/lualib.h"), "lualib.h");
library.installHeader(upstream.path("VM/include/luaconf.h"), "luaconf.h");
library.installHeader(upstream.path("Compiler/include/luacode.h"), "luacode.h");

return lib;
return library;
}

const luau_source_files = [_][]const u8{
Expand Down
Loading
Loading