Skip to content

Commit 6610ab0

Browse files
committed
build.zig: Avoid deprecated function std.Build.Step.Compile.defineCMacro
1 parent c400e55 commit 6610ab0

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

build.zig

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,12 @@ pub fn addRaylib(b: *std.Build, target: std.Build.ResolvedTarget, optimize: std.
4242
}
4343

4444
fn setDesktopPlatform(raylib: *std.Build.Step.Compile, platform: PlatformBackend) void {
45-
raylib.defineCMacro("PLATFORM_DESKTOP", null);
45+
raylib.root_module.addCMacro("PLATFORM_DESKTOP", "1");
4646

4747
switch (platform) {
48-
.glfw => raylib.defineCMacro("PLATFORM_DESKTOP_GLFW", null),
49-
.rgfw => raylib.defineCMacro("PLATFORM_DESKTOP_RGFW", null),
50-
.sdl => raylib.defineCMacro("PLATFORM_DESKTOP_SDL", null),
48+
.glfw => raylib.root_module.addCMacro("PLATFORM_DESKTOP_GLFW", "1"),
49+
.rgfw => raylib.root_module.addCMacro("PLATFORM_DESKTOP_RGFW", "1"),
50+
.sdl => raylib.root_module.addCMacro("PLATFORM_DESKTOP_SDL", "1"),
5151
else => {},
5252
}
5353
}
@@ -84,7 +84,7 @@ const config_h_flags = outer: {
8484

8585
// Set to 1 if no value is provided
8686
var value = strs.next() orelse "1";
87-
value = if (std.mem.startsWith(u8, value, "//")) "1" else value;
87+
if (std.mem.startsWith(u8, value, "//")) value = "1";
8888

8989
flags[i] = .{ flag, value };
9090
i += 1;
@@ -192,7 +192,7 @@ fn compileRaylib(b: *std.Build, target: std.Build.ResolvedTarget, optimize: std.
192192
}
193193

194194
if (options.opengl_version != .auto) {
195-
raylib.defineCMacro(options.opengl_version.toCMacroStr(), null);
195+
raylib.root_module.addCMacro(options.opengl_version.toCMacroStr(), "1");
196196
}
197197

198198
switch (target.result.os.tag) {
@@ -215,7 +215,7 @@ fn compileRaylib(b: *std.Build, target: std.Build.ResolvedTarget, optimize: std.
215215
raylib.addLibraryPath(.{ .cwd_relative = "/usr/lib" });
216216
raylib.addIncludePath(.{ .cwd_relative = "/usr/include" });
217217
if (options.linux_display_backend == .X11 or options.linux_display_backend == .Both) {
218-
raylib.defineCMacro("_GLFW_X11", null);
218+
raylib.root_module.addCMacro("_GLFW_X11", "1");
219219
raylib.linkSystemLibrary("X11");
220220
}
221221

@@ -227,7 +227,7 @@ fn compileRaylib(b: *std.Build, target: std.Build.ResolvedTarget, optimize: std.
227227
, .{});
228228
@panic("`wayland-scanner` not found");
229229
};
230-
raylib.defineCMacro("_GLFW_WAYLAND", null);
230+
raylib.root_module.addCMacro("_GLFW_WAYLAND", "1");
231231
raylib.linkSystemLibrary("wayland-client");
232232
raylib.linkSystemLibrary("wayland-cursor");
233233
raylib.linkSystemLibrary("wayland-egl");
@@ -246,7 +246,7 @@ fn compileRaylib(b: *std.Build, target: std.Build.ResolvedTarget, optimize: std.
246246
} else {
247247
if (options.opengl_version == .auto) {
248248
raylib.linkSystemLibrary("GLESv2");
249-
raylib.defineCMacro("GRAPHICS_API_OPENGL_ES2", null);
249+
raylib.root_module.addCMacro("GRAPHICS_API_OPENGL_ES2", "1");
250250
}
251251

252252
raylib.linkSystemLibrary("EGL");
@@ -258,9 +258,9 @@ fn compileRaylib(b: *std.Build, target: std.Build.ResolvedTarget, optimize: std.
258258
raylib.linkSystemLibrary("dl");
259259
raylib.addIncludePath(.{ .cwd_relative = "/usr/include/libdrm" });
260260

261-
raylib.defineCMacro("PLATFORM_DRM", null);
262-
raylib.defineCMacro("EGL_NO_X11", null);
263-
raylib.defineCMacro("DEFAULT_BATCH_BUFFER_ELEMENT", "2048");
261+
raylib.root_module.addCMacro("PLATFORM_DRM", "1");
262+
raylib.root_module.addCMacro("EGL_NO_X11", "1");
263+
raylib.root_module.addCMacro("DEFAULT_BATCH_BUFFER_ELEMENT", "2048");
264264
}
265265
},
266266
.freebsd, .openbsd, .netbsd, .dragonfly => {
@@ -295,9 +295,9 @@ fn compileRaylib(b: *std.Build, target: std.Build.ResolvedTarget, optimize: std.
295295
setDesktopPlatform(raylib, options.platform);
296296
},
297297
.emscripten => {
298-
raylib.defineCMacro("PLATFORM_WEB", null);
298+
raylib.root_module.addCMacro("PLATFORM_WEB", "1");
299299
if (options.opengl_version == .auto) {
300-
raylib.defineCMacro("GRAPHICS_API_OPENGL_ES2", null);
300+
raylib.root_module.addCMacro("GRAPHICS_API_OPENGL_ES2", "1");
301301
}
302302

303303
if (b.sysroot == null) {

0 commit comments

Comments
 (0)