Skip to content

Commit 6b92d71

Browse files
authored
Reverted commits that deprecated the build.zig files, and added a note to all of them stating version of zig they were using (#3060)
* Revert "Fixed broken build.zig files. Now works with latest stable compiler (as of commit, latest is 0.10.1) (#3045)" This reverts commit de748df so that zig build script works with master branch of zig. * Added a note to build.zig files that denotes what version of zig they have been tested with. * Standardised the note in the build.zig files
1 parent 26a3536 commit 6b92d71

File tree

3 files changed

+11
-8
lines changed

3 files changed

+11
-8
lines changed

build.zig

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
const std = @import("std");
22
const raylib = @import("src/build.zig");
33

4-
pub fn build(b: *std.build.Builder) void {
4+
// This has been tested to work with zig master branch as of commit 87de821 or May 14 2023
5+
pub fn build(b: *std.Build) void {
56
raylib.build(b);
67
}

examples/build.zig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
const std = @import("std");
22
const builtin = @import("builtin");
33

4+
// This has been tested to work with zig master branch as of commit 87de821 or May 14 2023
45
fn add_module(comptime module: []const u8, b: *std.Build, target: std.zig.CrossTarget, optimize: std.builtin.OptimizeMode) !*std.Build.Step {
56
if (target.getOsTag() == .emscripten) {
67
@panic("Emscripten building via Zig unsupported");

src/build.zig

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
11
const std = @import("std");
22

3-
pub fn addRaylib(b: *std.build.Builder, target: std.zig.CrossTarget) *std.build.LibExeObjStep {
3+
// This has been tested to work with zig master branch as of commit 87de821 or May 14 2023
4+
pub fn addRaylib(b: *std.Build, target: std.zig.CrossTarget, optimize: std.builtin.OptimizeMode) *std.Build.CompileStep {
45
const raylib_flags = &[_][]const u8{
56
"-std=gnu99",
67
"-D_GNU_SOURCE",
78
"-DGL_SILENCE_DEPRECATION=199309L",
89
"-fno-sanitize=undefined", // https://github.com/raysan5/raylib/issues/1891
910
};
1011

11-
const raylib = b.addStaticLibrary(std.Build.StaticLibraryOptions{
12+
const raylib = b.addStaticLibrary(.{
1213
.name = "raylib",
1314
.target = target,
14-
.optimize = b.standardOptimizeOption(.{ .preferred_optimize_mode = .ReleaseSafe }),
15+
.optimize = optimize,
1516
});
1617
raylib.linkLibC();
1718

@@ -103,7 +104,7 @@ pub fn addRaylib(b: *std.build.Builder, target: std.zig.CrossTarget) *std.build.
103104
return raylib;
104105
}
105106

106-
pub fn build(b: *std.build.Builder) void {
107+
pub fn build(b: *std.Build) void {
107108
// Standard target options allows the person running `zig build` to choose
108109
// what target to build for. Here we do not override the defaults, which
109110
// means any target is allowed, and the default is native. Other options
@@ -112,10 +113,10 @@ pub fn build(b: *std.build.Builder) void {
112113
// Standard optimization options allow the person running `zig build` to select
113114
// between Debug, ReleaseSafe, ReleaseFast, and ReleaseSmall. Here we do not
114115
// set a preferred release mode, allowing the user to decide how to optimize.
115-
// const optimize = b.standardReleaseOptions();
116+
const optimize = b.standardOptimizeOption(.{});
116117

117-
const lib = addRaylib(b, target);
118-
b.installFile("src/raylib.h", "raylib.h");
118+
const lib = addRaylib(b, target, optimize);
119+
lib.installHeader("src/raylib.h", "raylib.h");
119120
b.installArtifact(lib);
120121
}
121122

0 commit comments

Comments
 (0)