build-android/build.sh
author Edouard Tisserant
Sat, 26 Sep 2015 20:18:22 +0200
changeset 353 f1ca187ee8cb
parent 337 ea7d347eaf6c
child 369 906f46ffd840
permissions -rwxr-xr-x
Android : build script now needs GPGME_INCLUDE_PATH env var to be set.
     1 #!/bin/sh
     2 
     3 set -e
     4 
     5 build_version=1
     6 ANDROID_PLATFORM=android-21
     7 openssl_build_version=1
     8 cyrus_sasl_build_version=1
     9 libetpan_build_version=1
    10 archs="armeabi armeabi-v7a x86 x86_64"
    11 package_name=pEpEngine-android
    12 
    13 current_dir="`pwd`"
    14 libetpan_dir="$current_dir/../../libetpan/build-android"
    15 
    16 if test "x$ANDROID_NDK" = x ; then
    17   echo should set ANDROID_NDK before running this script.
    18   exit 1
    19 fi
    20 
    21 if test "x$GPGME_INCLUDE_PATH" = x ; then
    22   echo should set GPGME_INCLUDE_PATH before running this script.
    23   exit 1
    24 fi
    25 
    26 function build {
    27   rm -rf "$current_dir/obj"
    28   
    29   cd "$current_dir/jni"
    30   $ANDROID_NDK/ndk-build V=1 TARGET_PLATFORM=$ANDROID_PLATFORM TARGET_ARCH_ABI=$TARGET_ARCH_ABI \
    31     OPENSSL_PATH="$current_dir/third-party/openssl-android-$openssl_build_version" \
    32     CYRUS_SASL_PATH="$current_dir/third-party/cyrus-sasl-android-$cyrus_sasl_build_version" \
    33     LIBETPAN_PATH="$current_dir/third-party/libetpan-android-$libetpan_build_version"
    34 
    35   mkdir -p "$current_dir/$package_name-$build_version/libs/$TARGET_ARCH_ABI"
    36   cp "$current_dir/obj/local/$TARGET_ARCH_ABI/libpEpEngine.a" "$current_dir/$package_name-$build_version/libs/$TARGET_ARCH_ABI"
    37   rm -rf "$current_dir/obj"
    38 }
    39 
    40 mkdir -p "$current_dir/third-party"
    41 cd "$current_dir/third-party"
    42 unzip -qo "$libetpan_dir/dependencies/openssl/openssl-android-$openssl_build_version.zip"
    43 unzip -qo "$libetpan_dir/dependencies/cyrus-sasl/cyrus-sasl-android-$cyrus_sasl_build_version.zip"
    44 unzip -qo "$libetpan_dir/libetpan-android-$libetpan_build_version.zip"
    45 
    46 # Copy public headers to include
    47 mkdir -p "$current_dir/$package_name-$build_version/include/pEp"
    48 cd "$current_dir/../src"
    49 cp *.h "$current_dir/$package_name-$build_version/include/pEp"
    50 
    51 # Start building.
    52 for arch in $archs ; do
    53   TARGET_ARCH_ABI=$arch
    54   build
    55 done
    56 
    57 rm -rf "$current_dir/third-party"
    58 cd "$current_dir"
    59 zip -qry "$package_name-$build_version.zip" "$package_name-$build_version"
    60 rm -rf "$package_name-$build_version"