mirror of
https://github.com/NeoFlock/neonucleus.git
synced 2025-09-24 09:03:32 +02:00
fixed all the optimizer bugs
This commit is contained in:
parent
faa67f417d
commit
1bf8604433
27
build.zig
27
build.zig
@ -14,6 +14,10 @@ fn addEngineSources(b: *std.Build, opts: LibBuildOpts) *std.Build.Module {
|
|||||||
.target = opts.target,
|
.target = opts.target,
|
||||||
.optimize = opts.optimize,
|
.optimize = opts.optimize,
|
||||||
.single_threaded = true,
|
.single_threaded = true,
|
||||||
|
.sanitize_c = true,
|
||||||
|
.valgrind = true,
|
||||||
|
.stack_check = true,
|
||||||
|
.stack_protector = true,
|
||||||
});
|
});
|
||||||
|
|
||||||
dataMod.addCSourceFiles(.{
|
dataMod.addCSourceFiles(.{
|
||||||
@ -62,10 +66,17 @@ const LuaVersion = enum {
|
|||||||
// For the test architecture, we specify the target Lua version we so desire.
|
// For the test architecture, we specify the target Lua version we so desire.
|
||||||
// This can be checked for with Lua's _VERSION
|
// This can be checked for with Lua's _VERSION
|
||||||
|
|
||||||
fn compileTheRightLua(b: *std.Build, c: *std.Build.Step.Compile, version: LuaVersion) !void {
|
fn compileTheRightLua(b: *std.Build, target: std.Build.ResolvedTarget, version: LuaVersion) !*std.Build.Step.Compile {
|
||||||
const alloc = b.allocator;
|
const alloc = b.allocator;
|
||||||
const dirName = @tagName(version);
|
const dirName = @tagName(version);
|
||||||
|
|
||||||
|
const c = b.addObject(.{
|
||||||
|
.name = "lua",
|
||||||
|
.link_libc = true,
|
||||||
|
.optimize = .ReleaseSafe,
|
||||||
|
.target = target,
|
||||||
|
});
|
||||||
|
|
||||||
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));
|
c.addIncludePath(b.path(rootPath));
|
||||||
@ -90,13 +101,8 @@ fn compileTheRightLua(b: *std.Build, c: *std.Build.Step.Compile, version: LuaVer
|
|||||||
.root = b.path(rootPath),
|
.root = b.path(rootPath),
|
||||||
.files = files.items,
|
.files = files.items,
|
||||||
});
|
});
|
||||||
}
|
|
||||||
fn getSharedEngineName(os: std.Target.Os.Tag) []const u8 {
|
return c;
|
||||||
if (os == .windows) {
|
|
||||||
return "neonucleusdll";
|
|
||||||
} else {
|
|
||||||
return "neonucleus";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn build(b: *std.Build) void {
|
pub fn build(b: *std.Build) void {
|
||||||
@ -125,7 +131,7 @@ pub fn build(b: *std.Build) void {
|
|||||||
});
|
});
|
||||||
|
|
||||||
const engineShared = b.addSharedLibrary(.{
|
const engineShared = b.addSharedLibrary(.{
|
||||||
.name = getSharedEngineName(os),
|
.name = if(os == .windows) "neonucleusdll" else "neonucleus",
|
||||||
.root_module = engineMod,
|
.root_module = engineMod,
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -167,9 +173,10 @@ pub fn build(b: *std.Build) void {
|
|||||||
if(opts.bit32) "-DNN_BIT32" else "",
|
if(opts.bit32) "-DNN_BIT32" else "",
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
compileTheRightLua(b, emulator, luaVer) catch unreachable;
|
const l = compileTheRightLua(b, target, luaVer) catch unreachable;
|
||||||
|
|
||||||
// forces us to link in everything too
|
// forces us to link in everything too
|
||||||
|
emulator.addObject(l);
|
||||||
emulator.linkLibrary(engineStatic);
|
emulator.linkLibrary(engineStatic);
|
||||||
|
|
||||||
const emulatorStep = b.step("emulator", "Builds the emulator");
|
const emulatorStep = b.step("emulator", "Builds the emulator");
|
||||||
|
@ -164,9 +164,9 @@ void nni_gpu_get(nni_gpu *gpu, void *_, nn_component *component, nn_computer *co
|
|||||||
nn_unicode_codepointToChar(chr, pxl.codepoint, &l);
|
nn_unicode_codepointToChar(chr, pxl.codepoint, &l);
|
||||||
|
|
||||||
// TODO: gosh darn palettes
|
// TODO: gosh darn palettes
|
||||||
nn_return(computer, nn_values_cstring(chr));
|
nn_return_string(computer, chr, l);
|
||||||
nn_return(computer, nn_values_integer(pxl.fg));
|
nn_return_integer(computer, pxl.fg);
|
||||||
nn_return(computer, nn_values_integer(pxl.bg));
|
nn_return_integer(computer, pxl.bg);
|
||||||
}
|
}
|
||||||
|
|
||||||
void nni_gpu_getScreen(nni_gpu *gpu, void *_, nn_component *component, nn_computer *computer) {
|
void nni_gpu_getScreen(nni_gpu *gpu, void *_, nn_component *component, nn_computer *computer) {
|
||||||
|
@ -673,7 +673,11 @@ testLuaArch *testLuaArch_setup(nn_computer *computer, void *_) {
|
|||||||
lua_setfield(L, LUA_REGISTRYINDEX, "archPtr");
|
lua_setfield(L, LUA_REGISTRYINDEX, "archPtr");
|
||||||
s->L = L;
|
s->L = L;
|
||||||
testLuaArch_loadEnv(L);
|
testLuaArch_loadEnv(L);
|
||||||
assert(luaL_loadbufferx(L, testLuaSandbox, strlen(testLuaSandbox), "=machine.lua", "t") == LUA_OK);
|
if(luaL_loadbufferx(L, testLuaSandbox, strlen(testLuaSandbox), "=machine.lua", "t") != LUA_OK) {
|
||||||
|
lua_close(L);
|
||||||
|
nn_dealloc(alloc, s, sizeof(testLuaArch));
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -703,7 +707,7 @@ void testLuaArch_tick(nn_computer *computer, testLuaArch *arch, void *_) {
|
|||||||
} else {
|
} else {
|
||||||
const char *s = lua_tostring(arch->L, -1);
|
const char *s = lua_tostring(arch->L, -1);
|
||||||
nn_setError(computer, s);
|
nn_setError(computer, s);
|
||||||
lua_pop(arch->L, 1);
|
lua_pop(arch->L, ret);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user