parent
b1a8894a1c
commit
ef3db7d14c
@ -1,61 +0,0 @@ |
||||
{ runCommand |
||||
, lib |
||||
, llvm |
||||
, clang |
||||
, binutils |
||||
, stdenv |
||||
, coreutils |
||||
, gnugrep |
||||
, buildPackages |
||||
, hostPlatform |
||||
, targetPlatform |
||||
}: |
||||
|
||||
/* As of this writing, known-good prefix/arch/simulator triples: |
||||
* aarch64-apple-darwin14 | arm64 | false |
||||
* arm-apple-darwin10 | armv7 | false |
||||
* i386-apple-darwin11 | i386 | true |
||||
* x86_64-apple-darwin14 | x86_64 | true |
||||
*/ |
||||
|
||||
# Apple uses somewhat non-standard names for this. We could fall back on |
||||
# `targetPlatform.parsed.cpu.name`, but that would be a more standard one and |
||||
# likely to fail. Better just to require something manual. |
||||
assert targetPlatform ? arch; |
||||
|
||||
let |
||||
|
||||
prefix = targetPlatform.config; |
||||
inherit (targetPlatform) arch; |
||||
simulator = targetPlatform.isiPhoneSimulator or false; |
||||
|
||||
sdkType = if simulator then "Simulator" else "OS"; |
||||
|
||||
sdkVer = "10.2"; |
||||
|
||||
sdk = "/Applications/Xcode.app/Contents/Developer/Platforms/iPhone${sdkType}.platform/Developer/SDKs/iPhone${sdkType}${sdkVer}.sdk"; |
||||
|
||||
in (import ../../../build-support/cc-wrapper { |
||||
inherit stdenv coreutils gnugrep runCommand buildPackages; |
||||
nativeTools = false; |
||||
nativeLibc = false; |
||||
inherit binutils; |
||||
libc = runCommand "empty-libc" {} "mkdir -p $out/{lib,include}"; |
||||
inherit (clang) cc; |
||||
inherit hostPlatform targetPlatform; |
||||
extraBuildCommands = '' |
||||
if ! [ -d ${sdk} ]; then |
||||
echo "You must have ${sdkVer} of the iPhone${sdkType} sdk installed at ${sdk}" >&2 |
||||
exit 1 |
||||
fi |
||||
# ugh |
||||
tr '\n' ' ' < $out/nix-support/cc-cflags > cc-cflags.tmp |
||||
mv cc-cflags.tmp $out/nix-support/cc-cflags |
||||
echo "-target ${prefix} -arch ${arch} -idirafter ${sdk}/usr/include ${if simulator then "-mios-simulator-version-min=7.0" else "-miphoneos-version-min=7.0"}" >> $out/nix-support/cc-cflags |
||||
|
||||
# Purposefully overwrite libc-ldflags-before, cctools ld doesn't know dynamic-linker and cc-wrapper doesn't do cross-compilation well enough to adjust |
||||
echo "-arch ${arch} -L${sdk}/usr/lib ${lib.optionalString simulator "-L${sdk}/usr/lib/system "}-i${if simulator then "os_simulator" else "phoneos"}_version_min 7.0.0" > $out/nix-support/libc-ldflags-before |
||||
''; |
||||
}) // { |
||||
inherit sdkType sdkVer sdk; |
||||
} |
@ -0,0 +1,68 @@ |
||||
{ lib, hostPlatform, targetPlatform |
||||
, clang-unwrapped |
||||
, binutils-unwrapped |
||||
, runCommand |
||||
, stdenv |
||||
, wrapBintoolsWith |
||||
, wrapCCWith |
||||
, buildIosSdk, targetIosSdkPkgs |
||||
}: |
||||
|
||||
let |
||||
|
||||
minSdkVersion = "9.0"; |
||||
|
||||
iosPlatformArch = { parsed, ... }: { |
||||
"arm" = "armv7"; |
||||
"aarch64" = "arm64"; |
||||
"x86_64" = "x86_64"; |
||||
}.${parsed.cpu.name}; |
||||
|
||||
in |
||||
|
||||
rec { |
||||
# TODO(kmicklas): Make a pure version of this for each supported SDK version. |
||||
sdk = rec { |
||||
name = "ios-sdk"; |
||||
type = "derivation"; |
||||
outPath = "/Applications/Xcode.app/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 |
||||
''; |
||||
} |
Loading…
Reference in new issue