build.zig: Use std.Build.Module.addCMacro
for config flags
This commit is contained in:
parent
e16d5ebc8e
commit
1d1b398379
44
build.zig
44
build.zig
@ -134,6 +134,25 @@ fn compileRaylib(b: *std.Build, target: std.Build.ResolvedTarget, optimize: std.
|
||||
"-DGL_SILENCE_DEPRECATION=199309L",
|
||||
"-fno-sanitize=undefined", // https://github.com/raysan5/raylib/issues/3674
|
||||
});
|
||||
|
||||
if (options.shared) {
|
||||
try raylib_flags_arr.appendSlice(b.allocator, shared_flags);
|
||||
}
|
||||
|
||||
const raylib = if (options.shared)
|
||||
b.addSharedLibrary(.{
|
||||
.name = "raylib",
|
||||
.target = target,
|
||||
.optimize = optimize,
|
||||
})
|
||||
else
|
||||
b.addStaticLibrary(.{
|
||||
.name = "raylib",
|
||||
.target = target,
|
||||
.optimize = optimize,
|
||||
});
|
||||
raylib.linkLibC();
|
||||
|
||||
if (options.config.len > 0) {
|
||||
// Sets a flag indiciating the use of a custom `config.h`
|
||||
try raylib_flags_arr.append(b.allocator, "-DEXTERNAL_CONFIG_FLAGS");
|
||||
@ -171,32 +190,11 @@ fn compileRaylib(b: *std.Build, target: std.Build.ResolvedTarget, optimize: std.
|
||||
if (u_flag_stripped.len == flag.len or u_flag_stripped[flag.len] == '=') continue :outer;
|
||||
}
|
||||
|
||||
// Otherwise, append default value from config.h to compile flags
|
||||
try raylib_flags_arr.append(
|
||||
b.allocator,
|
||||
b.fmt("-D{s}={s}", .{ flag, value }),
|
||||
);
|
||||
// Otherwise, apply the default values from config.h
|
||||
raylib.root_module.addCMacro(flag, value);
|
||||
}
|
||||
}
|
||||
|
||||
if (options.shared) {
|
||||
try raylib_flags_arr.appendSlice(b.allocator, shared_flags);
|
||||
}
|
||||
|
||||
const raylib = if (options.shared)
|
||||
b.addSharedLibrary(.{
|
||||
.name = "raylib",
|
||||
.target = target,
|
||||
.optimize = optimize,
|
||||
})
|
||||
else
|
||||
b.addStaticLibrary(.{
|
||||
.name = "raylib",
|
||||
.target = target,
|
||||
.optimize = optimize,
|
||||
});
|
||||
raylib.linkLibC();
|
||||
|
||||
// No GLFW required on PLATFORM_DRM
|
||||
if (options.platform != .drm) {
|
||||
raylib.addIncludePath(b.path("src/external/glfw/include"));
|
||||
|
Loading…
Reference in New Issue
Block a user