From 29ad865fa6c938da89ac2af3d70e70d7dbbe27ad Mon Sep 17 00:00:00 2001 From: Dan Cojocaru Date: Wed, 21 Feb 2024 19:07:32 +0100 Subject: [PATCH] Allow build on Linux --- build.zig | 26 +++++++++++++++++++------- src/departure.zig | 2 +- 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/build.zig b/build.zig index 445d565..02b7999 100644 --- a/build.zig +++ b/build.zig @@ -31,7 +31,11 @@ pub fn build(b: *std.Build) void { // exe.linkSystemLibrary("raylib"); exe.linkSystemLibrary("curl"); exe.addObjectFile(.{ - .cwd_relative = "/opt/homebrew/Cellar/raylib/5.0/lib/libraylib.a", + .cwd_relative = switch (target.result.os.tag) { + .macos => "/opt/homebrew/Cellar/raylib/5.0/lib/libraylib.a", + .linux => "./libraylib.a", + else => @panic("Unsupported platform"), + }, }); // exe.addObjectFile(.{ // .cwd_relative = "/opt/homebrew/Cellar/curl/8.5.0/lib/libcurl.a", @@ -40,12 +44,20 @@ pub fn build(b: *std.Build) void { .cwd_relative = "/opt/homebrew/Cellar/raylib/5.0/include", }); // Raylib dependencies - exe.linkFramework("Foundation"); - exe.linkFramework("CoreVideo"); - exe.linkFramework("IOKit"); - exe.linkFramework("Cocoa"); - exe.linkFramework("GLUT"); - exe.linkFramework("OpenGL"); + switch (target.result.os.tag) { + .macos => { + exe.linkFramework("Foundation"); + exe.linkFramework("CoreVideo"); + exe.linkFramework("IOKit"); + exe.linkFramework("Cocoa"); + exe.linkFramework("GLUT"); + exe.linkFramework("OpenGL"); + }, + .linux => { + exe.linkSystemLibrary("c"); + }, + else => @panic("Unsupported platform"), + } // This declares intent for the executable to be installed into the // standard location when the user invokes the "install" step (the default diff --git a/src/departure.zig b/src/departure.zig index dea6b02..e5a8e1d 100644 --- a/src/departure.zig +++ b/src/departure.zig @@ -4,7 +4,7 @@ const rl = raylib.rl; const AppState = @import("state.zig"); const Curl = @import("curl.zig"); const C = @cImport({ - @cDefine("_XOPEN_SOURE", ""); + @cDefine("_XOPEN_SOURCE", ""); @cInclude("time.h"); });