mirror of
https://github.com/ziglang/zig.git
synced 2025-12-18 12:13:20 +00:00
`std.zig.system.darwin.getSdk` now pulls only the SDK path so we execute a child process only once and not twice as it was until now since we parse the SDK version directly from the pulled path. This is actually how `ld64` does it too.
38 lines
1.3 KiB
Zig
38 lines
1.3 KiB
Zig
const std = @import("std");
|
|
|
|
pub const requires_symlinks = true;
|
|
pub const requires_ios_sdk = true;
|
|
|
|
pub fn build(b: *std.Build) void {
|
|
const test_step = b.step("test", "Test it");
|
|
b.default_step = test_step;
|
|
|
|
const optimize: std.builtin.OptimizeMode = .Debug;
|
|
const target: std.zig.CrossTarget = .{
|
|
.cpu_arch = .aarch64,
|
|
.os_tag = .ios,
|
|
};
|
|
const target_info = std.zig.system.NativeTargetInfo.detect(target) catch @panic("couldn't detect native target");
|
|
const sdk = std.zig.system.darwin.getSdk(b.allocator, target_info.target) orelse @panic("no iOS SDK found");
|
|
b.sysroot = sdk;
|
|
|
|
const exe = b.addExecutable(.{
|
|
.name = "main",
|
|
.optimize = optimize,
|
|
.target = target,
|
|
});
|
|
exe.addCSourceFile(.{ .file = .{ .path = "main.m" }, .flags = &.{} });
|
|
exe.addSystemIncludePath(.{ .path = b.pathJoin(&.{ sdk, "/usr/include" }) });
|
|
exe.addSystemFrameworkPath(.{ .path = b.pathJoin(&.{ sdk, "/System/Library/Frameworks" }) });
|
|
exe.addLibraryPath(.{ .path = b.pathJoin(&.{ sdk, "/usr/lib" }) });
|
|
exe.linkFramework("Foundation");
|
|
exe.linkFramework("UIKit");
|
|
exe.linkLibC();
|
|
|
|
const check = exe.checkObject();
|
|
check.checkStart();
|
|
check.checkExact("cmd BUILD_VERSION");
|
|
check.checkExact("platform IOS");
|
|
test_step.dependOn(&check.step);
|
|
}
|