Make linking system raylib the first thing we do

This commit is contained in:
Not-Nik 2020-05-28 14:28:22 +10:00
parent 1e2b7c892e
commit 9891ade3ae
No known key found for this signature in database
GPG Key ID: 08BB71E672DB3BFD

18
lib.zig
View File

@ -6,12 +6,18 @@ pub fn Pkg(pkgdir: comptime []const u8) type {
return struct { return struct {
var ran_git = false; var ran_git = false;
pub fn link(exe: *LibExeObjStep, system_lib: bool) void { pub fn link(exe: *LibExeObjStep, system_lib: bool) void {
if (system_lib) {
exe.linkSystemLibrary("raylib");
return;
}
const raylibFlags = &[_][]const u8{ const raylibFlags = &[_][]const u8{
"-std=c99", "-std=c99",
"-DPLATFORM_DESKTOP", "-DPLATFORM_DESKTOP",
"-D_POSIX_C_SOURCE", "-D_POSIX_C_SOURCE",
"-DGL_SILENCE_DEPRECATION", "-DGL_SILENCE_DEPRECATION",
}; };
const target_os = exe.target.toTarget().os.tag; const target_os = exe.target.toTarget().os.tag;
switch (target_os) { switch (target_os) {
.windows => { .windows => {
@ -23,11 +29,8 @@ pub fn Pkg(pkgdir: comptime []const u8) type {
exe.addIncludeDir(pkgdir ++ "/raylib/src/external/glfw/deps/mingw"); exe.addIncludeDir(pkgdir ++ "/raylib/src/external/glfw/deps/mingw");
exe.addCSourceFile(pkgdir ++ "/raylib/src/rglfw.c", raylibFlags); exe.addCSourceFile(pkgdir ++ "/raylib/src/rglfw.c", raylibFlags);
}, },
.macosx => if (system_lib) { .macosx => {
std.debug.warn("TODO: add libraries necessary for system_lib linking on macosx (maybe just glfw?)", .{}); std.debug.warn("Compiling raylib is unsupported on macOS. Please add '-Dsystem-raylib=true' to your build command to use your system raylib.\n", .{});
std.os.exit(1);
} else {
std.debug.warn("compiling raylib is unsupported on macosx\n", .{});
std.os.exit(1); std.os.exit(1);
}, },
.freebsd, .openbsd, .netbsd, .dragonfly => { .freebsd, .openbsd, .netbsd, .dragonfly => {
@ -54,11 +57,6 @@ pub fn Pkg(pkgdir: comptime []const u8) type {
} }
exe.linkLibC(); exe.linkLibC();
if (system_lib) {
exe.linkSystemLibrary("raylib");
return;
}
fetchSubmodules(exe.builder) catch fetchSubmodules(exe.builder) catch
std.debug.warn( std.debug.warn(
\\Warning: \\Warning: