fixed a bug related to Lua includes

This commit is contained in:
IonutParau 2025-07-15 17:48:52 +02:00
parent 7a43ed0727
commit f4bf8e1d62
2 changed files with 16 additions and 8 deletions

View File

@ -79,8 +79,6 @@ fn compileTheRightLua(b: *std.Build, target: std.Build.ResolvedTarget, version:
const rootPath = try std.mem.join(alloc, std.fs.path.sep_str, &.{ "foreign", dirName }); const rootPath = try std.mem.join(alloc, std.fs.path.sep_str, &.{ "foreign", dirName });
c.addIncludePath(b.path(rootPath));
// get all the .c files // get all the .c files
var files = std.ArrayList([]const u8).init(alloc); var files = std.ArrayList([]const u8).init(alloc);
errdefer files.deinit(); errdefer files.deinit();
@ -105,7 +103,16 @@ fn compileTheRightLua(b: *std.Build, target: std.Build.ResolvedTarget, version:
return c; return c;
} }
pub fn build(b: *std.Build) void { fn includeTheRightLua(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));
}
pub fn build(b: *std.Build) !void {
const target = b.standardTargetOptions(.{}); const target = b.standardTargetOptions(.{});
const os = target.result.os.tag; const os = target.result.os.tag;
@ -162,7 +169,7 @@ pub fn build(b: *std.Build) void {
emulator.linkLibrary(raylib.artifact("raylib")); emulator.linkLibrary(raylib.artifact("raylib"));
} }
const luaVer = b.option(LuaVersion, "lua", "The version of Lua to use.") orelse LuaVersion.lua54; const luaVer = b.option(LuaVersion, "lua", "The version of Lua to use.") orelse LuaVersion.lua52;
emulator.addCSourceFiles(.{ emulator.addCSourceFiles(.{
.files = &.{ .files = &.{
"src/testLuaArch.c", "src/testLuaArch.c",
@ -173,7 +180,8 @@ pub fn build(b: *std.Build) void {
if(opts.bit32) "-DNN_BIT32" else "", if(opts.bit32) "-DNN_BIT32" else "",
}, },
}); });
const l = compileTheRightLua(b, target, luaVer) catch unreachable; const l = try compileTheRightLua(b, target, luaVer);
try includeTheRightLua(b, emulator, luaVer);
// forces us to link in everything too // forces us to link in everything too
emulator.addObject(l); emulator.addObject(l);

View File

@ -1,6 +1,6 @@
#include <lua.h> #include "lua.h"
#include <lualib.h> #include "lualib.h"
#include <lauxlib.h> #include "lauxlib.h"
#include <assert.h> #include <assert.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>