- Added xcodeenv: experimental support to build iOS apps through Nix

- Moved mobile development tools into a separate folder
This commit is contained in:
Sander van der Burg 2013-01-07 16:52:42 +01:00
parent a547de1ecb
commit 5b0ca88d97
26 changed files with 167 additions and 9 deletions

View File

@ -1,7 +1,7 @@
{ stdenv, fetchurl, apr, expat
, sslSupport ? true, openssl
, bdbSupport ? false, db4
, ldapSupport ? true, openldap
, ldapSupport ? false, openldap
}:
assert sslSupport -> openssl != null;

View File

@ -18,6 +18,7 @@ stdenv.mkDerivation rec {
};
configurePhase = ''
${stdenv.lib.optionalString (stdenv.system == "x86_64-darwin") "export PATH=/usr/bin:$PATH"}
mkdir build/gyp
ln -sv ${gyp}/bin/gyp build/gyp/gyp
'';
@ -37,7 +38,11 @@ stdenv.mkDerivation rec {
mkdir -p $out/bin
mkdir -p $out/lib
mv -v out/${arch}.release/d8 $out/bin
mv -v out/${arch}.release/lib.target/libv8.so $out/lib
${if stdenv.system == "x86_64-darwin" then
"mv -v out/${arch}.release/libv8.dylib $out/lib"
else
"mv -v out/${arch}.release/lib.target/libv8.so $out/lib"}
mv -v include $out/
'';
}

View File

