@@ -212,6 +212,12 @@ pub fn build(b: *std.Build) void {
212
212
const test_step = b .step ("test" , "Run zsdl tests" );
213
213
test_step .dependOn (runTests (b , optimize , target ));
214
214
215
+ const version_check_step = b .step ("version-check" , "checks runtime library version is the same as the compiled version" );
216
+ version_check_step .dependOn (testStep ("src/sdl2_version_check.zig" , b , "zsdl-sdl2-version-check" , target , optimize , .{
217
+ .api_version = .sdl2 ,
218
+ .enable_ttf = true ,
219
+ }));
220
+
215
221
_ = package (b , target , optimize , .{
216
222
.options = .{
217
223
.api_version = b .option (ApiVersion , "api_version" , "Select an SDL API version" ) orelse .sdl2 ,
@@ -227,13 +233,13 @@ pub fn runTests(
227
233
const step = b .allocator .create (std .Build .Step ) catch @panic ("OOM" );
228
234
step .* = std .Build .Step .init (.{ .id = .custom , .name = "zsdl-tests" , .owner = b });
229
235
230
- step .dependOn (testStep (b , "zsdl-tests-sdl2" , target , optimize , .{
236
+ step .dependOn (testStep ("src/zsdl.zig" , b , "zsdl-tests-sdl2" , target , optimize , .{
231
237
.api_version = .sdl2 ,
232
238
.enable_ttf = true ,
233
239
}));
234
240
235
241
// TODO: link SDL3 libs on all platforms
236
- // step.dependOn(testStep(b, "zsdl-tests-sdl3", target, optimize, .{
242
+ // step.dependOn(testStep("src/zsdl.zig", b, "zsdl-tests-sdl3", target, optimize, .{
237
243
// .api_version = .sdl3,
238
244
// .enable_ttf = true,
239
245
// }));
@@ -242,6 +248,7 @@ pub fn runTests(
242
248
}
243
249
244
250
fn testStep (
251
+ comptime test_entry : []const u8 ,
245
252
b : * std.Build ,
246
253
name : []const u8 ,
247
254
target : std.Build.ResolvedTarget ,
@@ -250,14 +257,22 @@ fn testStep(
250
257
) * std.Build.Step {
251
258
const tests = b .addTest (.{
252
259
.name = name ,
253
- .root_source_file = .{ .path = thisDir () ++ "/src/zsdl.zig" },
260
+ .root_source_file = .{ .path = thisDir () ++ "/" ++ test_entry },
254
261
.target = target ,
255
262
.optimize = optimize ,
256
263
});
257
264
const pkg = package (b , target , optimize , .{ .options = options });
258
265
pkg .link (tests );
259
- tests .addRPath (.{ .path = b .getInstallPath (.bin , "" ) });
260
- return & b .addRunArtifact (tests ).step ;
266
+ var test_run = b .addRunArtifact (tests );
267
+ switch (target .result .os .tag ) {
268
+ .windows = > test_run .setCwd (.{
269
+ .path = b .getInstallPath (.bin , "" ),
270
+ }),
271
+ else = > tests .addRPath (.{
272
+ .path = b .getInstallPath (.bin , "" ),
273
+ }),
274
+ }
275
+ return & test_run .step ;
261
276
}
262
277
263
278
inline fn thisDir () []const u8 {
0 commit comments