From 8267fa4694d7afe3579f8e7016a8a27c78eb1a1e Mon Sep 17 00:00:00 2001 From: Carles Pagès Date: Sun, 20 Apr 2014 11:29:10 +0200 Subject: androidndk: add v9d I also updated the buildApp expression so it can build ndk based apps, when setting useNDK to true. --- pkgs/development/mobile/androidenv/androidndk.nix | 31 +++++++++++++++++++++++ pkgs/development/mobile/androidenv/build-app.nix | 20 ++++++++++----- pkgs/development/mobile/androidenv/default.nix | 8 ++++-- 3 files changed, 50 insertions(+), 9 deletions(-) create mode 100644 pkgs/development/mobile/androidenv/androidndk.nix (limited to 'pkgs/development/mobile') diff --git a/pkgs/development/mobile/androidenv/androidndk.nix b/pkgs/development/mobile/androidenv/androidndk.nix new file mode 100644 index 00000000000..cbcff8178e3 --- /dev/null +++ b/pkgs/development/mobile/androidenv/androidndk.nix @@ -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 {} \; + ''; +} diff --git a/pkgs/development/mobile/androidenv/build-app.nix b/pkgs/development/mobile/androidenv/build-app.nix index db7067c989c..ca00e78b2cb 100644 --- a/pkgs/development/mobile/androidenv/build-app.nix +++ b/pkgs/development/mobile/androidenv/build-app.nix @@ -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 diff --git a/pkgs/development/mobile/androidenv/default.nix b/pkgs/development/mobile/androidenv/default.nix index 1e87c30f6bd..bc022bd70b4 100644 --- a/pkgs/development/mobile/androidenv/default.nix +++ b/pkgs/development/mobile/androidenv/default.nix @@ -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 { -- cgit 1.4.1