Skip to content

Commit

Permalink
fix build.zig (#3433)
Browse files Browse the repository at this point in the history
for zig master (2023-10-17)
  • Loading branch information
ryupold authored Oct 17, 2023
1 parent d7d04a0 commit 9534f48
Showing 1 changed file with 55 additions and 28 deletions.
83 changes: 55 additions & 28 deletions src/build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -20,37 +20,55 @@ pub fn addRaylib(b: *std.Build, target: std.zig.CrossTarget, optimize: std.built
raylib.addIncludePath(.{ .path = srcdir ++ "/external/glfw/include" });
}

raylib.addCSourceFiles(&.{
srcdir ++ "/rcore.c",
srcdir ++ "/utils.c",
}, raylib_flags);
raylib.addCSourceFiles(.{
.files = &.{
srcdir ++ "/rcore.c",
srcdir ++ "/utils.c",
},
.flags = raylib_flags,
});

if (options.raudio) {
raylib.addCSourceFiles(&.{
srcdir ++ "/raudio.c",
}, raylib_flags);
raylib.addCSourceFiles(.{
.files = &.{
srcdir ++ "/raudio.c",
},
.flags = raylib_flags,
});
}
if (options.rmodels) {
raylib.addCSourceFiles(&.{
srcdir ++ "/rmodels.c",
}, &[_][]const u8{
"-fno-sanitize=undefined", // https://github.com/raysan5/raylib/issues/1891
} ++ raylib_flags);
raylib.addCSourceFiles(.{
.files = &.{
srcdir ++ "/rmodels.c",
},
.flags = &[_][]const u8{
"-fno-sanitize=undefined", // https://github.com/raysan5/raylib/issues/1891
} ++ raylib_flags,
});
}
if (options.rshapes) {
raylib.addCSourceFiles(&.{
srcdir ++ "/rshapes.c",
}, raylib_flags);
raylib.addCSourceFiles(.{
.files = &.{
srcdir ++ "/rshapes.c",
},
.flags = raylib_flags,
});
}
if (options.rtext) {
raylib.addCSourceFiles(&.{
srcdir ++ "/rtext.c",
}, raylib_flags);
raylib.addCSourceFiles(.{
.files = &.{
srcdir ++ "/rtext.c",
},
.flags = raylib_flags,
});
}
if (options.rtextures) {
raylib.addCSourceFiles(&.{
srcdir ++ "/rtextures.c",
}, raylib_flags);
raylib.addCSourceFiles(.{
.files = &.{
srcdir ++ "/rtextures.c",
},
.flags = raylib_flags,
});
}

var gen_step = b.addWriteFiles();
Expand All @@ -65,7 +83,10 @@ pub fn addRaylib(b: *std.Build, target: std.zig.CrossTarget, optimize: std.built

switch (target.getOsTag()) {
.windows => {
raylib.addCSourceFiles(&.{srcdir ++ "/rglfw.c"}, raylib_flags);
raylib.addCSourceFiles(.{
.files = &.{srcdir ++ "/rglfw.c"},
.flags = raylib_flags,
});
raylib.linkSystemLibrary("winmm");
raylib.linkSystemLibrary("gdi32");
raylib.linkSystemLibrary("opengl32");
Expand All @@ -75,7 +96,10 @@ pub fn addRaylib(b: *std.Build, target: std.zig.CrossTarget, optimize: std.built
},
.linux => {
if (!options.platform_drm) {
raylib.addCSourceFiles(&.{srcdir ++ "/rglfw.c"}, raylib_flags);
raylib.addCSourceFiles(.{
.files = &.{srcdir ++ "/rglfw.c"},
.flags = raylib_flags,
});
raylib.linkSystemLibrary("GL");
raylib.linkSystemLibrary("rt");
raylib.linkSystemLibrary("dl");
Expand Down Expand Up @@ -103,7 +127,10 @@ pub fn addRaylib(b: *std.Build, target: std.zig.CrossTarget, optimize: std.built
}
},
.freebsd, .openbsd, .netbsd, .dragonfly => {
raylib.addCSourceFiles(&.{srcdir ++ "/rglfw.c"}, raylib_flags);
raylib.addCSourceFiles(.{
.files = &.{srcdir ++ "/rglfw.c"},
.flags = raylib_flags,
});
raylib.linkSystemLibrary("GL");
raylib.linkSystemLibrary("rt");
raylib.linkSystemLibrary("dl");
Expand All @@ -122,10 +149,10 @@ pub fn addRaylib(b: *std.Build, target: std.zig.CrossTarget, optimize: std.built
const raylib_flags_extra_macos = &[_][]const u8{
"-ObjC",
};
raylib.addCSourceFiles(
&.{srcdir ++ "/rglfw.c"},
raylib_flags ++ raylib_flags_extra_macos,
);
raylib.addCSourceFiles(.{
.files = &.{srcdir ++ "/rglfw.c"},
.flags = raylib_flags ++ raylib_flags_extra_macos,
});
raylib.linkFramework("Foundation");
raylib.linkFramework("CoreServices");
raylib.linkFramework("CoreGraphics");
Expand Down

0 comments on commit 9534f48

Please sign in to comment.