build-android/build.sh
author Krista Grothoff <krista@pep-project.org>
Fri, 11 Nov 2016 14:10:30 +0100
branchENGINE-84
changeset 1378 b2b2c6d361c9
parent 1268 10397798d2b3
child 1513 e7f7e42385b5
permissions -rwxr-xr-x
ENGINE-84: merge with default
     1 #!/bin/sh
     2 
     3 set -e
     4 
     5 build_version=1
     6 ANDROID_PLATFORM=android-21
     7 libetpan_build_version=1
     8 archs="armeabi armeabi-v7a x86 x86_64"
     9 package_name=pEpEngine-android
    10 
    11 current_dir="`pwd`"
    12 
    13 if test "x$ANDROID_NDK" = x ; then
    14   echo should set ANDROID_NDK before running this script.
    15   exit 1
    16 fi
    17 
    18 if test "x$GPGME_INCLUDE_PATH" = x ; then
    19   echo should set GPGME_INCLUDE_PATH before running this script.
    20   exit 1
    21 fi
    22 
    23 if test "x$LIBETPAN_PATH" = x ; then
    24   echo should set LIBETPAN_PATH before running this script.
    25   exit 1
    26 fi
    27 
    28 libetpan_dir=$LIBETPAN_PATH
    29 
    30 function build {
    31   rm -rf "$current_dir/obj"
    32   
    33   cd "$current_dir/jni"
    34   $ANDROID_NDK/ndk-build V=1 TARGET_PLATFORM=$ANDROID_PLATFORM TARGET_ARCH_ABI=$TARGET_ARCH_ABI \
    35     LIBETPAN_PATH="$current_dir/third-party/libetpan-android-$libetpan_build_version"
    36 
    37   mkdir -p "$current_dir/$package_name-$build_version/libs/$TARGET_ARCH_ABI"
    38   cp "$current_dir/obj/local/$TARGET_ARCH_ABI/libpEpEngine.a" "$current_dir/$package_name-$build_version/libs/$TARGET_ARCH_ABI"
    39   rm -rf "$current_dir/obj"
    40 }
    41 
    42 mkdir -p "$current_dir/third-party"
    43 cd "$current_dir/third-party"
    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 # Generate asn.1
    52 cd "$current_dir/../asn.1"
    53 make generate
    54 
    55 # Generate asn.1
    56 cd "$current_dir/../sync"
    57 make
    58 
    59 # Start building.
    60 for arch in $archs ; do
    61   TARGET_ARCH_ABI=$arch
    62   build
    63 done
    64 
    65 rm -rf "$current_dir/third-party"
    66 cd "$current_dir"
    67 zip -qry "$package_name-$build_version.zip" "$package_name-$build_version"
    68 rm -rf "$package_name-$build_version"