@@ -97,52 +97,55 @@ fn link(
97
97
exe .linkLibrary (lib );
98
98
}
99
99
100
- var _raylib_lib_cache : ? * std.Build.Step.Compile = null ;
100
+ var _raygui_impl_cache : ? * std.Build.Step.WriteFile = null ;
101
+ var _raygui_impl_path_cache : ? std.Build.LazyPath = null ;
101
102
fn getRaylib (b : * std.Build , target : std.Build.ResolvedTarget , optimize : std.builtin.OptimizeMode , options : Options ) * std.Build.Step.Compile {
102
- if (_raylib_lib_cache ) | lib | return lib else {
103
- const raylib = b .dependency ("raylib" , .{
104
- .target = target ,
105
- .optimize = optimize ,
106
- .raudio = options .raudio ,
107
- .rmodels = options .rmodels ,
108
- .rshapes = options .rshapes ,
109
- .rtext = options .rtext ,
110
- .rtextures = options .rtextures ,
111
- .platform = options .platform ,
112
- .shared = options .shared ,
113
- .linux_display_backend = options .linux_display_backend ,
114
- .opengl_version = options .opengl_version ,
115
- });
103
+ if (_raygui_impl_cache == null ) {
104
+ var gen_step = b .addWriteFiles ();
116
105
117
- const lib = raylib .artifact ("raylib" );
106
+ _raygui_impl_cache = gen_step ;
107
+ _raygui_impl_path_cache = gen_step .add ("raygui.c" , "#define RAYGUI_IMPLEMENTATION\n #include \" raygui.h\" \n " );
108
+ }
118
109
119
- const raygui_dep = b .dependency ("raygui" , .{
120
- .target = target ,
121
- .optimize = optimize ,
122
- });
110
+ const raylib = b .dependency ("raylib" , .{
111
+ .target = target ,
112
+ .optimize = optimize ,
113
+ .raudio = options .raudio ,
114
+ .rmodels = options .rmodels ,
115
+ .rshapes = options .rshapes ,
116
+ .rtext = options .rtext ,
117
+ .rtextures = options .rtextures ,
118
+ .platform = options .platform ,
119
+ .shared = options .shared ,
120
+ .linux_display_backend = options .linux_display_backend ,
121
+ .opengl_version = options .opengl_version ,
122
+ });
123
123
124
- var gen_step = b .addWriteFiles ();
125
- lib .step .dependOn (& gen_step .step );
126
-
127
- const raygui_c_path = gen_step .add ("raygui.c" , "#define RAYGUI_IMPLEMENTATION\n #include \" raygui.h\" \n " );
128
- lib .addCSourceFile (.{
129
- .file = raygui_c_path ,
130
- .flags = &[_ ][]const u8 {
131
- "-std=gnu99" ,
132
- "-D_GNU_SOURCE" ,
133
- "-DGL_SILENCE_DEPRECATION=199309L" ,
134
- "-fno-sanitize=undefined" , // https://github.com/raysan5/raylib/issues/3674
135
- },
136
- });
137
- lib .addIncludePath (raylib .path ("src" ));
138
- lib .addIncludePath (raygui_dep .path ("src" ));
124
+ const lib = raylib .artifact ("raylib" );
139
125
140
- lib .installHeader (raygui_dep .path ("src/raygui.h" ), "raygui.h" );
126
+ const raygui_dep = b .dependency ("raygui" , .{
127
+ .target = target ,
128
+ .optimize = optimize ,
129
+ });
141
130
142
- b .installArtifact (lib );
143
- _raylib_lib_cache = lib ;
144
- return lib ;
145
- }
131
+ lib .step .dependOn (&(_raygui_impl_cache orelse unreachable ).step );
132
+
133
+ lib .addCSourceFile (.{
134
+ .file = (_raygui_impl_path_cache orelse unreachable ),
135
+ .flags = &[_ ][]const u8 {
136
+ "-std=gnu99" ,
137
+ "-D_GNU_SOURCE" ,
138
+ "-DGL_SILENCE_DEPRECATION=199309L" ,
139
+ "-fno-sanitize=undefined" , // https://github.com/raysan5/raylib/issues/3674
140
+ },
141
+ });
142
+ lib .addIncludePath (raylib .path ("src" ));
143
+ lib .addIncludePath (raygui_dep .path ("src" ));
144
+
145
+ lib .installHeader (raygui_dep .path ("src/raygui.h" ), "raygui.h" );
146
+
147
+ b .installArtifact (lib );
148
+ return lib ;
146
149
}
147
150
148
151
fn getModule (b : * std.Build , target : std.Build.ResolvedTarget , optimize : std.builtin.OptimizeMode ) * std.Build.Module {
0 commit comments