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