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