I will murder someone for this
This commit is contained in:
45
build.zig
45
build.zig
@@ -24,6 +24,45 @@ fn addEngineSources(c: *std.Build.Step.Compile) void {
|
||||
});
|
||||
}
|
||||
|
||||
const LuaVersion = enum {
|
||||
lua52,
|
||||
lua53,
|
||||
lua54,
|
||||
};
|
||||
|
||||
// For the test architecture, we specify the target Lua version we so desire.
|
||||
// This can be checked for with Lua's _VERSION
|
||||
|
||||
fn compileTheRightLua(b: *std.Build, c: *std.Build.Step.Compile, version: LuaVersion) !void {
|
||||
const alloc = b.allocator;
|
||||
const dirName = @tagName(version);
|
||||
|
||||
const rootPath = try std.mem.join(alloc, std.fs.path.sep_str, &.{"foreign", dirName});
|
||||
|
||||
c.addIncludePath(b.path(rootPath));
|
||||
|
||||
// get all the .c files
|
||||
var files = std.ArrayList([]const u8).init(alloc);
|
||||
errdefer files.deinit();
|
||||
|
||||
var dir = try std.fs.cwd().openDir(rootPath, std.fs.Dir.OpenDirOptions {.iterate = true});
|
||||
defer dir.close();
|
||||
|
||||
var iter = dir.iterate();
|
||||
|
||||
while(try iter.next()) |e| {
|
||||
if(std.mem.startsWith(u8, e.name, "l") and std.mem.endsWith(u8, e.name, ".c") and !std.mem.eql(u8, e.name, "lua.c")) {
|
||||
const name = try alloc.dupe(u8, e.name);
|
||||
try files.append(name);
|
||||
}
|
||||
}
|
||||
|
||||
c.addCSourceFiles(.{
|
||||
.root = b.path(rootPath),
|
||||
.files = files.items,
|
||||
});
|
||||
}
|
||||
|
||||
pub fn build(b: *std.Build) void {
|
||||
const os = builtin.target.os.tag;
|
||||
|
||||
@@ -72,21 +111,19 @@ pub fn build(b: *std.Build) void {
|
||||
if (os == .windows) {
|
||||
// use the msvc win64 dll versions and copy them to raylib/ and lua/
|
||||
// get raylib from https://github.com/raysan5/raylib/releases
|
||||
// get lua from https://luabinaries.sourceforge.net/
|
||||
emulator.addIncludePath(b.path("lua/include"));
|
||||
emulator.addIncludePath(b.path("raylib/include"));
|
||||
emulator.addObjectFile(b.path("lua/lua54.lib"));
|
||||
emulator.addObjectFile(b.path("raylib/lib/raylibdll.lib"));
|
||||
} else {
|
||||
emulator.linkSystemLibrary("lua");
|
||||
emulator.linkSystemLibrary("raylib");
|
||||
}
|
||||
const luaVer = b.option(LuaVersion, "lua", "The version of Lua to use.") orelse LuaVersion.lua54;
|
||||
emulator.addCSourceFiles(.{
|
||||
.files = &.{
|
||||
"src/testLuaArch.c",
|
||||
"src/emulator.c",
|
||||
},
|
||||
});
|
||||
compileTheRightLua(b, emulator, luaVer) catch unreachable;
|
||||
|
||||
// forces us to link in everything too
|
||||
emulator.linkLibrary(engineStatic);
|
||||
|
||||
Reference in New Issue
Block a user