mirror of
https://github.com/NeoFlock/neonucleus.git
synced 2025-09-24 09:03:32 +02:00
changes
This commit is contained in:
parent
20a149cc28
commit
833d919066
92
build.zig
92
build.zig
@ -5,6 +5,7 @@ const LibBuildOpts = struct {
|
|||||||
target: std.Build.ResolvedTarget,
|
target: std.Build.ResolvedTarget,
|
||||||
optimize: std.builtin.OptimizeMode,
|
optimize: std.builtin.OptimizeMode,
|
||||||
baremetal: bool,
|
baremetal: bool,
|
||||||
|
bit32: bool,
|
||||||
};
|
};
|
||||||
|
|
||||||
fn addEngineSources(b: *std.Build, opts: LibBuildOpts) *std.Build.Module {
|
fn addEngineSources(b: *std.Build, opts: LibBuildOpts) *std.Build.Module {
|
||||||
@ -34,6 +35,7 @@ fn addEngineSources(b: *std.Build, opts: LibBuildOpts) *std.Build.Module {
|
|||||||
},
|
},
|
||||||
.flags = &.{
|
.flags = &.{
|
||||||
if(opts.baremetal) "-DNN_BAREMETAL" else "",
|
if(opts.baremetal) "-DNN_BAREMETAL" else "",
|
||||||
|
if(opts.bit32) "-DNN_BIT32" else "",
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -108,8 +110,11 @@ pub fn build(b: *std.Build) void {
|
|||||||
.target = target,
|
.target = target,
|
||||||
.optimize = optimize,
|
.optimize = optimize,
|
||||||
.baremetal = b.option(bool, "baremetal", "Compiles without libc integration") orelse false,
|
.baremetal = b.option(bool, "baremetal", "Compiles without libc integration") orelse false,
|
||||||
|
.bit32 = target.result.ptrBitWidth() == 32,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const noEmu = b.option(bool, "noEmu", "Disable compiling the emulator (fixes some build system quirks)") orelse false;
|
||||||
|
|
||||||
const includeFiles = b.addInstallHeaderFile(b.path("src/neonucleus.h"), "neonucleus.h");
|
const includeFiles = b.addInstallHeaderFile(b.path("src/neonucleus.h"), "neonucleus.h");
|
||||||
|
|
||||||
const engineMod = addEngineSources(b, opts);
|
const engineMod = addEngineSources(b, opts);
|
||||||
@ -134,48 +139,51 @@ pub fn build(b: *std.Build) void {
|
|||||||
sharedStep.dependOn(&includeFiles.step);
|
sharedStep.dependOn(&includeFiles.step);
|
||||||
sharedStep.dependOn(&b.addInstallArtifact(engineShared, .{}).step);
|
sharedStep.dependOn(&b.addInstallArtifact(engineShared, .{}).step);
|
||||||
|
|
||||||
const emulator = b.addExecutable(.{
|
if(!noEmu) {
|
||||||
.name = "neonucleus",
|
const emulator = b.addExecutable(.{
|
||||||
.target = target,
|
.name = "neonucleus",
|
||||||
.optimize = optimize,
|
.target = target,
|
||||||
});
|
.optimize = optimize,
|
||||||
emulator.linkLibC();
|
});
|
||||||
|
emulator.linkLibC();
|
||||||
|
|
||||||
const sysraylib_flag = b.option(bool, "sysraylib", "Use the system raylib instead of compiling raylib") orelse false;
|
const sysraylib_flag = b.option(bool, "sysraylib", "Use the system raylib instead of compiling raylib") orelse false;
|
||||||
if (sysraylib_flag) {
|
if (sysraylib_flag) {
|
||||||
emulator.linkSystemLibrary("raylib");
|
emulator.linkSystemLibrary("raylib");
|
||||||
} else {
|
} else {
|
||||||
const raylib = b.dependency("raylib", .{ .target = target, .optimize = optimize });
|
const raylib = b.dependency("raylib", .{ .target = target, .optimize = optimize });
|
||||||
emulator.addIncludePath(raylib.path(raylib.builder.h_dir));
|
emulator.addIncludePath(raylib.path(raylib.builder.h_dir));
|
||||||
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;
|
||||||
|
emulator.addCSourceFiles(.{
|
||||||
|
.files = &.{
|
||||||
|
"src/testLuaArch.c",
|
||||||
|
"src/emulator.c",
|
||||||
|
},
|
||||||
|
.flags = &.{
|
||||||
|
if(opts.baremetal) "-DNN_BAREMETAL" else "",
|
||||||
|
if(opts.bit32) "-DNN_BIT32" else "",
|
||||||
|
},
|
||||||
|
});
|
||||||
|
compileTheRightLua(b, emulator, luaVer) catch unreachable;
|
||||||
|
|
||||||
|
// forces us to link in everything too
|
||||||
|
emulator.linkLibrary(engineStatic);
|
||||||
|
|
||||||
|
const emulatorStep = b.step("emulator", "Builds the emulator");
|
||||||
|
emulatorStep.dependOn(&emulator.step);
|
||||||
|
emulatorStep.dependOn(&b.addInstallArtifact(emulator, .{}).step);
|
||||||
|
|
||||||
|
var run_cmd = b.addRunArtifact(emulator);
|
||||||
|
|
||||||
|
if (b.args) |args| {
|
||||||
|
run_cmd.addArgs(args);
|
||||||
|
}
|
||||||
|
|
||||||
|
const run_step = b.step("run", "Run the emulator");
|
||||||
|
run_step.dependOn(emulatorStep);
|
||||||
|
run_step.dependOn(&run_cmd.step);
|
||||||
}
|
}
|
||||||
|
|
||||||
const luaVer = b.option(LuaVersion, "lua", "The version of Lua to use.") orelse LuaVersion.lua54;
|
|
||||||
emulator.addCSourceFiles(.{
|
|
||||||
.files = &.{
|
|
||||||
"src/testLuaArch.c",
|
|
||||||
"src/emulator.c",
|
|
||||||
},
|
|
||||||
.flags = &.{
|
|
||||||
if(opts.baremetal) "-DNN_BAREMETAL" else "",
|
|
||||||
},
|
|
||||||
});
|
|
||||||
compileTheRightLua(b, emulator, luaVer) catch unreachable;
|
|
||||||
|
|
||||||
// forces us to link in everything too
|
|
||||||
emulator.linkLibrary(engineStatic);
|
|
||||||
|
|
||||||
const emulatorStep = b.step("emulator", "Builds the emulator");
|
|
||||||
emulatorStep.dependOn(&emulator.step);
|
|
||||||
emulatorStep.dependOn(&b.addInstallArtifact(emulator, .{}).step);
|
|
||||||
|
|
||||||
var run_cmd = b.addRunArtifact(emulator);
|
|
||||||
|
|
||||||
if (b.args) |args| {
|
|
||||||
run_cmd.addArgs(args);
|
|
||||||
}
|
|
||||||
|
|
||||||
const run_step = b.step("run", "Run the emulator");
|
|
||||||
run_step.dependOn(emulatorStep);
|
|
||||||
run_step.dependOn(&run_cmd.step);
|
|
||||||
}
|
}
|
||||||
|
@ -10,11 +10,15 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef NN_BAREMETAL
|
#ifdef NN_BAREMETAL
|
||||||
#if defined(__LP64__) || defined(_LP64)
|
#ifdef NN_BIT32
|
||||||
|
typedef int nn_intptr_t;
|
||||||
|
typedef unsigned int nn_size_t;
|
||||||
|
#elif defined(__LP64__) || defined(_LP64)
|
||||||
// long is ptr sized
|
// long is ptr sized
|
||||||
typedef long nn_intptr_t;
|
typedef long nn_intptr_t;
|
||||||
typedef unsigned long nn_size_t;
|
typedef unsigned long nn_size_t;
|
||||||
#else
|
#else
|
||||||
|
#error "fuck you"
|
||||||
typedef long long nn_intptr_t;
|
typedef long long nn_intptr_t;
|
||||||
typedef unsigned long long nn_size_t;
|
typedef unsigned long long nn_size_t;
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user