Skip to content

Commit f0a3df9

Browse files
dasimmetalexrp
authored andcommitted
replace @Panic with b.addFail in standalone test build.zig
1 parent d2b1aa4 commit f0a3df9

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

test/standalone/ios/build.zig

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,6 @@ pub fn build(b: *std.Build) void {
1212
.cpu_arch = .aarch64,
1313
.os_tag = .ios,
1414
});
15-
const sdk = std.zig.system.darwin.getSdk(b.allocator, &target.result) orelse
16-
@panic("no iOS SDK found");
17-
b.sysroot = sdk;
1815

1916
const exe = b.addExecutable(.{
2017
.name = "main",
@@ -25,10 +22,17 @@ pub fn build(b: *std.Build) void {
2522
.link_libc = true,
2623
}),
2724
});
25+
26+
if (std.zig.system.darwin.getSdk(b.allocator, &target.result)) |sdk| {
27+
b.sysroot = sdk;
28+
exe.root_module.addSystemIncludePath(.{ .cwd_relative = b.pathJoin(&.{ sdk, "/usr/include" }) });
29+
exe.root_module.addSystemFrameworkPath(.{ .cwd_relative = b.pathJoin(&.{ sdk, "/System/Library/Frameworks" }) });
30+
exe.root_module.addLibraryPath(.{ .cwd_relative = b.pathJoin(&.{ sdk, "/usr/lib" }) });
31+
} else {
32+
exe.step.dependOn(&b.addFail("no iOS SDK found").step);
33+
}
34+
2835
exe.root_module.addCSourceFile(.{ .file = b.path("main.m"), .flags = &.{} });
29-
exe.root_module.addSystemIncludePath(.{ .cwd_relative = b.pathJoin(&.{ sdk, "/usr/include" }) });
30-
exe.root_module.addSystemFrameworkPath(.{ .cwd_relative = b.pathJoin(&.{ sdk, "/System/Library/Frameworks" }) });
31-
exe.root_module.addLibraryPath(.{ .cwd_relative = b.pathJoin(&.{ sdk, "/usr/lib" }) });
3236
exe.root_module.linkFramework("Foundation", .{});
3337
exe.root_module.linkFramework("UIKit", .{});
3438

0 commit comments

Comments
 (0)