@@ -34,7 +34,6 @@ pub fn addRaylib(b: *std.Build, target: std.Build.ResolvedTarget, optimize: std.
34
34
.shared = options .shared ,
35
35
.linux_display_backend = options .linux_display_backend ,
36
36
.opengl_version = options .opengl_version ,
37
- // TODO: Fix the type mismatch caused here due to unsupported `?[]const u8`.
38
37
.config = options .config ,
39
38
});
40
39
const raylib = raylib_dep .artifact ("raylib" );
@@ -86,7 +85,7 @@ fn compileRaylib(b: *std.Build, target: std.Build.ResolvedTarget, optimize: std.
86
85
"-DGL_SILENCE_DEPRECATION=199309L" ,
87
86
"-fno-sanitize=undefined" , // https://github.com/raysan5/raylib/issues/3674
88
87
});
89
- if (options .config ) | config | {
88
+ if (options .config . len > 0 ) {
90
89
const file = b .pathJoin (&.{ srcDir (b ), "config.h" });
91
90
const content = try std .fs .cwd ().readFileAlloc (b .allocator , file , std .math .maxInt (usize ));
92
91
defer b .allocator .free (content );
@@ -104,14 +103,14 @@ fn compileRaylib(b: *std.Build, target: std.Build.ResolvedTarget, optimize: std.
104
103
flag = try std .fmt .allocPrint (b .allocator , "-D{s}" , .{flag }); // Prepend with -D
105
104
106
105
// If user specifies the flag skip it
107
- if (std .mem .containsAtLeast (u8 , config , 1 , flag )) continue ;
106
+ if (std .mem .containsAtLeast (u8 , options . config , 1 , flag )) continue ;
108
107
109
108
// Append default value from config.h to compile flags
110
109
try raylib_flags_arr .append (b .allocator , flag );
111
110
}
112
111
113
112
// Append config flags supplied by user to compile flags
114
- try raylib_flags_arr .append (b .allocator , config );
113
+ try raylib_flags_arr .append (b .allocator , options . config );
115
114
116
115
try raylib_flags_arr .append (b .allocator , "-DEXTERNAL_CONFIG_FLAGS" );
117
116
}
@@ -321,7 +320,7 @@ pub const Options = struct {
321
320
linux_display_backend : LinuxDisplayBackend = .Both ,
322
321
opengl_version : OpenglVersion = .auto ,
323
322
/// config should be a list of cflags, eg, "-DSUPPORT_CUSTOM_FRAME_CONTROL"
324
- config : ? []const u8 = null ,
323
+ config : []const u8 = &.{} ,
325
324
326
325
raygui_dependency_name : []const u8 = "raygui" ,
327
326
};
@@ -384,7 +383,7 @@ pub fn build(b: *std.Build) !void {
384
383
.shared = b .option (bool , "shared" , "Compile as shared library" ) orelse defaults .shared ,
385
384
.linux_display_backend = b .option (LinuxDisplayBackend , "linux_display_backend" , "Linux display backend to use" ) orelse defaults .linux_display_backend ,
386
385
.opengl_version = b .option (OpenglVersion , "opengl_version" , "OpenGL version to use" ) orelse defaults .opengl_version ,
387
- .config = b .option ([]const u8 , "config" , "Compile with custom define macros overriding config.h" ),
386
+ .config = b .option ([]const u8 , "config" , "Compile with custom define macros overriding config.h" ) orelse &.{} ,
388
387
};
389
388
390
389
const lib = try compileRaylib (b , target , optimize , options );
0 commit comments