build-android/build.sh
author Edouard Tisserant
Wed, 12 Oct 2016 11:58:14 +0200
changeset 1268 10397798d2b3
parent 660 e1905543313b
child 1513 e7f7e42385b5
permissions -rwxr-xr-x
Android : invoke sync code gen from build.sh since some of generated code isn't in repo anymore
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
libetpan_build_version=1
Edouard@394
     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
Edouard@333
    13
if test "x$ANDROID_NDK" = x ; then
Edouard@333
    14
  echo should set ANDROID_NDK before running this script.
Edouard@333
    15
  exit 1
Edouard@333
    16
fi
Edouard@333
    17
Edouard@353
    18
if test "x$GPGME_INCLUDE_PATH" = x ; then
Edouard@353
    19
  echo should set GPGME_INCLUDE_PATH before running this script.
Edouard@353
    20
  exit 1
Edouard@353
    21
fi
Edouard@353
    22
Edouard@369
    23
if test "x$LIBETPAN_PATH" = x ; then
Edouard@369
    24
  echo should set LIBETPAN_PATH before running this script.
Edouard@369
    25
  exit 1
Edouard@369
    26
fi
Edouard@369
    27
Edouard@369
    28
libetpan_dir=$LIBETPAN_PATH
Edouard@369
    29
Edouard@333
    30
function build {
Edouard@333
    31
  rm -rf "$current_dir/obj"
Edouard@333
    32
  
Edouard@333
    33
  cd "$current_dir/jni"
Edouard@333
    34
  $ANDROID_NDK/ndk-build V=1 TARGET_PLATFORM=$ANDROID_PLATFORM TARGET_ARCH_ABI=$TARGET_ARCH_ABI \
Edouard@333
    35
    LIBETPAN_PATH="$current_dir/third-party/libetpan-android-$libetpan_build_version"
Edouard@333
    36
Edouard@333
    37
  mkdir -p "$current_dir/$package_name-$build_version/libs/$TARGET_ARCH_ABI"
Edouard@333
    38
  cp "$current_dir/obj/local/$TARGET_ARCH_ABI/libpEpEngine.a" "$current_dir/$package_name-$build_version/libs/$TARGET_ARCH_ABI"
Edouard@333
    39
  rm -rf "$current_dir/obj"
Edouard@333
    40
}
Edouard@333
    41
Edouard@333
    42
mkdir -p "$current_dir/third-party"
Edouard@333
    43
cd "$current_dir/third-party"
Edouard@333
    44
unzip -qo "$libetpan_dir/libetpan-android-$libetpan_build_version.zip"
Edouard@333
    45
Edouard@333
    46
# Copy public headers to include
Edouard@333
    47
mkdir -p "$current_dir/$package_name-$build_version/include/pEp"
Edouard@333
    48
cd "$current_dir/../src"
Edouard@333
    49
cp *.h "$current_dir/$package_name-$build_version/include/pEp"
Edouard@333
    50
Hussein@660
    51
# Generate asn.1
Hussein@660
    52
cd "$current_dir/../asn.1"
Hussein@660
    53
make generate
Hussein@660
    54
Edouard@1268
    55
# Generate asn.1
Edouard@1268
    56
cd "$current_dir/../sync"
Edouard@1268
    57
make
Edouard@1268
    58
Edouard@333
    59
# Start building.
Edouard@333
    60
for arch in $archs ; do
Edouard@333
    61
  TARGET_ARCH_ABI=$arch
Edouard@333
    62
  build
Edouard@333
    63
done
Edouard@333
    64
Edouard@333
    65
rm -rf "$current_dir/third-party"
Edouard@333
    66
cd "$current_dir"
Edouard@333
    67
zip -qry "$package_name-$build_version.zip" "$package_name-$build_version"
Edouard@333
    68
rm -rf "$package_name-$build_version"