diff options
author | Sander van der Burg <sander@conference-compass.com> | 2014-01-21 17:19:26 +0100 |
---|---|---|
committer | Sander van der Burg <sander@conference-compass.com> | 2014-01-21 17:19:26 +0100 |
commit | eb850385183e14d2f870bb46317242b9e216df9e (patch) | |
tree | 4fab2ffa6bc2c9203ad6a76b02af8c2af989aa85 /pkgs/development/mobile/titaniumenv/build-app.nix | |
parent | 6731ed2b86fdc2e62f86f9f077b02ffbe6efa71d (diff) | |
download | nixpkgs-eb850385183e14d2f870bb46317242b9e216df9e.tar nixpkgs-eb850385183e14d2f870bb46317242b9e216df9e.tar.gz nixpkgs-eb850385183e14d2f870bb46317242b9e216df9e.tar.bz2 nixpkgs-eb850385183e14d2f870bb46317242b9e216df9e.tar.lz nixpkgs-eb850385183e14d2f870bb46317242b9e216df9e.tar.xz nixpkgs-eb850385183e14d2f870bb46317242b9e216df9e.tar.zst nixpkgs-eb850385183e14d2f870bb46317242b9e216df9e.zip |
titaniumsdk: Replace deprecated python build tools by the new NodeJS based tool
Diffstat (limited to 'pkgs/development/mobile/titaniumenv/build-app.nix')
-rw-r--r-- | pkgs/development/mobile/titaniumenv/build-app.nix | 135 |
1 files changed, 71 insertions, 64 deletions
diff --git a/pkgs/development/mobile/titaniumenv/build-app.nix b/pkgs/development/mobile/titaniumenv/build-app.nix index 068a9acedda..ef2182135da 100644 --- a/pkgs/development/mobile/titaniumenv/build-app.nix +++ b/pkgs/development/mobile/titaniumenv/build-app.nix @@ -1,7 +1,7 @@ -{stdenv, androidsdk, titaniumsdk, xcodewrapper, jdk}: -{ appId, name, appName ? null, src, target, androidPlatformVersions ? [ "8" ], androidAbiVersions ? [ "armeabi" "armeabi-v7a" ] +{stdenv, androidsdk, titaniumsdk, titanium, xcodewrapper, jdk, python}: +{ name, src, target, androidPlatformVersions ? [ "8" ], androidAbiVersions ? [ "armeabi" "armeabi-v7a" ], tiVersion ? null , release ? false, androidKeyStore ? null, androidKeyAlias ? null, androidKeyStorePassword ? null -, iosMobileProvisioningProfile ? null, iosCertificateName ? null, iosCertificate ? null, iosCertificatePassword ? null, iosDistribute ? false +, iosMobileProvisioningProfile ? null, iosCertificateName ? null, iosCertificate ? null, iosCertificatePassword ? null }: assert (release && target == "android") -> androidKeyStore != null && androidKeyAlias != null && androidKeyStorePassword != null; @@ -15,92 +15,99 @@ let }; deleteKeychain = "security delete-keychain $keychainName"; - - _appName = if appName == null then name else appName; in stdenv.mkDerivation { name = stdenv.lib.replaceChars [" "] [""] name; inherit src; - buildInputs = [ jdk ] ++ stdenv.lib.optional (stdenv.system == "x86_64-darwin") xcodewrapper; + buildInputs = [ titanium jdk python ] ++ stdenv.lib.optional (stdenv.system == "x86_64-darwin") xcodewrapper; buildPhase = '' export HOME=$TMPDIR + + ${stdenv.lib.optionalString (tiVersion != null) '' + # Replace titanium version by the provided one + sed -i -e "s|<sdk-version>[0-9a-zA-Z\.]*</sdk-version>|<sdk-version>${tiVersion}</sdk-version>|" tiapp.xml + ''} + + # Simulate a login + mkdir -p $HOME/.titanium + cat > $HOME/.titanium/auth_session.json <<EOF + { "loggedIn": true } + EOF + + echo "{}" > $TMPDIR/config.json + titanium --config-file $TMPDIR/config.json config sdk.defaultInstallLocation ${titaniumsdk} mkdir -p $out ${if target == "android" then - if release then - ''${titaniumsdk}/mobilesdk/*/*/android/builder.py distribute "${_appName}" ${androidsdkComposition}/libexec/android-sdk-* $(pwd) ${appId} ${androidKeyStore} ${androidKeyStorePassword} ${androidKeyAlias} $out'' - else - ''${titaniumsdk}/mobilesdk/*/*/android/builder.py build "${_appName}" ${androidsdkComposition}/libexec/android-sdk-* $(pwd) ${appId}'' - + '' + titanium config --config-file $TMPDIR/config.json android.sdkPath ${androidsdkComposition}/libexec/android-sdk-* + + ${if release then + ''titanium build --config-file $TMPDIR/config.json --force --platform android --target dist-playstore --keystore ${androidKeyStore} --alias ${androidKeyAlias} --password ${androidKeyStorePassword} --output-dir $out'' + else + ''titanium build --config-file $TMPDIR/config.json --force --platform android --target emulator --build-only --output $out''} + '' else if target == "iphone" then - if iosDistribute then '' - export HOME=/Users/$(whoami) - export keychainName=$(basename $out) + '' + export NIX_TITANIUM_WORKAROUND="--config-file $TMPDIR/config.json" + + ${if release then + '' + export HOME=/Users/$(whoami) + export keychainName=$(basename $out) - # Create a keychain with the component hash name (should always be unique) - security create-keychain -p "" $keychainName - security default-keychain -s $keychainName - security unlock-keychain -p "" $keychainName - security import ${iosCertificate} -k $keychainName -P "${iosCertificatePassword}" -A + # Create a keychain with the component hash name (should always be unique) + security create-keychain -p "" $keychainName + security default-keychain -s $keychainName + security unlock-keychain -p "" $keychainName + security import ${iosCertificate} -k $keychainName -P "${iosCertificatePassword}" -A - provisioningId=$(grep UUID -A1 -a ${iosMobileProvisioningProfile} | grep -o "[-A-Z0-9]\{36\}") + provisioningId=$(grep UUID -A1 -a ${iosMobileProvisioningProfile} | grep -o "[-A-Z0-9]\{36\}") - # Ensure that the requested provisioning profile can be found - - if [ ! -f "$HOME/Library/MobileDevice/Provisioning Profiles/$provisioningId.mobileprovision" ] - then - mkdir -p "$HOME/Library/MobileDevice/Provisioning Profiles" - cp ${iosMobileProvisioningProfile} "$HOME/Library/MobileDevice/Provisioning Profiles/$provisioningId.mobileprovision" - fi + # Ensure that the requested provisioning profile can be found + + if [ ! -f "$HOME/Library/MobileDevice/Provisioning Profiles/$provisioningId.mobileprovision" ] + then + mkdir -p "$HOME/Library/MobileDevice/Provisioning Profiles" + cp ${iosMobileProvisioningProfile} "$HOME/Library/MobileDevice/Provisioning Profiles/$provisioningId.mobileprovision" + fi - ${titaniumsdk}/mobilesdk/*/*/iphone/builder.py distribute 7.0 $(pwd) ${appId} "${_appName}" "$provisioningId" "${iosCertificateName}" $out universal "$HOME/Library/Keychains/$keychainName" + # Make a copy of the Titanium SDK and fix its permissions. Without it, + # builds using the facebook module fail, because it needs to be writable - # Remove our generated keychain + cp -av ${titaniumsdk} $TMPDIR/titaniumsdk - ${deleteKeychain} - '' - else - if release then - '' - export HOME=/Users/$(whoami) - export keychainName=$(basename $out) + find $TMPDIR/titaniumsdk | while read i + do + chmod 755 "$i" + done - # Create a keychain with the component hash name (should always be unique) - security create-keychain -p "" $keychainName - security default-keychain -s $keychainName - security unlock-keychain -p "" $keychainName - security import ${iosCertificate} -k $keychainName -P "${iosCertificatePassword}" -A - - provisioningId=$(grep UUID -A1 -a ${iosMobileProvisioningProfile} | grep -o "[-A-Z0-9]\{36\}") - - # Ensure that the requested provisioning profile can be found + # Set the SDK to our copy + titanium --config-file $TMPDIR/config.json config sdk.defaultInstallLocation $TMPDIR/titaniumsdk - if [ ! -f "$HOME/Library/MobileDevice/Provisioning Profiles/$provisioningId.mobileprovision" ] - then - mkdir -p "$HOME/Library/MobileDevice/Provisioning Profiles" - cp ${iosMobileProvisioningProfile} "$HOME/Library/MobileDevice/Provisioning Profiles/$provisioningId.mobileprovision" - fi + # Do the actual build + titanium build --config-file $TMPDIR/config.json --force --platform ios --target dist-adhoc --pp-uuid $provisioningId --distribution-name "${iosCertificateName}" --keychain $HOME/Library/Keychains/$keychainName --device-family universal --output-dir $out - ${titaniumsdk}/mobilesdk/*/*/iphone/builder.py adhoc 7.0 $(pwd) ${appId} "${_appName}" "$provisioningId" "${iosCertificateName}" universal "$HOME/Library/Keychains/$keychainName" + # Remove our generated keychain - # Remove our generated keychain + ${deleteKeychain} + '' + else + '' + # Copy all sources to the output store directory. + # Why? Debug application include *.js files, which are symlinked into their + # sources. If they are not copied, we have dangling references to the + # temp folder. - ${deleteKeychain} - '' - else - '' - # Copy all sources to the output store directory. - # Why? Debug application include *.js files, which are symlinked into their - # sources. If they are not copied, we have dangling references to the - # temp folder. + cp -av * $out + cd $out - cp -av * $out - cd $out - ${titaniumsdk}/mobilesdk/*/*/iphone/builder.py build 7.0 $(pwd) ${appId} "${_appName}" universal - '' + titanium build --config-file $TMPDIR/config.json --force --platform ios --target simulator --build-only --device-family universal --output-dir $out + ''} + '' else throw "Target: ${target} is not supported!"} ''; |