@ -0,0 +1,92 @@
{stdenv, xcodewrapper}:
{ name
, src
, target ? null
, configuration ? null
, scheme ? null
, sdk ? null
, arch ? null
, xcodeFlags ? ""
, release ? false
, codeSignIdentity ? null
, certificateFile ? null
, certificatePassword ? null
, provisioningProfile ? null
, generateIPA ? false
, generateXCArchive ? false
}:
assert release -> codeSignIdentity != null && certificateFile != null && certificatePassword != null && provisioningProfile != null;
let
# Set some default values here
_target = if target == null then name else target;
_scheme = if scheme == null then name else scheme;
_configuration = if configuration == null
then
if release then "Release" else "Debug"
else configuration;
_arch = if arch == null
then
if release then "armv7" else "i386"
else arch;
_sdk = if sdk == null
then
if release then "iphoneos6.0" else "iphonesimulator6.0"
else sdk;
# The following is to prevent repetition
deleteKeychain = "security delete-keychain $keychainName";
in
stdenv.mkDerivation {
inherit name src;
buildInputs = [ xcodewrapper ];
buildPhase = ''
${stdenv.lib.optionalString release ''
export HOME=/Users/$(whoami)
keychainName="$(basename $out)"
# Create a keychain
security create-keychain -p "" $keychainName
security default-keychain -s $keychainName
security unlock-keychain -p "" $keychainName
# Import the certificate into the keychain
security import ${certificateFile} -k $keychainName -P "${certificatePassword}" -A
# Determine provisioning ID
PROVISIONING_PROFILE=$(grep UUID -A1 -a ${provisioningProfile} | grep -o "[-A-Z0-9]\{36\}")
if [ ! -f "$HOME/Library/MobileDevice/Provisioning Profiles/$PROVISIONING_PROFILE.mobileprovision" ]
then
# Copy provisioning profile into the home directory
mkdir -p "$HOME/Library/MobileDevice/Provisioning Profiles"
cp ${provisioningProfile} "$HOME/Library/MobileDevice/Provisioning Profiles/$PROVISIONING_PROFILE.mobileprovision"
fi
# Check whether the identity can be found
security find-identity -p codesigning $keychainName
''}
# Do the building
xcodebuild -target ${_target} -configuration ${_configuration} -scheme ${_scheme} -sdk ${_sdk} -arch ${_arch} ONLY_ACTIVE_ARCH=NO CONFIGURATION_TEMP_DIR=$TMPDIR CONFIGURATION_BUILD_DIR=$out ${if generateXCArchive then "archive" else ""} ${xcodeFlags} ${if release then ''"CODE_SIGN_IDENTITY=${codeSignIdentity}" PROVISIONING_PROFILE=$PROVISIONING_PROFILE OTHER_CODE_SIGN_FLAGS="--keychain $HOME/Library/Keychains/$keychainName"'' else ""}
${stdenv.lib.optionalString release ''
${stdenv.lib.optionalString generateIPA ''
# Produce an IPA file
xcrun -sdk iphoneos PackageApplication -v $out/*.app -o $out/${name}.ipa
''}
# Delete our temp keychain
${deleteKeychain}
''}
'';
failureHook = stdenv.lib.optionalString release deleteKeychain;
installPhase = "true";
}

View File

@ -0,0 +1,15 @@
{stdenv}:
rec {
xcodewrapper = import ./xcodewrapper.nix {
inherit stdenv;
};
buildApp = import ./build-app.nix {
inherit stdenv xcodewrapper;
};
simulateApp = import ./simulate-app.nix {
inherit stdenv xcodewrapper;
};
}

View File

@ -0,0 +1,17 @@
{stdenv, xcodewrapper}:
{name, app, device ? "iPhone", baseDir ? ""}:
stdenv.mkDerivation {
inherit name;
buildCommand = ''
ensureDir $out/bin
cat > $out/bin/run-test-simulator << "EOF"
#! ${stdenv.shell} -e
cd ${app}/${baseDir}/${name}.app
"$(readlink "${xcodewrapper}/bin/iPhone Simulator")" -SimulateApplication ./${name} -SimulateDevice '${device}'
EOF
chmod +x $out/bin/run-test-simulator
'';
}

View File

@ -0,0 +1,24 @@
{stdenv}:
let
version = "4.5.2";
in
stdenv.mkDerivation {
name = "xcode-wrapper-"+version;
buildCommand = ''
ensureDir $out/bin
cd $out/bin
ln -s /usr/bin/xcode-select
ln -s /usr/bin/xcodebuild
ln -s /usr/bin/xcrun
ln -s /usr/bin/security
ln -s "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/Applications/iPhone Simulator.app/Contents/MacOS/iPhone Simulator"
# Check if we have the xcodebuild version that we want
if [ -z "$($out/bin/xcodebuild -version | grep ${version})" ]
then
echo "We require xcodebuild version: ${version}"
exit 1
fi
'';
}

View File

@ -12,20 +12,23 @@ stdenv.mkDerivation rec {
configureFlags = [
"--openssl-includes=${openssl}/include"
"--openssl-libpath=${openssl}/lib"
"--shared-v8"
"--shared-v8-includes=${v8}/includes"
"--shared-v8-libpath=${v8}/lib"
#"--shared-v8"
#"--shared-v8-includes=${v8}/includes"
#"--shared-v8-libpath=${v8}/lib"
];
patches = stdenv.lib.optional stdenv.isDarwin ./no-arch-flag.patch;
#patches = stdenv.lib.optional stdenv.isDarwin ./no-arch-flag.patch;
prePatch = ''
sed -e 's|^#!/usr/bin/env python$|#!${python}/bin/python|g' -i tools/{*.py,waf-light,node-waf} configure
sed=$(type -p sed)
export PATH=/usr/bin:$PATH
$sed -e 's|^#!/usr/bin/env python$|#!${python}/bin/python|g' -i tools/{*.py,waf-light,node-waf} configure
'';
postInstall = ''
sed -e 's|^#!/usr/bin/env node$|#!'$out'/bin/node|' -i $out/lib/node_modules/npm/bin/npm-cli.js
$sed -e 's|^#!/usr/bin/env node$|#!'$out'/bin/node|' -i $out/lib/node_modules/npm/bin/npm-cli.js
'' + stdenv.lib.optionalString stdenv.isDarwin ''
install_name_tool -change libv8.dylib ${v8}/lib/libv8.dylib $out/bin/node
'';

View File

@ -411,11 +411,13 @@ let
client = true;
});
androidenv = import ../development/androidenv {
androidenv = import ../development/mobile/androidenv {
inherit pkgs;
pkgs_i686 = pkgsi686Linux;
};
xcodeenv = callPackage ../development/mobile/xcodeenv { };
inherit (androidenv) androidsdk_4_1;
aria = builderDefsPackage (import ../tools/networking/aria) { };