mirror of
https://codeberg.org/ziglang/zig.git
synced 2025-12-06 05:44:20 +00:00
std.zig.system.darwin: fix redundant names
This commit is contained in:
parent
da91ef5c28
commit
e582a3642b
5 changed files with 10 additions and 13 deletions
|
|
@ -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" }));
|
||||
|
|
|
|||
|
|
@ -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 <target_sdk> --show-sdk-path` which fetches the path to the SDK sysroot (if any).
|
||||
/// Subsequently calls `xcrun --sdk <target_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);
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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(.{
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue