Compile + static link raylib on all platforms

This commit is contained in:
Speedy_Lex 2025-07-03 13:09:34 +02:00
parent 48e53a7261
commit f3f3c0b2f0
4 changed files with 22 additions and 11 deletions

1
.gitignore vendored
View File

@ -2,5 +2,4 @@
zig-out/
!data/.gitkeep
.vscode/
raylib/
*.log

3
.gitmodules vendored
View File

@ -10,3 +10,6 @@
path = foreign/lua54
url = https://github.com/lua/lua
branch = v5.4
[submodule "foreign/raylib"]
path = foreign/raylib
url = https://github.com/raysan5/raylib

View File

@ -31,6 +31,22 @@ const LuaVersion = enum {
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.
// This can be checked for with Lua's _VERSION
@ -110,16 +126,8 @@ pub fn build(b: *std.Build) void {
});
emulator.linkLibC();
if (os == .windows) {
// use the mingw-w64 version and copy files to raylib/
// get raylib from https://github.com/raysan5/raylib/releases
emulator.addIncludePath(b.path("raylib/include"));
emulator.addObjectFile(b.path("raylib/lib/libraylib.a"));
emulator.linkSystemLibrary("GDI32");
emulator.linkSystemLibrary("WinMM");
} else {
emulator.linkSystemLibrary("raylib");
}
compileRaylib(b, os, emulator);
const luaVer = b.option(LuaVersion, "lua", "The version of Lua to use.") orelse LuaVersion.lua54;
emulator.addCSourceFiles(.{
.files = &.{

1
foreign/raylib Submodule

@ -0,0 +1 @@
Subproject commit 46f01e315d07d0b1fedd1a3c388d1acaa9f6ccd6