mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-02-01 01:33:20 +00:00
darwin.apple_sdk.sdkRoot: init at 10.12 and 11.0
Based on the derivation from xcbuild.sdk. apple_sdk.sdkRoot provides version plists and a hook that passes them automatically to the compiler as `-isysroot`. This is needed to correctly set the SDK version in compiled binaries. Otherwise, clang will infer the SDK version to be the same as the deployment target, which is usually not what you want.
This commit is contained in:
parent
79db5b641e
commit
39a5f4a6ee
@ -105,6 +105,8 @@ let
|
|||||||
# conflicting LLVM modules.
|
# conflicting LLVM modules.
|
||||||
objc4 = stdenv.objc4 or (callPackage ./libobjc.nix { });
|
objc4 = stdenv.objc4 or (callPackage ./libobjc.nix { });
|
||||||
|
|
||||||
|
sdkRoot = pkgs.callPackage ../apple-sdk/sdkRoot.nix { sdkVersion = "11.0"; };
|
||||||
|
|
||||||
# questionable aliases
|
# questionable aliases
|
||||||
configd = pkgs.darwin.apple_sdk.frameworks.SystemConfiguration;
|
configd = pkgs.darwin.apple_sdk.frameworks.SystemConfiguration;
|
||||||
inherit (pkgs.darwin.apple_sdk.frameworks) IOKit;
|
inherit (pkgs.darwin.apple_sdk.frameworks) IOKit;
|
||||||
|
@ -354,6 +354,8 @@ in rec {
|
|||||||
|
|
||||||
objc4 = pkgs.darwin.libobjc;
|
objc4 = pkgs.darwin.libobjc;
|
||||||
|
|
||||||
|
sdkRoot = pkgs.callPackage ./sdkRoot.nix { sdkVersion = "10.12"; };
|
||||||
|
|
||||||
inherit (pkgs.darwin) Libsystem;
|
inherit (pkgs.darwin) Libsystem;
|
||||||
|
|
||||||
inherit sdk;
|
inherit sdk;
|
||||||
|
68
pkgs/os-specific/darwin/apple-sdk/sdkRoot.nix
Normal file
68
pkgs/os-specific/darwin/apple-sdk/sdkRoot.nix
Normal file
@ -0,0 +1,68 @@
|
|||||||
|
{
|
||||||
|
lib,
|
||||||
|
runCommand,
|
||||||
|
writeText,
|
||||||
|
sdkVersion,
|
||||||
|
}:
|
||||||
|
|
||||||
|
let
|
||||||
|
sdkName = "MacOSX${sdkVersion}";
|
||||||
|
toolchainName = "com.apple.dt.toolchain.XcodeDefault";
|
||||||
|
productBuildVer = null;
|
||||||
|
|
||||||
|
inherit (lib.generators) toPlist toJSON;
|
||||||
|
|
||||||
|
SDKSettings = {
|
||||||
|
CanonicalName = "macosx${sdkVersion}";
|
||||||
|
DisplayName = "macOS ${sdkVersion}";
|
||||||
|
Toolchains = [ toolchainName ];
|
||||||
|
Version = sdkVersion;
|
||||||
|
MaximumDeploymentTarget = "${sdkVersion}.99";
|
||||||
|
isBaseSDK = "YES";
|
||||||
|
};
|
||||||
|
|
||||||
|
SystemVersion =
|
||||||
|
lib.optionalAttrs (productBuildVer != null) { ProductBuildVersion = productBuildVer; }
|
||||||
|
// {
|
||||||
|
ProductName = "macOS";
|
||||||
|
ProductVersion = sdkVersion;
|
||||||
|
};
|
||||||
|
in
|
||||||
|
runCommand "sdkroot-${sdkVersion}" { } ''
|
||||||
|
sdk="$out/${sdkName}.sdk"
|
||||||
|
|
||||||
|
install -D ${writeText "SDKSettings.plist" (toPlist { } SDKSettings)} "$sdk/SDKSettings.plist"
|
||||||
|
install -D ${writeText "SDKSettings.json" (toJSON { } SDKSettings)} "$sdk/SDKSettings.json"
|
||||||
|
install -D ${
|
||||||
|
writeText "SystemVersion.plist" (toPlist { } SystemVersion)
|
||||||
|
} "$sdk/System/Library/CoreServices/SystemVersion.plist"
|
||||||
|
|
||||||
|
ln -s "$sdk" "$sdk/usr"
|
||||||
|
|
||||||
|
install -D '${../../../build-support/setup-hooks/role.bash}' "$out/nix-support/setup-hook"
|
||||||
|
cat >> "$out/nix-support/setup-hook" <<-hook
|
||||||
|
#
|
||||||
|
# See comments in cc-wrapper's setup hook. This works exactly the same way.
|
||||||
|
#
|
||||||
|
[[ -z \''${strictDeps-} ]] || (( "\$hostOffset" < 0 )) || return 0
|
||||||
|
|
||||||
|
sdkRootHook() {
|
||||||
|
# See ../../../build-support/setup-hooks/role.bash
|
||||||
|
local role_post
|
||||||
|
getHostRoleEnvHook
|
||||||
|
|
||||||
|
# Only set the SDK root if one has not been set via this hook or some other means.
|
||||||
|
if [[ ! \$NIX_CFLAGS_COMPILE =~ isysroot ]]; then
|
||||||
|
export NIX_CFLAGS_COMPILE\''${role_post}+=' -isysroot $out/${sdkName}.sdk'
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# See ../../../build-support/setup-hooks/role.bash
|
||||||
|
getTargetRole
|
||||||
|
|
||||||
|
addEnvHooks "\$targetOffset" sdkRootHook
|
||||||
|
|
||||||
|
# No local scope in sourced file
|
||||||
|
unset -v role_post
|
||||||
|
hook
|
||||||
|
''
|
Loading…
Reference in New Issue
Block a user