mirror of https://github.com/raysan5/raylib
Add macos support to zig build system (#2175)
This commit is contained in:
parent
2b2141902b
commit
71f2e2b1e4
|
@ -21,13 +21,20 @@ fn add_module(comptime module: []const u8, b: *std.build.Builder, target: std.zi
|
|||
// zig's mingw headers do not include pthread.h
|
||||
if (std.mem.eql(u8, "core_loading_thread", name) and target.getOsTag() == .windows) continue;
|
||||
|
||||
const exe = b.addExecutable(name, path);
|
||||
const exe = b.addExecutable(name, null);
|
||||
exe.addCSourceFile(path, switch (target.getOsTag()) {
|
||||
.windows => &[_][]const u8{},
|
||||
.linux => &[_][]const u8{},
|
||||
.macos => &[_][]const u8{"-DPLATFORM_DESKTOP"},
|
||||
else => @panic("Unsupported OS"),
|
||||
});
|
||||
exe.setTarget(target);
|
||||
exe.setBuildMode(mode);
|
||||
exe.linkLibC();
|
||||
exe.addObjectFile(switch (target.getOsTag()) {
|
||||
.windows => "../src/raylib.lib",
|
||||
.linux => "../src/libraylib.a",
|
||||
.macos => "../src/libraylib.a",
|
||||
else => @panic("Unsupported OS"),
|
||||
});
|
||||
|
||||
|
@ -49,6 +56,14 @@ fn add_module(comptime module: []const u8, b: *std.build.Builder, target: std.zi
|
|||
exe.linkSystemLibrary("m");
|
||||
exe.linkSystemLibrary("X11");
|
||||
},
|
||||
.macos => {
|
||||
exe.linkFramework("Foundation");
|
||||
exe.linkFramework("Cocoa");
|
||||
exe.linkFramework("OpenGL");
|
||||
exe.linkFramework("CoreAudio");
|
||||
exe.linkFramework("CoreVideo");
|
||||
exe.linkFramework("IOKit");
|
||||
},
|
||||
else => {
|
||||
@panic("Unsupported OS");
|
||||
},
|
||||
|
|
|
@ -28,7 +28,6 @@ pub fn build(b: *std.build.Builder) void {
|
|||
raylib.addCSourceFiles(&.{
|
||||
"raudio.c",
|
||||
"rcore.c",
|
||||
"rglfw.c",
|
||||
"rmodels.c",
|
||||
"rshapes.c",
|
||||
"rtext.c",
|
||||
|
@ -38,18 +37,31 @@ pub fn build(b: *std.build.Builder) void {
|
|||
|
||||
switch (raylib.target.toTarget().os.tag) {
|
||||
.windows => {
|
||||
raylib.addCSourceFiles(&.{"rglfw.c"}, raylib_flags);
|
||||
raylib.linkSystemLibrary("winmm");
|
||||
raylib.linkSystemLibrary("gdi32");
|
||||
raylib.linkSystemLibrary("opengl32");
|
||||
raylib.addIncludeDir("external/glfw/deps/mingw");
|
||||
},
|
||||
.linux => {
|
||||
raylib.addCSourceFiles(&.{"rglfw.c"}, raylib_flags);
|
||||
raylib.linkSystemLibrary("GL");
|
||||
raylib.linkSystemLibrary("rt");
|
||||
raylib.linkSystemLibrary("dl");
|
||||
raylib.linkSystemLibrary("m");
|
||||
raylib.linkSystemLibrary("X11");
|
||||
},
|
||||
.macos => {
|
||||
// On macos rglfw.c include Objective-C files.
|
||||
const raylib_flags_extra_macos = &[_][]const u8{
|
||||
"-ObjC",
|
||||
};
|
||||
raylib.addCSourceFiles(
|
||||
&.{"rglfw.c"},
|
||||
raylib_flags ++ raylib_flags_extra_macos,
|
||||
);
|
||||
raylib.linkFramework("Foundation");
|
||||
},
|
||||
else => {
|
||||
@panic("Unsupported OS");
|
||||
},
|
||||
|
|
Loading…
Reference in New Issue