[build][zig] use addLibrary() and set root modules manually

These changes will be required by Zig version 0.15.0.
This commit is contained in:
Mike Will
2025-07-23 11:56:36 -04:00
parent 5434ae1100
commit dfa21c2d1f

View File

@@ -153,18 +153,14 @@ fn compileRaylib(b: *std.Build, target: std.Build.ResolvedTarget, optimize: std.
try raylib_flags_arr.appendSlice(&config_h_flags); try raylib_flags_arr.appendSlice(&config_h_flags);
} }
const raylib = if (options.shared) const raylib = b.addLibrary(.{
b.addSharedLibrary(.{ .name = "raylib",
.name = "raylib", .linkage = if (options.shared) .dynamic else .static,
.root_module = b.createModule(.{
.target = target, .target = target,
.optimize = optimize, .optimize = optimize,
}) }),
else });
b.addStaticLibrary(.{
.name = "raylib",
.target = target,
.optimize = optimize,
});
raylib.linkLibC(); raylib.linkLibC();
// No GLFW required on PLATFORM_DRM // No GLFW required on PLATFORM_DRM
@@ -550,10 +546,13 @@ fn addExamples(
if (std.mem.eql(u8, "core_loading_thread", name) and target.result.os.tag == .windows) continue; if (std.mem.eql(u8, "core_loading_thread", name) and target.result.os.tag == .windows) continue;
if (target.result.os.tag == .emscripten) { if (target.result.os.tag == .emscripten) {
const exe_lib = b.addStaticLibrary(.{ const exe_lib = b.addLibrary(.{
.name = name, .name = name,
.target = target, .linkage = .static,
.optimize = optimize, .root_module = b.createModule(.{
.target = target,
.optimize = optimize,
}),
}); });
exe_lib.addCSourceFile(.{ exe_lib.addCSourceFile(.{
.file = b.path(path), .file = b.path(path),
@@ -633,8 +632,10 @@ fn addExamples(
} else { } else {
const exe = b.addExecutable(.{ const exe = b.addExecutable(.{
.name = name, .name = name,
.target = target, .root_module = b.createModule(.{
.optimize = optimize, .target = target,
.optimize = optimize,
}),
}); });
exe.addCSourceFile(.{ .file = b.path(path), .flags = &.{} }); exe.addCSourceFile(.{ .file = b.path(path), .flags = &.{} });
exe.linkLibC(); exe.linkLibC();