90 lines
2.5 KiB
Zig
90 lines
2.5 KiB
Zig
const std = @import("std");
|
|
const bh = @import("bh");
|
|
|
|
pub fn build(b: *std.Build) void {
|
|
const target = b.standardTargetOptions(.{});
|
|
const optimize = b.standardOptimizeOption(.{});
|
|
const static_build = b.option(bool, "static_build", "builds backlog dependencies for static linking") orelse false;
|
|
|
|
const lua = bh.MakeModLib(b, .{
|
|
.name = "lua",
|
|
.target = target,
|
|
.optimize = optimize,
|
|
.static_build = static_build,
|
|
.root = b.path("src/lua.zig"),
|
|
});
|
|
|
|
lua.install();
|
|
|
|
// Add include paths to module (for Zig @cImport)
|
|
lua.addIncludePath("lua/src/");
|
|
lua.addIncludePath("src/");
|
|
|
|
// Configure library
|
|
lua.lib.linkLibC();
|
|
lua.lib.addCSourceFiles(.{
|
|
.root = b.path("lua/src/"),
|
|
.files = &.{
|
|
"lapi.c",
|
|
"lmathlib.c",
|
|
"lauxlib.c",
|
|
"lbaselib.c",
|
|
"lcode.c",
|
|
"lcorolib.c",
|
|
"lctype.c",
|
|
"ldblib.c",
|
|
"ldebug.c",
|
|
"ldo.c",
|
|
"ldump.c",
|
|
"lfunc.c",
|
|
"lgc.c",
|
|
"linit.c",
|
|
"liolib.c",
|
|
"llex.c",
|
|
"lmem.c",
|
|
"loadlib.c",
|
|
"lobject.c",
|
|
"lopcodes.c",
|
|
"loslib.c",
|
|
"lparser.c",
|
|
"lstate.c",
|
|
"lstring.c",
|
|
"lstrlib.c",
|
|
"ltable.c",
|
|
"ltablib.c",
|
|
"ltm.c",
|
|
"lundump.c",
|
|
"lutf8lib.c",
|
|
"lvm.c",
|
|
"lzio.c",
|
|
},
|
|
});
|
|
|
|
lua.lib.addCSourceFile(.{ .file = b.path("src/limited_io.c") });
|
|
|
|
if (target.result.os.tag == .windows) {
|
|
lua.lib.addCSourceFile(.{ .file = b.path("src/minidumpsetup.cpp") });
|
|
if (target.result.abi != .msvc)
|
|
lua.lib.linkLibCpp();
|
|
} else {
|
|
lua.lib.addCSourceFile(.{ .file = b.path("src/minidumpstub.cpp") });
|
|
}
|
|
|
|
const run_step = b.step("test", "");
|
|
const tests = b.addExecutable(.{
|
|
.name = "run-lua",
|
|
.root_module = b.createModule(.{
|
|
.target = target,
|
|
.optimize = optimize,
|
|
.root_source_file = b.path("test/test-lua.zig"),
|
|
.link_libc = true,
|
|
}),
|
|
});
|
|
|
|
tests.root_module.addImport("lua", lua.mod);
|
|
tests.root_module.linkLibrary(lua.lib);
|
|
const runArtifact = b.addRunArtifact(tests);
|
|
run_step.dependOn(&runArtifact.step);
|
|
b.installArtifact(tests);
|
|
}
|