lol
1{ stdenv
2, clang-unwrapped
3, binutils-unwrapped
4, runCommand
5
6, wrapBintoolsWith
7, wrapCCWith
8, buildIosSdk, targetIosSdkPkgs
9, xcode
10, lib
11}:
12
13let
14
15minSdkVersion = stdenv.targetPlatform.minSdkVersion or "9.0";
16
17in
18
19rec {
20 sdk = rec {
21 name = "ios-sdk";
22 type = "derivation";
23 outPath = xcode + "/Contents/Developer/Platforms/${platform}.platform/Developer/SDKs/${platform}${version}.sdk";
24
25 platform = stdenv.targetPlatform.xcodePlatform;
26 version = stdenv.targetPlatform.sdkVer;
27 };
28
29 binutils = wrapBintoolsWith {
30 libc = targetIosSdkPkgs.libraries;
31 bintools = binutils-unwrapped;
32 };
33
34 clang = (wrapCCWith {
35 cc = clang-unwrapped;
36 bintools = binutils;
37 libc = targetIosSdkPkgs.libraries;
38 extraPackages = [ "${sdk}/System" ];
39 extraBuildCommands = ''
40 tr '\n' ' ' < $out/nix-support/cc-cflags > cc-cflags.tmp
41 mv cc-cflags.tmp $out/nix-support/cc-cflags
42 echo "-target ${stdenv.targetPlatform.config}" >> $out/nix-support/cc-cflags
43 echo "-isystem ${sdk}/usr/include${lib.optionalString (lib.versionAtLeast "10" sdk.version) " -isystem ${sdk}/usr/include/c++/4.2.1/ -stdlib=libstdc++"}" >> $out/nix-support/cc-cflags
44 ${lib.optionalString (lib.versionAtLeast sdk.version "14") "echo -isystem ${xcode}/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1 >> $out/nix-support/cc-cflags"}
45 '';
46 }) // {
47 inherit sdk;
48 };
49
50 libraries = let sdk = buildIosSdk; in runCommand "libSystem-prebuilt" {
51 passthru = {
52 inherit sdk;
53 };
54 } ''
55 if ! [ -d ${sdk} ]; then
56 echo "You must have version ${sdk.version} of the ${sdk.platform} sdk installed at ${sdk}" >&2
57 exit 1
58 fi
59 ln -s ${sdk}/usr $out
60 '';
61}