From 0bfffbc5e19f1a16c19f3cec5272174555006869 Mon Sep 17 00:00:00 2001 From: Matthew Bauer Date: Mon, 25 Jun 2018 22:18:23 -0400 Subject: xcode: add xcodePlatform to system This give us a little bit more control over what target we are using. Eventually we can target other things like WatchOS or MacOS. --- pkgs/os-specific/darwin/ios-sdk-pkgs/default.nix | 68 ----------------------- pkgs/os-specific/darwin/xcode/sdk-pkgs.nix | 71 ++++++++++++++++++++++++ pkgs/top-level/darwin-packages.nix | 2 +- 3 files changed, 72 insertions(+), 69 deletions(-) delete mode 100644 pkgs/os-specific/darwin/ios-sdk-pkgs/default.nix create mode 100644 pkgs/os-specific/darwin/xcode/sdk-pkgs.nix (limited to 'pkgs') diff --git a/pkgs/os-specific/darwin/ios-sdk-pkgs/default.nix b/pkgs/os-specific/darwin/ios-sdk-pkgs/default.nix deleted file mode 100644 index ebca738431c3..000000000000 --- a/pkgs/os-specific/darwin/ios-sdk-pkgs/default.nix +++ /dev/null @@ -1,68 +0,0 @@ -{ lib, hostPlatform, targetPlatform -, clang-unwrapped -, binutils-unwrapped -, runCommand -, stdenv -, wrapBintoolsWith -, wrapCCWith -, buildIosSdk, targetIosSdkPkgs -, xcode -}: - -let - -minSdkVersion = "9.0"; - -iosPlatformArch = { parsed, ... }: { - "armv7a" = "armv7"; - "aarch64" = "arm64"; - "x86_64" = "x86_64"; -}.${parsed.cpu.name}; - -in - -rec { - sdk = rec { - name = "ios-sdk"; - type = "derivation"; - outPath = xcode + "/Contents/Developer/Platforms/iPhone${sdkType}.platform/Developer/SDKs/iPhone${sdkType}${version}.sdk"; - - sdkType = if targetPlatform.isiPhoneSimulator then "Simulator" else "OS"; - version = targetPlatform.sdkVer; - }; - - binutils = wrapBintoolsWith { - libc = targetIosSdkPkgs.libraries; - bintools = binutils-unwrapped; - extraBuildCommands = '' - echo "-arch ${iosPlatformArch targetPlatform}" >> $out/nix-support/libc-ldflags - ''; - }; - - clang = (wrapCCWith { - cc = clang-unwrapped; - bintools = binutils; - libc = targetIosSdkPkgs.libraries; - extraBuildCommands = '' - tr '\n' ' ' < $out/nix-support/cc-cflags > cc-cflags.tmp - mv cc-cflags.tmp $out/nix-support/cc-cflags - echo "-target ${targetPlatform.config} -arch ${iosPlatformArch targetPlatform}" >> $out/nix-support/cc-cflags - echo "-isystem ${sdk}/usr/include -isystem ${sdk}/usr/include/c++/4.2.1/ -stdlib=libstdc++" >> $out/nix-support/cc-cflags - echo "${if targetPlatform.isiPhoneSimulator then "-mios-simulator-version-min" else "-miphoneos-version-min"}=${minSdkVersion}" >> $out/nix-support/cc-cflags - ''; - }) // { - inherit sdk; - }; - - libraries = let sdk = buildIosSdk; in runCommand "libSystem-prebuilt" { - passthru = { - inherit sdk; - }; - } '' - if ! [ -d ${sdk} ]; then - echo "You must have version ${sdk.version} of the iPhone${sdk.sdkType} sdk installed at ${sdk}" >&2 - exit 1 - fi - ln -s ${sdk}/usr $out - ''; -} diff --git a/pkgs/os-specific/darwin/xcode/sdk-pkgs.nix b/pkgs/os-specific/darwin/xcode/sdk-pkgs.nix new file mode 100644 index 000000000000..d5ed21cd9e24 --- /dev/null +++ b/pkgs/os-specific/darwin/xcode/sdk-pkgs.nix @@ -0,0 +1,71 @@ +{ lib, hostPlatform, targetPlatform +, clang-unwrapped +, binutils-unwrapped +, runCommand +, stdenv +, wrapBintoolsWith +, wrapCCWith +, buildIosSdk, targetIosSdkPkgs +, xcode +}: + +let + +minSdkVersion = "9.0"; + +iosPlatformArch = { parsed, ... }: { + "armv7a" = "armv7"; + "aarch64" = "arm64"; + "x86_64" = "x86_64"; +}.${parsed.cpu.name}; + +in + +rec { + sdk = rec { + name = "ios-sdk"; + type = "derivation"; + outPath = xcode + "/Contents/Developer/Platforms/${platform}.platform/Developer/SDKs/${platform}${version}.sdk"; + + platform = targetPlatform.xcodePlatform; + version = targetPlatform.sdkVer; + }; + + binutils = wrapBintoolsWith { + libc = targetIosSdkPkgs.libraries; + bintools = binutils-unwrapped; + extraBuildCommands = '' + echo "-arch ${iosPlatformArch targetPlatform}" >> $out/nix-support/libc-ldflags + ''; + }; + + clang = (wrapCCWith { + cc = clang-unwrapped; + bintools = binutils; + libc = targetIosSdkPkgs.libraries; + extraBuildCommands = '' + tr '\n' ' ' < $out/nix-support/cc-cflags > cc-cflags.tmp + mv cc-cflags.tmp $out/nix-support/cc-cflags + echo "-target ${targetPlatform.config} -arch ${iosPlatformArch targetPlatform}" >> $out/nix-support/cc-cflags + echo "-isystem ${sdk}/usr/include -isystem ${sdk}/usr/include/c++/4.2.1/ -stdlib=libstdc++" >> $out/nix-support/cc-cflags + '' + stdenv.lib.optionalString (sdk.platform == "iPhoneSimulator") '' + echo "-mios-simulator-version-min=${minSdkVersion}" >> $out/nix-support/cc-cflags + '' + stdenv.lib.optionalString (sdk.platform == "iPhoneOS") '' + echo "-miphoneos-version-min=${minSdkVersion}" >> $out/nix-support/cc-cflags + ''; + }) // { + inherit sdk; + }; + + libraries = let sdk = buildIosSdk; in runCommand "libSystem-prebuilt" { + passthru = { + inherit sdk; + }; + } '' + if ! [ -d ${sdk} ]; then + echo "You must have version ${sdk.version} of the ${sdk.platform} sdk installed at ${sdk}" >&2 + exit 1 + fi + ln -s ${sdk}/usr $out + ''; +} diff --git a/pkgs/top-level/darwin-packages.nix b/pkgs/top-level/darwin-packages.nix index 03a32260710a..047eab83bb42 100644 --- a/pkgs/top-level/darwin-packages.nix +++ b/pkgs/top-level/darwin-packages.nix @@ -44,7 +44,7 @@ in insert_dylib = callPackage ../os-specific/darwin/insert_dylib { }; - iosSdkPkgs = darwin.callPackage ../os-specific/darwin/ios-sdk-pkgs { + iosSdkPkgs = darwin.callPackage ../os-specific/darwin/xcode/sdk-pkgs.nix { buildIosSdk = buildPackages.darwin.iosSdkPkgs.sdk; targetIosSdkPkgs = targetPackages.darwin.iosSdkPkgs; xcode = darwin.xcode; -- cgit 1.4.1