replace @panic with b.addFail in standalone test build.zig

This commit is contained in:
Tobias Simetsreiter 2025-11-17 12:14:09 +01:00 committed by Alex Rønne Petersen
parent d2b1aa48ab
commit f0a3df98d3

View file

@ -12,9 +12,6 @@ pub fn build(b: *std.Build) void {
.cpu_arch = .aarch64, .cpu_arch = .aarch64,
.os_tag = .ios, .os_tag = .ios,
}); });
const sdk = std.zig.system.darwin.getSdk(b.allocator, &target.result) orelse
@panic("no iOS SDK found");
b.sysroot = sdk;
const exe = b.addExecutable(.{ const exe = b.addExecutable(.{
.name = "main", .name = "main",
@ -25,10 +22,17 @@ pub fn build(b: *std.Build) void {
.link_libc = true, .link_libc = true,
}), }),
}); });
if (std.zig.system.darwin.getSdk(b.allocator, &target.result)) |sdk| {
b.sysroot = sdk;
exe.root_module.addSystemIncludePath(.{ .cwd_relative = b.pathJoin(&.{ sdk, "/usr/include" }) });
exe.root_module.addSystemFrameworkPath(.{ .cwd_relative = b.pathJoin(&.{ sdk, "/System/Library/Frameworks" }) });
exe.root_module.addLibraryPath(.{ .cwd_relative = b.pathJoin(&.{ sdk, "/usr/lib" }) });
} else {
exe.step.dependOn(&b.addFail("no iOS SDK found").step);
}
exe.root_module.addCSourceFile(.{ .file = b.path("main.m"), .flags = &.{} }); exe.root_module.addCSourceFile(.{ .file = b.path("main.m"), .flags = &.{} });
exe.root_module.addSystemIncludePath(.{ .cwd_relative = b.pathJoin(&.{ sdk, "/usr/include" }) });
exe.root_module.addSystemFrameworkPath(.{ .cwd_relative = b.pathJoin(&.{ sdk, "/System/Library/Frameworks" }) });
exe.root_module.addLibraryPath(.{ .cwd_relative = b.pathJoin(&.{ sdk, "/usr/lib" }) });
exe.root_module.linkFramework("Foundation", .{}); exe.root_module.linkFramework("Foundation", .{});
exe.root_module.linkFramework("UIKit", .{}); exe.root_module.linkFramework("UIKit", .{});