3
0
Fork 0
forked from mirrors/nixpkgs

Merge pull request #2346 from cpages/android

Add android ndk support
This commit is contained in:
Sander van der Burg 2014-04-21 23:27:10 +02:00
commit 281126d7ee
3 changed files with 50 additions and 9 deletions

View file

@ -0,0 +1,31 @@
{ stdenv, fetchurl, zlib, ncurses
}:
stdenv.mkDerivation rec {
name = "android-ndk-r9d";
src = if stdenv.system == "i686-linux"
then fetchurl {
url = "http://dl.google.com/android/ndk/${name}-linux-x86.tar.bz2";
md5 = "6c1d7d99f55f0c17ecbcf81ba0eb201f";
}
else if stdenv.system == "x86_64-linux" then fetchurl {
url = "http://dl.google.com/android/ndk/${name}-linux-x86_64.tar.bz2";
md5 = "c7c775ab3342965408d20fd18e71aa45";
}
else throw "platform not ${stdenv.system} supported!";
phases = "installPhase";
installPhase = ''
set -x
mkdir -pv $out
tar xf $src
mv */* $out
find $out \( \
\( -type f -a -name "*.so*" \) -o \
\( -type f -a -perm +0100 \) \
\) -exec patchelf --set-interpreter ${stdenv.gcc.libc}/lib/ld-*so.? \
--set-rpath ${zlib}/lib:${ncurses}/lib {} \;
'';
}

View file

@ -1,7 +1,7 @@
{ stdenv, androidsdk, jdk, ant }:
{ stdenv, androidsdk, jdk, ant, androidndk, gnumake, gawk, file, which }:
args@{ name, src, platformVersions ? [ "8" ], useGoogleAPIs ? false, antFlags ? ""
, release ? false, keyStore ? null, keyAlias ? null, keyStorePassword ? null, keyAliasPassword ? null
, ...
, useNDK ? false, ...
}:
assert release -> keyStore != null && keyAlias != null && keyStorePassword != null && keyAliasPassword != null;
@ -18,11 +18,12 @@ let
in
stdenv.mkDerivation ({
name = stdenv.lib.replaceChars [" "] [""] name;
ANDROID_HOME = "${androidsdkComposition}/libexec/android-sdk-${platformName}";
buildInputs = [ jdk ant ];
buildInputs = [ jdk ant ] ++
stdenv.lib.optional useNDK [ androidndk gnumake gawk file which ];
buildPhase = ''
${stdenv.lib.optionalString release ''
@ -33,11 +34,16 @@ stdenv.mkDerivation ({
echo "key.alias.password=${keyAliasPassword}"
) >> ant.properties
''}
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}/ndk-build
'' else ""}
ant ${antFlags} ${if release then "release" else "debug"}
'';
installPhase = ''
mkdir -p $out
mv bin/*-${if release then "release" else "debug"}.apk $out

View file

@ -81,10 +81,14 @@ rec {
abiVersions = [ "armeabi-v7a" "x86" ];
useGoogleAPIs = true;
};
androidndk = import ./androidndk.nix {
inherit (pkgs) stdenv fetchurl zlib ncurses;
};
buildApp = import ./build-app.nix {
inherit (pkgs) stdenv jdk ant;
inherit androidsdk;
inherit (pkgs) stdenv jdk ant gnumake gawk file which;
inherit androidsdk androidndk;
};
emulateApp = import ./emulate-app.nix {