Unverified Commit e6d58290 authored by Emily's avatar Emily Committed by GitHub
Browse files

apple-sdk: clean up and improve compatibility with Swift (#445094)

parents 1a1d97e4 c93f6d55
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -42,7 +42,6 @@ in
self: super: {
  buildPhase = super.buildPhase or "" + ''
    mkdir -p System/Library/PrivateFrameworks/CoreSymbolication.framework/Versions/A/Headers
    ln -s A System/Library/PrivateFrameworks/CoreSymbolication.framework/Versions/Current
    ln -s Versions/Current/Headers System/Library/PrivateFrameworks/CoreSymbolication.framework/Headers
    cp '${CoreSymbolication}/include/'*.h System/Library/PrivateFrameworks/CoreSymbolication.framework/Versions/A/Headers
  '';
+16 −3
Original line number Diff line number Diff line
@@ -2,15 +2,28 @@
  lib,
  stdenvNoCC,
  xcodePlatform,
  sdkVersion,
}:

let
  inherit (lib.generators) toPlist;

  Info = {
    CFBundleIdentifier = "com.apple.platform.${lib.toLower xcodePlatform}";
    Type = "Platform";
  Info = rec {
    CFBundleIdentifier = "com.apple.platform.${Name}";
    DefaultProperties = {
      COMPRESS_PNG_FILES = "NO";
      DEPLOYMENT_TARGET_SETTING_NAME = stdenvNoCC.hostPlatform.darwinMinVersionVariable;
      STRIP_PNG_TEXT = "NO";
    };
    Description = if stdenvNoCC.hostPlatform.isMacOS then "macOS" else "iOS";
    FamilyDisplayName = Description;
    FamilyIdentifier = lib.toLower xcodePlatform;
    FamilyName = Description;
    Identifier = CFBundleIdentifier;
    MinimumSDKVersion = stdenvNoCC.hostPlatform.darwinMinVersion;
    Name = lib.toLower xcodePlatform;
    Type = "Platform";
    Version = sdkVersion;
  };

  # These files are all based off of Xcode spec files found in
+6 −3
Original line number Diff line number Diff line
@@ -56,16 +56,19 @@ self: super: {
      darwin.libsbuf
      # Shipped with the SDK only as a library with no headers
      (lib.getLib darwin.libutil)
      # Required by some SDK headers
      cupsHeaders
    ]
    # x86_64-darwin links the object files from Csu when targeting very old releases
    ++ lib.optionals stdenvNoCC.hostPlatform.isx86_64 [ darwin.Csu ];

  # The Darwin module for Swift requires certain headers to be included in the SDK (and not just be propagated).
  buildPhase = super.buildPhase or "" + ''
    for header in '${lib.getDev libiconv}/include/'* '${lib.getDev ncurses}/include/'*; do
    for header in '${lib.getDev libiconv}/include/'* '${lib.getDev ncurses}/include/'* '${cupsHeaders}/include/'*; do
      ln -s "$header" "usr/include/$(basename "$header")"
    done
  '';

  # Exported to allow the headers to pass the requisites check in the stdenv bootstrap.
  passthru = (super.passthru or { }) // {
    cups-headers = cupsHeaders;
  };
}
+8 −3
Original line number Diff line number Diff line
@@ -3,11 +3,12 @@
  pkgsBuildHost,
  stdenv,
  stdenvNoCC,
  sdkVersion,
}:

let
  plists = import ./plists.nix {
    inherit lib stdenvNoCC;
    inherit lib stdenvNoCC sdkVersion;
    xcodePlatform = if stdenvNoCC.hostPlatform.isMacOS then "MacOSX" else "iPhoneOS";
  };
  inherit (pkgsBuildHost) darwin cctools xcbuild;
@@ -38,11 +39,15 @@ self: super: {
    # Include `libtool` in the toolchain, so `xcrun -find libtool` can find it without requiring `cctools.libtool`
    # as a `nativeBuildInput`.
    mkdir -p "$toolchainsPath/usr/bin"
    if [ -e '${cctools.libtool}/bin/${stdenv.cc.targetPrefix}libtool' ]; then
      ln -s '${cctools.libtool}/bin/${stdenv.cc.targetPrefix}libtool' "$toolchainsPath/usr/bin/libtool"
    fi

    # Include additional binutils required by some packages (such as Chromium).
    for tool in lipo nm otool size strip; do
      if [ -e '${darwin.binutils-unwrapped}/bin/${stdenv.cc.targetPrefix}'$tool ]; then
        ln -s '${darwin.binutils-unwrapped}/bin/${stdenv.cc.targetPrefix}'$tool "$toolchainsPath/usr/bin/$tool"
      fi
    done
  '';
}
+6 −7
Original line number Diff line number Diff line
@@ -41,7 +41,7 @@ let
    # Avoid infinite recursions by not propagating certain packages, so they can themselves build with the SDK.
    ++ lib.optionals (!enableBootstrap) [
      (callPackage ./common/propagate-inputs.nix { })
      (callPackage ./common/propagate-xcrun.nix { })
      (callPackage ./common/propagate-xcrun.nix { inherit sdkVersion; })
    ]
    # This has to happen last.
    ++ [
@@ -58,12 +58,6 @@ stdenvNoCC.mkDerivation (

    dontConfigure = true;

    # TODO(@connorbaker):
    # This is a quick fix unblock builds broken by https://github.com/NixOS/nixpkgs/pull/370750.
    # Fails due to a reflexive symlink:
    # $out/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.3.sdk/System/Library/PrivateFrameworks/CoreSymbolication.framework/Versions/A/A
    dontCheckForBrokenSymlinks = true;

    strictDeps = true;

    setupHooks = [
@@ -96,6 +90,11 @@ stdenvNoCC.mkDerivation (
        ln -s "${sdkName}" "$sdkpath/MacOSX${sdkMajor}.sdk"
        ln -s "${sdkName}" "$sdkpath/MacOSX.sdk"

        # Swift adds these locations to its search paths. Avoid spurious warnings by making sure they exist.
        mkdir -p "$platformPath/Developer/Library/Frameworks"
        mkdir -p "$platformPath/Developer/Library/PrivateFrameworks"
        mkdir -p "$platformPath/Developer/usr/lib"

        runHook postInstall
      '';

Loading