2018-07-21 02:44:44 +02:00
|
|
|
{ targetPlatform
|
2018-04-16 01:21:45 +02:00
|
|
|
, clang-unwrapped
|
|
|
|
, binutils-unwrapped
|
|
|
|
, runCommand
|
2021-01-25 09:26:54 +01:00
|
|
|
|
2018-04-16 01:21:45 +02:00
|
|
|
, wrapBintoolsWith
|
|
|
|
, wrapCCWith
|
|
|
|
, buildIosSdk, targetIosSdkPkgs
|
2018-05-23 21:32:15 +02:00
|
|
|
, xcode
|
2019-11-26 05:50:21 +01:00
|
|
|
, lib
|
2018-04-16 01:21:45 +02:00
|
|
|
}:
|
|
|
|
|
|
|
|
let
|
|
|
|
|
2020-07-22 17:54:11 +02:00
|
|
|
minSdkVersion = targetPlatform.minSdkVersion or "9.0";
|
2018-04-16 01:21:45 +02:00
|
|
|
|
|
|
|
in
|
|
|
|
|
|
|
|
rec {
|
|
|
|
sdk = rec {
|
|
|
|
name = "ios-sdk";
|
|
|
|
type = "derivation";
|
2018-06-26 04:18:23 +02:00
|
|
|
outPath = xcode + "/Contents/Developer/Platforms/${platform}.platform/Developer/SDKs/${platform}${version}.sdk";
|
2018-04-16 01:21:45 +02:00
|
|
|
|
2018-06-26 04:18:23 +02:00
|
|
|
platform = targetPlatform.xcodePlatform;
|
2018-04-16 01:21:45 +02:00
|
|
|
version = targetPlatform.sdkVer;
|
|
|
|
};
|
|
|
|
|
|
|
|
binutils = wrapBintoolsWith {
|
|
|
|
libc = targetIosSdkPkgs.libraries;
|
|
|
|
bintools = binutils-unwrapped;
|
|
|
|
};
|
|
|
|
|
|
|
|
clang = (wrapCCWith {
|
|
|
|
cc = clang-unwrapped;
|
|
|
|
bintools = binutils;
|
|
|
|
libc = targetIosSdkPkgs.libraries;
|
2019-02-26 02:01:14 +01:00
|
|
|
extraPackages = [ "${sdk}/System" ];
|
2018-04-16 01:21:45 +02:00
|
|
|
extraBuildCommands = ''
|
|
|
|
tr '\n' ' ' < $out/nix-support/cc-cflags > cc-cflags.tmp
|
|
|
|
mv cc-cflags.tmp $out/nix-support/cc-cflags
|
2020-12-12 07:49:48 +01:00
|
|
|
echo "-target ${targetPlatform.config}" >> $out/nix-support/cc-cflags
|
2019-11-26 05:50:21 +01:00
|
|
|
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
|
2020-12-09 23:48:00 +01:00
|
|
|
${lib.optionalString (lib.versionAtLeast sdk.version "14") "echo -isystem ${xcode}/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1 >> $out/nix-support/cc-cflags"}
|
2018-04-16 01:21:45 +02:00
|
|
|
'';
|
|
|
|
}) // {
|
|
|
|
inherit sdk;
|
|
|
|
};
|
|
|
|
|
|
|
|
libraries = let sdk = buildIosSdk; in runCommand "libSystem-prebuilt" {
|
|
|
|
passthru = {
|
|
|
|
inherit sdk;
|
|
|
|
};
|
|
|
|
} ''
|
|
|
|
if ! [ -d ${sdk} ]; then
|
2018-06-26 04:18:23 +02:00
|
|
|
echo "You must have version ${sdk.version} of the ${sdk.platform} sdk installed at ${sdk}" >&2
|
2018-04-16 01:21:45 +02:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
ln -s ${sdk}/usr $out
|
|
|
|
'';
|
|
|
|
}
|