• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/bin/sh
2
3# The purpose of this script is the following:
4#
5# 1/ Build the libraries under prebuilts/jni/
6#
7# 2/ Build the project under jni/
8#
9# 3/ Check that the prebuilt shared library was copied to
10#    $NDK_OUT/<abi>/objs.
11#
12# 4/ Check that the prebuilt static library was not copied to
13#    the same directory.
14#
15
16PROGDIR=$(dirname "$0")
17
18OUT=$PROGDIR/obj/local
19PREBUILTS_DIR=$PROGDIR/prebuilts
20PREBUILTS_DIR=$(cd "$PREBUILTS_DIR" && pwd)
21
22ABIS=
23for OPT; do
24  case $OPT in
25    APP_ABI=*)
26      ABIS=${OPT##APP_ABI=}
27      ;;
28  esac
29done
30
31if [ -z "$ABIS" ]; then
32  ABIS="armeabi armeabi-v7a x86 mips"
33fi
34
35# Step 1: Build prebuilt libraries.
36$NDK/ndk-build -C "$PREBUILTS_DIR"
37if [ $? != 0 ]; then
38  echo "ERROR: Can't build prebuilt libraries!"
39  exit 1
40fi
41
42# Step 2: Build the project
43PREBUILTS_DIR=$PREBUILTS_DIR $NDK/ndk-build -C "$PROGDIR"
44if [ $? != 0 ]; then
45  echo "ERROR: Can't build project!"
46  exit 1
47fi
48
49# Step 3: Check that the prebuilt shared library was copied to the
50#         right location.
51#
52
53FAILURES=0
54for ABI in $ABIS; do
55  SHARED_LIB=$OUT/$ABI/libfoo.so
56  STATIC_LIB=$OUT/$ABI/libbar.a
57  printf "Checking for $ABI shared library: "
58  if [ ! -f "$SHARED_LIB" ]; then
59    printf "KO! missing file: $SHARED_LIB\n"
60    FAILURES=$(( $FAILURES + 1 ))
61  else
62    printf "ok\n"
63  fi
64
65  printf "Checking for $ABI static library: "
66  if [ -f "$STATIC_LIB" ]; then
67    printf "KO! file should not exist: $STATIC_LIB\n"
68    FAILURES=$(( $FAILURES + 1 ))
69  else
70    printf "ok\n"
71  fi
72done
73
74if [ "$FAILURES" = 0 ]; then
75  echo "Everything's ok. Congratulations!"
76  exit 0
77else
78  echo "Found $FAILURES failures! Please fix ndk-build!"
79  exit 1
80fi
81