From e582a3642bb001a7a19ecb72b128f45ab7fc08aa Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Wed, 2 Aug 2023 16:25:45 -0700 Subject: [PATCH] std.zig.system.darwin: fix redundant names --- lib/std/zig/system/NativePaths.zig | 4 ++-- lib/std/zig/system/darwin.zig | 10 +++++----- src/libc_installation.zig | 4 ++-- src/main.zig | 3 --- test/link/macho/bugs/13056/build.zig | 2 +- 5 files changed, 10 insertions(+), 13 deletions(-) diff --git a/lib/std/zig/system/NativePaths.zig b/lib/std/zig/system/NativePaths.zig index 61f71144ca..1fd92292f9 100644 --- a/lib/std/zig/system/NativePaths.zig +++ b/lib/std/zig/system/NativePaths.zig @@ -79,8 +79,8 @@ pub fn detect(arena: Allocator, native_info: NativeTargetInfo) !NativePaths { // TODO: consider also adding homebrew paths // TODO: consider also adding macports paths if (comptime builtin.target.isDarwin()) { - if (std.zig.system.darwin.isDarwinSDKInstalled(arena)) sdk: { - const sdk = std.zig.system.darwin.getDarwinSDK(arena, native_target) orelse break :sdk; + if (std.zig.system.darwin.isSdkInstalled(arena)) sdk: { + const sdk = std.zig.system.darwin.getSdk(arena, native_target) orelse break :sdk; try self.addLibDir(try std.fs.path.join(arena, &.{ sdk.path, "usr/lib" })); try self.addFrameworkDir(try std.fs.path.join(arena, &.{ sdk.path, "System/Library/Frameworks" })); try self.addIncludeDir(try std.fs.path.join(arena, &.{ sdk.path, "usr/include" })); diff --git a/lib/std/zig/system/darwin.zig b/lib/std/zig/system/darwin.zig index e29dc68d64..3857d4f46c 100644 --- a/lib/std/zig/system/darwin.zig +++ b/lib/std/zig/system/darwin.zig @@ -11,7 +11,7 @@ pub const macos = @import("darwin/macos.zig"); /// Therefore, we resort to the same tool used by Homebrew, namely, invoking `xcode-select --print-path` /// and checking if the status is nonzero or the returned string in nonempty. /// https://github.com/Homebrew/brew/blob/e119bdc571dcb000305411bc1e26678b132afb98/Library/Homebrew/brew.sh#L630 -pub fn isDarwinSDKInstalled(allocator: Allocator) bool { +pub fn isSdkInstalled(allocator: Allocator) bool { const argv = &[_][]const u8{ "/usr/bin/xcode-select", "--print-path" }; const result = std.ChildProcess.exec(.{ .allocator = allocator, .argv = argv }) catch return false; defer { @@ -29,7 +29,7 @@ pub fn isDarwinSDKInstalled(allocator: Allocator) bool { /// Calls `xcrun --sdk --show-sdk-path` which fetches the path to the SDK sysroot (if any). /// Subsequently calls `xcrun --sdk --show-sdk-version` which fetches version of the SDK. /// The caller needs to deinit the resulting struct. -pub fn getDarwinSDK(allocator: Allocator, target: Target) ?DarwinSDK { +pub fn getSdk(allocator: Allocator, target: Target) ?Sdk { const is_simulator_abi = target.abi == .simulator; const sdk = switch (target.os.tag) { .macos => "macosx", @@ -73,7 +73,7 @@ pub fn getDarwinSDK(allocator: Allocator, target: Target) ?DarwinSDK { }; break :version version; }; - return DarwinSDK{ + return Sdk{ .path = path, .version = version, }; @@ -96,11 +96,11 @@ fn parseSdkVersion(raw: []const u8) ?Version { return Version.parse(buffer[0..len]) catch null; } -pub const DarwinSDK = struct { +pub const Sdk = struct { path: []const u8, version: Version, - pub fn deinit(self: DarwinSDK, allocator: Allocator) void { + pub fn deinit(self: Sdk, allocator: Allocator) void { allocator.free(self.path); } }; diff --git a/src/libc_installation.zig b/src/libc_installation.zig index 4dbe9d9c57..2d42a03a32 100644 --- a/src/libc_installation.zig +++ b/src/libc_installation.zig @@ -183,9 +183,9 @@ pub const LibCInstallation = struct { var self: LibCInstallation = .{}; if (is_darwin) { - if (!std.zig.system.darwin.isDarwinSDKInstalled(args.allocator)) + if (!std.zig.system.darwin.isSdkInstalled(args.allocator)) return error.DarwinSdkNotFound; - const sdk = std.zig.system.darwin.getDarwinSDK(args.allocator, args.target) orelse + const sdk = std.zig.system.darwin.getSdk(args.allocator, args.target) orelse return error.DarwinSdkNotFound; defer args.allocator.free(sdk.path); diff --git a/src/main.zig b/src/main.zig index 3f06469a75..3c7d2c85be 100644 --- a/src/main.zig +++ b/src/main.zig @@ -2857,9 +2857,6 @@ fn buildOutputType( std.log.err("unable to find {s} system library '{s}' using strategy '{s}'. searched paths:{s}", .{ @tagName(f.preferred_mode), f.name, @tagName(f.strategy), searched_paths, }); - if (f.preferred_mode == .Dynamic and f.strategy == .no_fallback) { - std.log.info("to link statically, pass the library as a positional argument", .{}); - } } process.exit(1); } diff --git a/test/link/macho/bugs/13056/build.zig b/test/link/macho/bugs/13056/build.zig index eade752bc4..50eb990583 100644 --- a/test/link/macho/bugs/13056/build.zig +++ b/test/link/macho/bugs/13056/build.zig @@ -16,7 +16,7 @@ pub fn build(b: *std.Build) void { fn add(b: *std.Build, test_step: *std.Build.Step, optimize: std.builtin.OptimizeMode) void { const target: std.zig.CrossTarget = .{ .os_tag = .macos }; const target_info = std.zig.system.NativeTargetInfo.detect(target) catch unreachable; - const sdk = std.zig.system.darwin.getDarwinSDK(b.allocator, target_info.target) orelse + const sdk = std.zig.system.darwin.getSdk(b.allocator, target_info.target) orelse @panic("macOS SDK is required to run the test"); const exe = b.addExecutable(.{