2019-08-17 09:48:09 +01:00
|
|
|
{ composeAndroidPackages, stdenv, lib, ant, jdk, gnumake, gawk }:
|
2018-11-27 19:36:27 +00:00
|
|
|
|
|
|
|
{ name
|
2012-11-07 20:10:39 +00:00
|
|
|
, release ? false, keyStore ? null, keyAlias ? null, keyStorePassword ? null, keyAliasPassword ? null
|
2018-11-27 19:36:27 +00:00
|
|
|
, antFlags ? ""
|
|
|
|
, ...
|
|
|
|
}@args:
|
2012-11-07 20:10:39 +00:00
|
|
|
|
|
|
|
assert release -> keyStore != null && keyAlias != null && keyStorePassword != null && keyAliasPassword != null;
|
|
|
|
|
|
|
|
let
|
2018-11-27 19:36:27 +00:00
|
|
|
androidSdkFormalArgs = builtins.functionArgs composeAndroidPackages;
|
|
|
|
androidArgs = builtins.intersectAttrs androidSdkFormalArgs args;
|
|
|
|
androidsdk = (composeAndroidPackages androidArgs).androidsdk;
|
|
|
|
|
|
|
|
extraArgs = removeAttrs args ([ "name" ] ++ builtins.attrNames androidSdkFormalArgs);
|
2012-11-07 20:10:39 +00:00
|
|
|
in
|
2013-10-15 15:32:16 +01:00
|
|
|
stdenv.mkDerivation ({
|
2019-08-17 09:48:09 +01:00
|
|
|
name = lib.replaceChars [" "] [""] name; # Android APKs may contain white spaces in their names, but Nix store paths cannot
|
2018-11-27 19:36:27 +00:00
|
|
|
ANDROID_HOME = "${androidsdk}/libexec/android-sdk";
|
|
|
|
buildInputs = [ jdk ant ];
|
2012-11-07 20:10:39 +00:00
|
|
|
buildPhase = ''
|
2019-08-17 09:48:09 +01:00
|
|
|
${lib.optionalString release ''
|
2012-11-07 20:10:39 +00:00
|
|
|
# Provide key singing attributes
|
|
|
|
( echo "key.store=${keyStore}"
|
|
|
|
echo "key.alias=${keyAlias}"
|
|
|
|
echo "key.store.password=${keyStorePassword}"
|
|
|
|
echo "key.alias.password=${keyAliasPassword}"
|
|
|
|
) >> ant.properties
|
|
|
|
''}
|
2014-04-20 10:29:10 +01:00
|
|
|
|
2012-11-07 20:10:39 +00:00
|
|
|
export ANDROID_SDK_HOME=`pwd` # Key files cannot be stored in the user's home directory. This overrides it.
|
2018-11-27 19:36:27 +00:00
|
|
|
|
2019-08-17 09:48:09 +01:00
|
|
|
${lib.optionalString (args ? includeNDK && args.includeNDK) ''
|
2018-11-27 19:36:27 +00:00
|
|
|
export GNUMAKE=${gnumake}/bin/make
|
|
|
|
export NDK_HOST_AWK=${gawk}/bin/gawk
|
|
|
|
${androidsdk}/libexec/android-sdk/ndk-bundle/ndk-build
|
|
|
|
''}
|
2013-08-01 10:21:54 +01:00
|
|
|
ant ${antFlags} ${if release then "release" else "debug"}
|
2012-11-07 20:10:39 +00:00
|
|
|
'';
|
|
|
|
installPhase = ''
|
|
|
|
mkdir -p $out
|
2013-03-21 13:21:20 +00:00
|
|
|
mv bin/*-${if release then "release" else "debug"}.apk $out
|
2018-11-27 19:36:27 +00:00
|
|
|
|
2013-03-05 11:29:48 +00:00
|
|
|
mkdir -p $out/nix-support
|
2013-03-21 13:11:58 +00:00
|
|
|
echo "file binary-dist \"$(echo $out/*.apk)\"" > $out/nix-support/hydra-build-products
|
2012-11-07 20:10:39 +00:00
|
|
|
'';
|
2018-11-27 19:36:27 +00:00
|
|
|
} // extraArgs)
|