build-android/build.sh
author Edouard Tisserant
Sat, 10 Oct 2015 17:24:45 +0200
changeset 371 2b34176e3fd7
parent 369 906f46ffd840
child 394 a872e68c2104
permissions -rwxr-xr-x
Fixed double free and unprotected NULL dereferencing.
     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 archs="armeabi"
    12 package_name=pEpEngine-android
    13 
    14 current_dir="`pwd`"
    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 if test "x$LIBETPAN_PATH" = x ; then
    27   echo should set LIBETPAN_PATH before running this script.
    28   exit 1
    29 fi
    30 
    31 libetpan_dir=$LIBETPAN_PATH
    32 
    33 function build {
    34   rm -rf "$current_dir/obj"
    35   
    36   cd "$current_dir/jni"
    37   $ANDROID_NDK/ndk-build V=1 TARGET_PLATFORM=$ANDROID_PLATFORM TARGET_ARCH_ABI=$TARGET_ARCH_ABI \
    38     OPENSSL_PATH="$current_dir/third-party/openssl-android-$openssl_build_version" \
    39     CYRUS_SASL_PATH="$current_dir/third-party/cyrus-sasl-android-$cyrus_sasl_build_version" \
    40     LIBETPAN_PATH="$current_dir/third-party/libetpan-android-$libetpan_build_version"
    41 
    42   mkdir -p "$current_dir/$package_name-$build_version/libs/$TARGET_ARCH_ABI"
    43   cp "$current_dir/obj/local/$TARGET_ARCH_ABI/libpEpEngine.a" "$current_dir/$package_name-$build_version/libs/$TARGET_ARCH_ABI"
    44   rm -rf "$current_dir/obj"
    45 }
    46 
    47 mkdir -p "$current_dir/third-party"
    48 cd "$current_dir/third-party"
    49 unzip -qo "$libetpan_dir/dependencies/openssl/openssl-android-$openssl_build_version.zip"
    50 unzip -qo "$libetpan_dir/dependencies/cyrus-sasl/cyrus-sasl-android-$cyrus_sasl_build_version.zip"
    51 unzip -qo "$libetpan_dir/libetpan-android-$libetpan_build_version.zip"
    52 
    53 # Copy public headers to include
    54 mkdir -p "$current_dir/$package_name-$build_version/include/pEp"
    55 cd "$current_dir/../src"
    56 cp *.h "$current_dir/$package_name-$build_version/include/pEp"
    57 
    58 # Start building.
    59 for arch in $archs ; do
    60   TARGET_ARCH_ABI=$arch
    61   build
    62 done
    63 
    64 rm -rf "$current_dir/third-party"
    65 cd "$current_dir"
    66 zip -qry "$package_name-$build_version.zip" "$package_name-$build_version"
    67 rm -rf "$package_name-$build_version"