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