Revert "Fixed broken build.zig files. Now works with latest stable compiler (as of commit, latest is 0.10.1) (#3045)"

This reverts commit de748dfffe so that zig
build script works with master branch of zig.
This commit is contained in:
Talha Qamar 2023-05-14 05:07:34 +05:00
parent 5978358e58
commit ee5a1c4e34
2 changed files with 11 additions and 7 deletions

View File

@ -1,6 +1,6 @@
const std = @import("std"); const std = @import("std");
const raylib = @import("src/build.zig"); const raylib = @import("src/build.zig");
pub fn build(b: *std.build.Builder) void { pub fn build(b: *std.Build) void {
raylib.build(b); raylib.build(b);
} }

View File

@ -1,6 +1,6 @@
const std = @import("std"); const std = @import("std");
pub fn addRaylib(b: *std.build.Builder, target: std.zig.CrossTarget) *std.build.LibExeObjStep { pub fn addRaylib(b: *std.Build, target: std.zig.CrossTarget, optimize: std.builtin.OptimizeMode) *std.Build.CompileStep {
const raylib_flags = &[_][]const u8{ const raylib_flags = &[_][]const u8{
"-std=gnu99", "-std=gnu99",
"-D_GNU_SOURCE", "-D_GNU_SOURCE",
@ -8,7 +8,11 @@ pub fn addRaylib(b: *std.build.Builder, target: std.zig.CrossTarget) *std.build.
"-fno-sanitize=undefined", // https://github.com/raysan5/raylib/issues/1891 "-fno-sanitize=undefined", // https://github.com/raysan5/raylib/issues/1891
}; };
const raylib = b.addStaticLibrary("raylib", null); const raylib = b.addStaticLibrary(.{
.name = "raylib",
.target = target,
.optimize = optimize,
});
raylib.linkLibC(); raylib.linkLibC();
raylib.addIncludePath(srcdir ++ "/external/glfw/include"); raylib.addIncludePath(srcdir ++ "/external/glfw/include");
@ -99,7 +103,7 @@ pub fn addRaylib(b: *std.build.Builder, target: std.zig.CrossTarget) *std.build.
return raylib; return raylib;
} }
pub fn build(b: *std.build.Builder) void { pub fn build(b: *std.Build) void {
// Standard target options allows the person running `zig build` to choose // Standard target options allows the person running `zig build` to choose
// what target to build for. Here we do not override the defaults, which // what target to build for. Here we do not override the defaults, which
// means any target is allowed, and the default is native. Other options // means any target is allowed, and the default is native. Other options
@ -108,10 +112,10 @@ pub fn build(b: *std.build.Builder) void {
// Standard optimization options allow the person running `zig build` to select // Standard optimization options allow the person running `zig build` to select
// between Debug, ReleaseSafe, ReleaseFast, and ReleaseSmall. Here we do not // between Debug, ReleaseSafe, ReleaseFast, and ReleaseSmall. Here we do not
// set a preferred release mode, allowing the user to decide how to optimize. // set a preferred release mode, allowing the user to decide how to optimize.
// const optimize = b.standardReleaseOptions(); const optimize = b.standardOptimizeOption(.{});
const lib = addRaylib(b, target); const lib = addRaylib(b, target, optimize);
b.installFile("src/raylib.h", "raylib.h"); lib.installHeader("src/raylib.h", "raylib.h");
b.installArtifact(lib); b.installArtifact(lib);
} }