authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2023-08-02 16:25:45-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2023-08-03 09:52:15-07:00
loge582a3642bb001a7a19ecb72b128f45ab7fc08aa
tree81b880b895b220fd14e21756e59956ff8d9b6ffd
parentda91ef5c28bd11823bd84b6f54df9ca601f03e21

std.zig.system.darwin: fix redundant names


5 files changed, 10 insertions(+), 13 deletions(-)

lib/std/zig/system/NativePaths.zig+2-2
......@@ -79,8 +79,8 @@ pub fn detect(arena: Allocator, native_info: NativeTargetInfo) !NativePaths {
7979 // TODO: consider also adding homebrew paths
8080 // TODO: consider also adding macports paths
8181 if (comptime builtin.target.isDarwin()) {
82 if (std.zig.system.darwin.isDarwinSDKInstalled(arena)) sdk: {
83 const sdk = std.zig.system.darwin.getDarwinSDK(arena, native_target) orelse break :sdk;
82 if (std.zig.system.darwin.isSdkInstalled(arena)) sdk: {
83 const sdk = std.zig.system.darwin.getSdk(arena, native_target) orelse break :sdk;
8484 try self.addLibDir(try std.fs.path.join(arena, &.{ sdk.path, "usr/lib" }));
8585 try self.addFrameworkDir(try std.fs.path.join(arena, &.{ sdk.path, "System/Library/Frameworks" }));
8686 try self.addIncludeDir(try std.fs.path.join(arena, &.{ sdk.path, "usr/include" }));
lib/std/zig/system/darwin.zig+5-5
......@@ -11,7 +11,7 @@ pub const macos = @import("darwin/macos.zig");
1111/// Therefore, we resort to the same tool used by Homebrew, namely, invoking `xcode-select --print-path`
1212/// and checking if the status is nonzero or the returned string in nonempty.
1313/// https://github.com/Homebrew/brew/blob/e119bdc571dcb000305411bc1e26678b132afb98/Library/Homebrew/brew.sh#L630
14pub fn isDarwinSDKInstalled(allocator: Allocator) bool {
14pub fn isSdkInstalled(allocator: Allocator) bool {
1515 const argv = &[_][]const u8{ "/usr/bin/xcode-select", "--print-path" };
1616 const result = std.ChildProcess.exec(.{ .allocator = allocator, .argv = argv }) catch return false;
1717 defer {
......@@ -29,7 +29,7 @@ pub fn isDarwinSDKInstalled(allocator: Allocator) bool {
2929/// Calls `xcrun --sdk <target_sdk> --show-sdk-path` which fetches the path to the SDK sysroot (if any).
3030/// Subsequently calls `xcrun --sdk <target_sdk> --show-sdk-version` which fetches version of the SDK.
3131/// The caller needs to deinit the resulting struct.
32pub fn getDarwinSDK(allocator: Allocator, target: Target) ?DarwinSDK {
32pub fn getSdk(allocator: Allocator, target: Target) ?Sdk {
3333 const is_simulator_abi = target.abi == .simulator;
3434 const sdk = switch (target.os.tag) {
3535 .macos => "macosx",
......@@ -73,7 +73,7 @@ pub fn getDarwinSDK(allocator: Allocator, target: Target) ?DarwinSDK {
7373 };
7474 break :version version;
7575 };
76 return DarwinSDK{
76 return Sdk{
7777 .path = path,
7878 .version = version,
7979 };
......@@ -96,11 +96,11 @@ fn parseSdkVersion(raw: []const u8) ?Version {
9696 return Version.parse(buffer[0..len]) catch null;
9797}
9898
99pub const DarwinSDK = struct {
99pub const Sdk = struct {
100100 path: []const u8,
101101 version: Version,
102102
103 pub fn deinit(self: DarwinSDK, allocator: Allocator) void {
103 pub fn deinit(self: Sdk, allocator: Allocator) void {
104104 allocator.free(self.path);
105105 }
106106};
src/libc_installation.zig+2-2
......@@ -183,9 +183,9 @@ pub const LibCInstallation = struct {
183183 var self: LibCInstallation = .{};
184184
185185 if (is_darwin) {
186 if (!std.zig.system.darwin.isDarwinSDKInstalled(args.allocator))
186 if (!std.zig.system.darwin.isSdkInstalled(args.allocator))
187187 return error.DarwinSdkNotFound;
188 const sdk = std.zig.system.darwin.getDarwinSDK(args.allocator, args.target) orelse
188 const sdk = std.zig.system.darwin.getSdk(args.allocator, args.target) orelse
189189 return error.DarwinSdkNotFound;
190190 defer args.allocator.free(sdk.path);
191191
src/main.zig-3
......@@ -2857,9 +2857,6 @@ fn buildOutputType(
28572857 std.log.err("unable to find {s} system library '{s}' using strategy '{s}'. searched paths:{s}", .{
28582858 @tagName(f.preferred_mode), f.name, @tagName(f.strategy), searched_paths,
28592859 });
2860 if (f.preferred_mode == .Dynamic and f.strategy == .no_fallback) {
2861 std.log.info("to link statically, pass the library as a positional argument", .{});
2862 }
28632860 }
28642861 process.exit(1);
28652862 }
test/link/macho/bugs/13056/build.zig+1-1
......@@ -16,7 +16,7 @@ pub fn build(b: *std.Build) void {
1616fn add(b: *std.Build, test_step: *std.Build.Step, optimize: std.builtin.OptimizeMode) void {
1717 const target: std.zig.CrossTarget = .{ .os_tag = .macos };
1818 const target_info = std.zig.system.NativeTargetInfo.detect(target) catch unreachable;
19 const sdk = std.zig.system.darwin.getDarwinSDK(b.allocator, target_info.target) orelse
19 const sdk = std.zig.system.darwin.getSdk(b.allocator, target_info.target) orelse
2020 @panic("macOS SDK is required to run the test");
2121
2222 const exe = b.addExecutable(.{