build-android/build.sh
author Krista 'DarthMama' Bennett <krista@pep.foundation>
Tue, 04 Jun 2019 15:08:54 +0200
branchENGINE-559
changeset 3829 e1d53d19bb4d
parent 1528 f0ed0f1f2b56
permissions -rwxr-xr-x
Merged in sync/parent
Edouard@333
     1
#!/bin/sh
Edouard@333
     2
vb@1513
     3
# This file is under GNU General Public License 3.0
vb@1513
     4
# see LICENSE.txt
vb@1513
     5
Edouard@353
     6
set -e
Edouard@353
     7
Edouard@333
     8
build_version=1
huss@1528
     9
ANDROID_PLATFORM=android-18
Edouard@333
    10
libetpan_build_version=1
Edouard@394
    11
archs="armeabi armeabi-v7a x86 x86_64"
Edouard@333
    12
package_name=pEpEngine-android
Edouard@333
    13
Edouard@333
    14
current_dir="`pwd`"
Edouard@333
    15
Edouard@333
    16
if test "x$ANDROID_NDK" = x ; then
Edouard@333
    17
  echo should set ANDROID_NDK before running this script.
Edouard@333
    18
  exit 1
Edouard@333
    19
fi
Edouard@333
    20
Edouard@353
    21
if test "x$GPGME_INCLUDE_PATH" = x ; then
Edouard@353
    22
  echo should set GPGME_INCLUDE_PATH before running this script.
Edouard@353
    23
  exit 1
Edouard@353
    24
fi
Edouard@353
    25
Edouard@369
    26
if test "x$LIBETPAN_PATH" = x ; then
Edouard@369
    27
  echo should set LIBETPAN_PATH before running this script.
Edouard@369
    28
  exit 1
Edouard@369
    29
fi
Edouard@369
    30
Edouard@369
    31
libetpan_dir=$LIBETPAN_PATH
Edouard@369
    32
Edouard@333
    33
function build {
Edouard@333
    34
  rm -rf "$current_dir/obj"
Edouard@333
    35
  
Edouard@333
    36
  cd "$current_dir/jni"
Edouard@333
    37
  $ANDROID_NDK/ndk-build V=1 TARGET_PLATFORM=$ANDROID_PLATFORM TARGET_ARCH_ABI=$TARGET_ARCH_ABI \
Edouard@333
    38
    LIBETPAN_PATH="$current_dir/third-party/libetpan-android-$libetpan_build_version"
Edouard@333
    39
Edouard@333
    40
  mkdir -p "$current_dir/$package_name-$build_version/libs/$TARGET_ARCH_ABI"
Edouard@333
    41
  cp "$current_dir/obj/local/$TARGET_ARCH_ABI/libpEpEngine.a" "$current_dir/$package_name-$build_version/libs/$TARGET_ARCH_ABI"
Edouard@333
    42
  rm -rf "$current_dir/obj"
Edouard@333
    43
}
Edouard@333
    44
Edouard@333
    45
mkdir -p "$current_dir/third-party"
Edouard@333
    46
cd "$current_dir/third-party"
Edouard@333
    47
unzip -qo "$libetpan_dir/libetpan-android-$libetpan_build_version.zip"
Edouard@333
    48
Edouard@333
    49
# Copy public headers to include
Edouard@333
    50
mkdir -p "$current_dir/$package_name-$build_version/include/pEp"
Edouard@333
    51
cd "$current_dir/../src"
Edouard@333
    52
cp *.h "$current_dir/$package_name-$build_version/include/pEp"
Edouard@333
    53
Hussein@660
    54
# Generate asn.1
Hussein@660
    55
cd "$current_dir/../asn.1"
Hussein@660
    56
make generate
Hussein@660
    57
Edouard@1268
    58
# Generate asn.1
Edouard@1268
    59
cd "$current_dir/../sync"
Edouard@1268
    60
make
Edouard@1268
    61
Edouard@333
    62
# Start building.
Edouard@333
    63
for arch in $archs ; do
Edouard@333
    64
  TARGET_ARCH_ABI=$arch
Edouard@333
    65
  build
Edouard@333
    66
done
Edouard@333
    67
Edouard@333
    68
rm -rf "$current_dir/third-party"
Edouard@333
    69
cd "$current_dir"
Edouard@333
    70
zip -qry "$package_name-$build_version.zip" "$package_name-$build_version"
Edouard@333
    71
rm -rf "$package_name-$build_version"