mirror of
https://github.com/NeoFlock/neonucleus.git
synced 2025-11-14 14:34:26 +01:00
Merge pull request #24 from speedy-lex/fix-raylib-build
Revert "raylib submodule -> zig dependency"
This commit is contained in:
commit
eefc7281bd
3
.gitmodules
vendored
3
.gitmodules
vendored
@ -10,3 +10,6 @@
|
|||||||
path = foreign/lua54
|
path = foreign/lua54
|
||||||
url = https://github.com/lua/lua
|
url = https://github.com/lua/lua
|
||||||
branch = v5.4
|
branch = v5.4
|
||||||
|
[submodule "foreign/raylib"]
|
||||||
|
path = foreign/raylib
|
||||||
|
url = https://github.com/raysan5/raylib
|
||||||
|
|||||||
50
build.zig
50
build.zig
@ -13,8 +13,8 @@ fn addEngineSources(b: *std.Build, opts: LibBuildOpts) *std.Build.Module {
|
|||||||
.root_source_file = b.path("src/data.zig"),
|
.root_source_file = b.path("src/data.zig"),
|
||||||
.target = opts.target,
|
.target = opts.target,
|
||||||
.optimize = opts.optimize,
|
.optimize = opts.optimize,
|
||||||
.strip = if(opts.optimize == .Debug) false else true,
|
.strip = if (opts.optimize == .Debug) false else true,
|
||||||
.unwind_tables = if(opts.optimize == .Debug) null else .none,
|
.unwind_tables = if (opts.optimize == .Debug) null else .none,
|
||||||
.pic = true,
|
.pic = true,
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -49,17 +49,17 @@ fn addEngineSources(b: *std.Build, opts: LibBuildOpts) *std.Build.Module {
|
|||||||
"src/components/externalComputer.c",
|
"src/components/externalComputer.c",
|
||||||
},
|
},
|
||||||
.flags = &.{
|
.flags = &.{
|
||||||
if(opts.baremetal) "-DNN_BAREMETAL" else "",
|
if (opts.baremetal) "-DNN_BAREMETAL" else "",
|
||||||
if(opts.bit32) "-DNN_BIT32" else "",
|
if (opts.bit32) "-DNN_BIT32" else "",
|
||||||
if(strict) "-Wall" else "",
|
if (strict) "-Wall" else "",
|
||||||
if(strict) "-Werror" else "",
|
if (strict) "-Werror" else "",
|
||||||
"-std=gnu23",
|
"-std=gnu23",
|
||||||
"-Wno-keyword-macro", // cuz bools
|
"-Wno-keyword-macro", // cuz bools
|
||||||
"-fPIE",
|
"-fPIE",
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
if(!opts.baremetal) {
|
if (!opts.baremetal) {
|
||||||
dataMod.link_libc = true; // we need a libc
|
dataMod.link_libc = true; // we need a libc
|
||||||
dataMod.addCSourceFiles(.{
|
dataMod.addCSourceFiles(.{
|
||||||
.files = &.{
|
.files = &.{
|
||||||
@ -82,6 +82,22 @@ const LuaVersion = enum {
|
|||||||
lua54,
|
lua54,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
fn compileRaylib(b: *std.Build, os: std.Target.Os.Tag, c: *std.Build.Step.Compile) void {
|
||||||
|
// TODO: find out how to send our target to this build cmd
|
||||||
|
const raylib = b.addSystemCommand(&.{ "zig", "build" });
|
||||||
|
raylib.setCwd(b.path("foreign/raylib/"));
|
||||||
|
raylib.stdio = .inherit;
|
||||||
|
|
||||||
|
c.step.dependOn(&raylib.step);
|
||||||
|
c.addIncludePath(b.path("foreign/raylib/zig-out/include/"));
|
||||||
|
c.addLibraryPath(b.path("foreign/raylib/zig-out/lib/"));
|
||||||
|
c.linkSystemLibrary("raylib");
|
||||||
|
if (os == .windows) {
|
||||||
|
c.linkSystemLibrary("WinMM");
|
||||||
|
c.linkSystemLibrary("GDI32");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// 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
|
||||||
|
|
||||||
@ -106,7 +122,7 @@ fn compileTheRightLua(b: *std.Build, target: std.Build.ResolvedTarget, version:
|
|||||||
var files = try std.ArrayList([]const u8).initCapacity(b.allocator, 0);
|
var files = try std.ArrayList([]const u8).initCapacity(b.allocator, 0);
|
||||||
errdefer files.deinit(b.allocator);
|
errdefer files.deinit(b.allocator);
|
||||||
|
|
||||||
var dir = try std.fs.cwd().openDir(rootPath, std.fs.Dir.OpenOptions { .iterate = true });
|
var dir = try std.fs.cwd().openDir(rootPath, std.fs.Dir.OpenOptions{ .iterate = true });
|
||||||
defer dir.close();
|
defer dir.close();
|
||||||
|
|
||||||
var iter = dir.iterate();
|
var iter = dir.iterate();
|
||||||
@ -142,7 +158,7 @@ pub fn build(b: *std.Build) !void {
|
|||||||
|
|
||||||
const optimize = b.standardOptimizeOption(.{});
|
const optimize = b.standardOptimizeOption(.{});
|
||||||
|
|
||||||
const opts = LibBuildOpts {
|
const opts = LibBuildOpts{
|
||||||
.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,
|
||||||
@ -152,7 +168,7 @@ pub fn build(b: *std.Build) !void {
|
|||||||
const noEmu = b.option(bool, "noEmu", "Disable compiling the emulator (fixes some build system quirks)") orelse false;
|
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);
|
||||||
|
|
||||||
const engineStatic = b.addLibrary(.{
|
const engineStatic = b.addLibrary(.{
|
||||||
@ -160,9 +176,9 @@ pub fn build(b: *std.Build) !void {
|
|||||||
.root_module = engineMod,
|
.root_module = engineMod,
|
||||||
.linkage = .static,
|
.linkage = .static,
|
||||||
});
|
});
|
||||||
|
|
||||||
const engineShared = b.addLibrary(.{
|
const engineShared = b.addLibrary(.{
|
||||||
.name = if(os == .windows) "neonucleusdll" else "neonucleus",
|
.name = if (os == .windows) "neonucleusdll" else "neonucleus",
|
||||||
.root_module = engineMod,
|
.root_module = engineMod,
|
||||||
.linkage = .dynamic,
|
.linkage = .dynamic,
|
||||||
});
|
});
|
||||||
@ -177,7 +193,7 @@ 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);
|
||||||
|
|
||||||
if(!noEmu) {
|
if (!noEmu) {
|
||||||
const emulator = b.addExecutable(.{
|
const emulator = b.addExecutable(.{
|
||||||
.name = "neonucleus",
|
.name = "neonucleus",
|
||||||
.root_module = b.addModule("emulator", .{
|
.root_module = b.addModule("emulator", .{
|
||||||
@ -191,9 +207,7 @@ pub fn build(b: *std.Build) !void {
|
|||||||
if (sysraylib_flag) {
|
if (sysraylib_flag) {
|
||||||
emulator.linkSystemLibrary("raylib");
|
emulator.linkSystemLibrary("raylib");
|
||||||
} else {
|
} else {
|
||||||
const raylib = b.dependency("raylib", .{ .target = target, .optimize = optimize });
|
compileRaylib(b, os, emulator);
|
||||||
emulator.addIncludePath(raylib.path(raylib.builder.h_dir));
|
|
||||||
emulator.linkLibrary(raylib.artifact("raylib"));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const luaVer = b.option(LuaVersion, "lua", "The version of Lua to use.") orelse LuaVersion.lua53;
|
const luaVer = b.option(LuaVersion, "lua", "The version of Lua to use.") orelse LuaVersion.lua53;
|
||||||
@ -203,8 +217,8 @@ pub fn build(b: *std.Build) !void {
|
|||||||
"src/emulator.c",
|
"src/emulator.c",
|
||||||
},
|
},
|
||||||
.flags = &.{
|
.flags = &.{
|
||||||
if(opts.baremetal) "-DNN_BAREMETAL" else "",
|
if (opts.baremetal) "-DNN_BAREMETAL" else "",
|
||||||
if(opts.bit32) "-DNN_BIT32" else "",
|
if (opts.bit32) "-DNN_BIT32" else "",
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
const l = try compileTheRightLua(b, target, luaVer);
|
const l = try compileTheRightLua(b, target, luaVer);
|
||||||
|
|||||||
@ -1,13 +0,0 @@
|
|||||||
.{
|
|
||||||
.name = .neonucleus,
|
|
||||||
.fingerprint = 0xc9c7605b6b82f1a7,
|
|
||||||
.version = "0.0.1",
|
|
||||||
.paths = .{ "data", "build.zig", "build.zig.zon", "src" },
|
|
||||||
|
|
||||||
.dependencies = .{
|
|
||||||
.raylib = .{
|
|
||||||
.url = "https://github.com/raysan5/raylib/archive/46f01e315d07d0b1fedd1a3c388d1acaa9f6ccd6.tar.gz",
|
|
||||||
.hash = "raylib-5.5.0-whq8uO5uNgRDK_yuN0AGftGhWSVyctgPQNALENrZHt3k",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
|
||||||
1
foreign/raylib
Submodule
1
foreign/raylib
Submodule
@ -0,0 +1 @@
|
|||||||
|
Subproject commit 6f1077737e48d447380cf5573adf1394dfe3aac6
|
||||||
Loading…
x
Reference in New Issue
Block a user