Replace androidenv by new implementation
This commit is contained in:
@@ -1,28 +1,26 @@
|
||||
{ stdenv, androidsdk, jdk, ant, androidndk, gnumake, gawk, file, which }:
|
||||
args@{ name, src, platformVersions ? [ "8" ], useGoogleAPIs ? false, antFlags ? ""
|
||||
{ composeAndroidPackages, stdenv, ant, jdk, gnumake, gawk }:
|
||||
|
||||
{ name
|
||||
, release ? false, keyStore ? null, keyAlias ? null, keyStorePassword ? null, keyAliasPassword ? null
|
||||
, useNDK ? false, ...
|
||||
}:
|
||||
, antFlags ? ""
|
||||
, ...
|
||||
}@args:
|
||||
|
||||
assert release -> keyStore != null && keyAlias != null && keyStorePassword != null && keyAliasPassword != null;
|
||||
|
||||
let
|
||||
androidsdkComposition = androidsdk {
|
||||
inherit platformVersions useGoogleAPIs;
|
||||
abiVersions = [];
|
||||
};
|
||||
androidSdkFormalArgs = builtins.functionArgs composeAndroidPackages;
|
||||
androidArgs = builtins.intersectAttrs androidSdkFormalArgs args;
|
||||
androidsdk = (composeAndroidPackages androidArgs).androidsdk;
|
||||
|
||||
extraArgs = removeAttrs args ([ "name" ] ++ builtins.attrNames androidSdkFormalArgs);
|
||||
in
|
||||
stdenv.mkDerivation ({
|
||||
name = stdenv.lib.replaceChars [" "] [""] name;
|
||||
|
||||
ANDROID_HOME = "${androidsdkComposition}/libexec";
|
||||
|
||||
buildInputs = [ jdk ant ] ++
|
||||
stdenv.lib.optional useNDK [ androidndk gnumake gawk file which ];
|
||||
|
||||
name = stdenv.lib.replaceChars [" "] [""] name; # Android APKs may contain white spaces in their names, but Nix store paths cannot
|
||||
ANDROID_HOME = "${androidsdk}/libexec/android-sdk";
|
||||
buildInputs = [ jdk ant ];
|
||||
buildPhase = ''
|
||||
${stdenv.lib.optionalString release ''
|
||||
|
||||
# Provide key singing attributes
|
||||
( echo "key.store=${keyStore}"
|
||||
echo "key.alias=${keyAlias}"
|
||||
@@ -32,20 +30,19 @@ stdenv.mkDerivation ({
|
||||
''}
|
||||
|
||||
export ANDROID_SDK_HOME=`pwd` # Key files cannot be stored in the user's home directory. This overrides it.
|
||||
${if useNDK then ''
|
||||
export GNUMAKE=${gnumake}/bin/make
|
||||
export NDK_HOST_AWK=${gawk}/bin/gawk
|
||||
${androidndk}/bin/ndk-build
|
||||
'' else ""}
|
||||
|
||||
${stdenv.lib.optionalString (args ? includeNDK && args.includeNDK) ''
|
||||
export GNUMAKE=${gnumake}/bin/make
|
||||
export NDK_HOST_AWK=${gawk}/bin/gawk
|
||||
${androidsdk}/libexec/android-sdk/ndk-bundle/ndk-build
|
||||
''}
|
||||
ant ${antFlags} ${if release then "release" else "debug"}
|
||||
'';
|
||||
|
||||
installPhase = ''
|
||||
mkdir -p $out
|
||||
mv bin/*-${if release then "release" else "debug"}.apk $out
|
||||
|
||||
|
||||
mkdir -p $out/nix-support
|
||||
echo "file binary-dist \"$(echo $out/*.apk)\"" > $out/nix-support/hydra-build-products
|
||||
'';
|
||||
} //
|
||||
builtins.removeAttrs args ["name"])
|
||||
} // extraArgs)
|
||||
|
||||
Reference in New Issue
Block a user