Content-Length: 420989 | pFad | http://github.com/zig-gamedev/zig-gamedev/commit/e3dc04fd160aafca9e7167a0948a8176bf42e63f

F1 Merge pull request #513 from Pyrolistical/zsdl-use-cwd-over-rpath-on-… · zig-gamedev/zig-gamedev@e3dc04f · GitHub
Skip to content

Commit e3dc04f

Browse files
authored
Merge pull request #513 from Pyrolistical/zsdl-use-cwd-over-rpath-on-windows
[zsdl] handle windows case for #467 by setting cwd instead of rpath
2 parents f104298 + cb3d10b commit e3dc04f

File tree

3 files changed

+28
-7
lines changed

3 files changed

+28
-7
lines changed

build.zig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -269,9 +269,9 @@ fn tests(
269269
test_step.dependOn(zphysics.runTests(b, optimize, target));
270270
test_step.dependOn(zpool.runTests(b, optimize, target));
271271

272-
// TODO(hazeycode): Fix tests linking SDL on Windows and macOS
272+
// TODO(hazeycode): Fix tests linking SDL on macOS
273273
switch (target.result.os.tag) {
274-
.windows, .macos => {},
274+
.macos => {},
275275
else => test_step.dependOn(zsdl.runTests(b, optimize, target)),
276276
}
277277

libs/zsdl/build.zig

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,12 @@ pub fn build(b: *std.Build) void {
212212
const test_step = b.step("test", "Run zsdl tests");
213213
test_step.dependOn(runTests(b, optimize, target));
214214

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+
215221
_ = package(b, target, optimize, .{
216222
.options = .{
217223
.api_version = b.option(ApiVersion, "api_version", "Select an SDL API version") orelse .sdl2,
@@ -227,13 +233,13 @@ pub fn runTests(
227233
const step = b.allocator.create(std.Build.Step) catch @panic("OOM");
228234
step.* = std.Build.Step.init(.{ .id = .custom, .name = "zsdl-tests", .owner = b });
229235

230-
step.dependOn(testStep(b, "zsdl-tests-sdl2", target, optimize, .{
236+
step.dependOn(testStep("src/zsdl.zig", b, "zsdl-tests-sdl2", target, optimize, .{
231237
.api_version = .sdl2,
232238
.enable_ttf = true,
233239
}));
234240

235241
// 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, .{
237243
// .api_version = .sdl3,
238244
// .enable_ttf = true,
239245
// }));
@@ -242,6 +248,7 @@ pub fn runTests(
242248
}
243249

244250
fn testStep(
251+
comptime test_entry: []const u8,
245252
b: *std.Build,
246253
name: []const u8,
247254
target: std.Build.ResolvedTarget,
@@ -250,14 +257,22 @@ fn testStep(
250257
) *std.Build.Step {
251258
const tests = b.addTest(.{
252259
.name = name,
253-
.root_source_file = .{ .path = thisDir() ++ "/src/zsdl.zig" },
260+
.root_source_file = .{ .path = thisDir() ++ "/" ++ test_entry },
254261
.target = target,
255262
.optimize = optimize,
256263
});
257264
const pkg = package(b, target, optimize, .{ .options = options });
258265
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;
261276
}
262277

263278
inline fn thisDir() []const u8 {

libs/zsdl/src/sdl2_version_check.zig

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
const std = @import("std");
2+
const sdl2 = @import("sdl2.zig");
3+
4+
test "compiled version should be same as linked version" {
5+
try std.testing.expectEqual(sdl2.VERSION, sdl2.getVersion());
6+
}

0 commit comments

Comments
 (0)








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/zig-gamedev/zig-gamedev/commit/e3dc04fd160aafca9e7167a0948a8176bf42e63f

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy