titaniumsdk: Replace deprecated python build tools by the new NodeJS based tool
This commit is contained in:
parent
6731ed2b86
commit
eb85038518
@ -1,7 +1,7 @@
|
|||||||
{stdenv, androidsdk, titaniumsdk, xcodewrapper, jdk}:
|
{stdenv, androidsdk, titaniumsdk, titanium, xcodewrapper, jdk, python}:
|
||||||
{ appId, name, appName ? null, src, target, androidPlatformVersions ? [ "8" ], androidAbiVersions ? [ "armeabi" "armeabi-v7a" ]
|
{ name, src, target, androidPlatformVersions ? [ "8" ], androidAbiVersions ? [ "armeabi" "armeabi-v7a" ], tiVersion ? null
|
||||||
, release ? false, androidKeyStore ? null, androidKeyAlias ? null, androidKeyStorePassword ? 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;
|
assert (release && target == "android") -> androidKeyStore != null && androidKeyAlias != null && androidKeyStorePassword != null;
|
||||||
@ -15,55 +15,46 @@ let
|
|||||||
};
|
};
|
||||||
|
|
||||||
deleteKeychain = "security delete-keychain $keychainName";
|
deleteKeychain = "security delete-keychain $keychainName";
|
||||||
|
|
||||||
_appName = if appName == null then name else appName;
|
|
||||||
in
|
in
|
||||||
stdenv.mkDerivation {
|
stdenv.mkDerivation {
|
||||||
name = stdenv.lib.replaceChars [" "] [""] name;
|
name = stdenv.lib.replaceChars [" "] [""] name;
|
||||||
inherit src;
|
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 = ''
|
buildPhase = ''
|
||||||
export HOME=$TMPDIR
|
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
|
mkdir -p $out
|
||||||
|
|
||||||
${if target == "android" then
|
${if target == "android" then
|
||||||
if release then
|
''
|
||||||
''${titaniumsdk}/mobilesdk/*/*/android/builder.py distribute "${_appName}" ${androidsdkComposition}/libexec/android-sdk-* $(pwd) ${appId} ${androidKeyStore} ${androidKeyStorePassword} ${androidKeyAlias} $out''
|
titanium config --config-file $TMPDIR/config.json android.sdkPath ${androidsdkComposition}/libexec/android-sdk-*
|
||||||
else
|
|
||||||
''${titaniumsdk}/mobilesdk/*/*/android/builder.py build "${_appName}" ${androidsdkComposition}/libexec/android-sdk-* $(pwd) ${appId}''
|
|
||||||
|
|
||||||
|
${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
|
else if target == "iphone" then
|
||||||
if iosDistribute 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
|
|
||||||
|
|
||||||
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
|
|
||||||
|
|
||||||
${titaniumsdk}/mobilesdk/*/*/iphone/builder.py distribute 7.0 $(pwd) ${appId} "${_appName}" "$provisioningId" "${iosCertificateName}" $out universal "$HOME/Library/Keychains/$keychainName"
|
|
||||||
|
|
||||||
# Remove our generated keychain
|
|
||||||
|
|
||||||
${deleteKeychain}
|
|
||||||
''
|
''
|
||||||
else
|
export NIX_TITANIUM_WORKAROUND="--config-file $TMPDIR/config.json"
|
||||||
if release then
|
|
||||||
|
${if release then
|
||||||
''
|
''
|
||||||
export HOME=/Users/$(whoami)
|
export HOME=/Users/$(whoami)
|
||||||
export keychainName=$(basename $out)
|
export keychainName=$(basename $out)
|
||||||
@ -84,7 +75,21 @@ stdenv.mkDerivation {
|
|||||||
cp ${iosMobileProvisioningProfile} "$HOME/Library/MobileDevice/Provisioning Profiles/$provisioningId.mobileprovision"
|
cp ${iosMobileProvisioningProfile} "$HOME/Library/MobileDevice/Provisioning Profiles/$provisioningId.mobileprovision"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
${titaniumsdk}/mobilesdk/*/*/iphone/builder.py adhoc 7.0 $(pwd) ${appId} "${_appName}" "$provisioningId" "${iosCertificateName}" 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
|
||||||
|
|
||||||
|
cp -av ${titaniumsdk} $TMPDIR/titaniumsdk
|
||||||
|
|
||||||
|
find $TMPDIR/titaniumsdk | while read i
|
||||||
|
do
|
||||||
|
chmod 755 "$i"
|
||||||
|
done
|
||||||
|
|
||||||
|
# Set the SDK to our copy
|
||||||
|
titanium --config-file $TMPDIR/config.json config sdk.defaultInstallLocation $TMPDIR/titaniumsdk
|
||||||
|
|
||||||
|
# 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
|
||||||
|
|
||||||
# Remove our generated keychain
|
# Remove our generated keychain
|
||||||
|
|
||||||
@ -99,7 +104,9 @@ stdenv.mkDerivation {
|
|||||||
|
|
||||||
cp -av * $out
|
cp -av * $out
|
||||||
cd $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!"}
|
else throw "Target: ${target} is not supported!"}
|
||||||
|
@ -1,5 +1,25 @@
|
|||||||
{pkgs, pkgs_i686, xcodeVersion ? "5.0"}:
|
{pkgs, pkgs_i686, xcodeVersion ? "5.0"}:
|
||||||
|
|
||||||
|
let
|
||||||
|
# We have to use Oracle's JDK. On Darwin, just simply expose the host system's
|
||||||
|
# JDK. According to their docs, OpenJDK is not supported.
|
||||||
|
|
||||||
|
jdkWrapper = pkgs.stdenv.mkDerivation {
|
||||||
|
name = "jdk-wrapper";
|
||||||
|
buildCommand = ''
|
||||||
|
mkdir -p $out/bin
|
||||||
|
cd $out/bin
|
||||||
|
ln -s /usr/bin/javac
|
||||||
|
ln -s /usr/bin/java
|
||||||
|
ln -s /usr/bin/jarsigner
|
||||||
|
ln -s /usr/bin/jar
|
||||||
|
ln -s /usr/bin/keytool
|
||||||
|
'';
|
||||||
|
setupHook = ''
|
||||||
|
export JAVA_HOME=/usr
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
in
|
||||||
rec {
|
rec {
|
||||||
androidenv = pkgs.androidenv;
|
androidenv = pkgs.androidenv;
|
||||||
|
|
||||||
@ -12,7 +32,11 @@ rec {
|
|||||||
};
|
};
|
||||||
|
|
||||||
buildApp = import ./build-app.nix {
|
buildApp = import ./build-app.nix {
|
||||||
inherit (pkgs) stdenv jdk;
|
inherit (pkgs) stdenv python;
|
||||||
|
jdk = if pkgs.stdenv.isLinux then pkgs.oraclejdk7
|
||||||
|
else if pkgs.stdenv.isDarwin then jdkWrapper
|
||||||
|
else throw "Platform not supported: ${pkgs.stdenv.system}";
|
||||||
|
inherit (pkgs.nodePackages) titanium;
|
||||||
inherit (androidenv) androidsdk;
|
inherit (androidenv) androidsdk;
|
||||||
inherit (xcodeenv) xcodewrapper;
|
inherit (xcodeenv) xcodewrapper;
|
||||||
inherit titaniumsdk;
|
inherit titaniumsdk;
|
||||||
|
@ -27,9 +27,8 @@ let
|
|||||||
in
|
in
|
||||||
titaniumenv.buildApp {
|
titaniumenv.buildApp {
|
||||||
name = "KitchenSink-${target}-${if release then "release" else "debug"}";
|
name = "KitchenSink-${target}-${if release then "release" else "debug"}";
|
||||||
appName = "KitchenSink";
|
|
||||||
appId = if rename then newBundleId else "com.appcelerator.kitchensink";
|
|
||||||
src = if rename then renamedSrc else src;
|
src = if rename then renamedSrc else src;
|
||||||
|
tiVersion = "3.1.4.GA";
|
||||||
|
|
||||||
inherit target androidPlatformVersions release;
|
inherit target androidPlatformVersions release;
|
||||||
|
|
||||||
|
@ -72,5 +72,7 @@ stdenv.mkDerivation {
|
|||||||
'' + stdenv.lib.optionalString (stdenv.system == "x86_64-darwin") ''
|
'' + stdenv.lib.optionalString (stdenv.system == "x86_64-darwin") ''
|
||||||
# 'ditto' utility is needed to copy stuff to the Xcode organizer. Dirty, but this allows it to work.
|
# 'ditto' utility is needed to copy stuff to the Xcode organizer. Dirty, but this allows it to work.
|
||||||
sed -i -e "s|ditto|/usr/bin/ditto|g" $out/mobilesdk/osx/*/iphone/builder.py
|
sed -i -e "s|ditto|/usr/bin/ditto|g" $out/mobilesdk/osx/*/iphone/builder.py
|
||||||
|
|
||||||
|
sed -i -e "s|--xcode|--xcode '+process.env['NIX_TITANIUM_WORKAROUND']+'|" $out/mobilesdk/osx/*/iphone/cli/commands/_build.js
|
||||||
'';
|
'';
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user