Permalink
Browse files

Automated boost library for Android and simplified build process

  • Loading branch information...
amsurana committed Jul 2, 2018
1 parent b8d5fde commit f7bbff5dc599e36398f700b9a112e514511d7c0a
@@ -2,7 +2,7 @@ While `base_build.sh` will handle most of the build process for android,
if given the `android` build flag, it does not install boost for Android
as required.
To install boost for android, checkout the Boost-for-Android repo:
Follow the steps to download and install Boost
* export ANDROID_ARCH environment variable to armeabi-v7a, x86, arm64, x86_64
* export `NDK_ROOT` pointing to your android-ndk root folder (should be version r16b)
@@ -194,12 +194,6 @@ project (gams) : build_files, using_madara, using_utm, using_ros, vrep_lib, ros_
}
}
project (gams_jar) : using_gams, using_madara,port/java/using_java {
requires += java
libout = $(GAMS_ROOT)/lib
sharedname= GAMS_JNI
}
project (gams_controller) : using_gams, using_madara, using_vrep {
exeout = $(GAMS_ROOT)/bin
@@ -76,15 +76,13 @@ fi
#Copy all required JNI files into respective project directory.
MADARA_LIB=$MADARA_ROOT/lib/libMADARA.so
MADARA_JAR_LIB=$MADARA_ROOT/lib/libMADARA_JNI.so
MADARA_JAR=$MADARA_ROOT/lib/madara.jar
GAMS_LIB=$GAMS_ROOT/lib/libGAMS.so
GAMS_JAR_LIB=$GAMS_ROOT/lib/libGAMS_JNI.so
GAMS_JAR=$GAMS_ROOT/lib/gams.jar
if [ ! -f $MADARA_LIB ] || [ ! -f $MADARA_JAR_LIB ] || [ ! -f $GAMS_LIB ] || [ ! -f $GAMS_JAR_LIB ] || [ ! -f $MADARA_JAR ] || [ ! -f $GAMS_JAR ]; then
if [ ! -f $MADARA_LIB ] || [ ! -f $GAMS_LIB ] || [ ! -f $MADARA_JAR ] || [ ! -f $GAMS_JAR ]; then
echo "Looks like not all required libraries are available. Please ensure BOOST, MADARA, GAMS libraries are available";
exit;
exit 1;
fi
@@ -93,13 +91,27 @@ mkdir -p $JNI_LIBS_DIR_ARCH
cp $MADARA_LIB $JNI_LIBS_DIR_ARCH
cp $GAMS_LIB $JNI_LIBS_DIR_ARCH
cp $MADARA_JAR_LIB $JNI_LIBS_DIR_ARCH
cp $GAMS_JAR_LIB $JNI_LIBS_DIR_ARCH
cp $MADARA_JAR_LIB $JNI_LIBS_DIR_ARCH
cp $GAMS_JAR_LIB $JNI_LIBS_DIR_ARCH
cp -r $GAMS_ROOT/port/android/prebuilts/$ANDROID_ARCH/*.so $JNI_LIBS_DIR_ARCH
case $ANDROID_ARCH in
arm32|arm|armeabi|armeabi-v7a)
cp $NDK_TOOLS/arm-linux-androideabi/lib/libc++_shared.so $JNI_LIBS_DIR_ARCH
;;
arm64|aarch64)
cp $NDK_TOOLS/aarch64-linux-androidabi/lib/libc++_shared.so $JNI_LIBS_DIR_ARCH
;;
x86)
cp $NDK_TOOLS/i686-linux-android/lib/libc++_shared.so $JNI_LIBS_DIR_ARCH
;;
x64|x86_64)
cp $NDK_TOOLS/x86_64-linux-android/lib/libc++_shared.so $JNI_LIBS_DIR_ARCH
;;
*)
echo "Unknown arch. Copy libc++_shared.so manually to $JNI_LIBS_DIR_ARCH"
exit 1
;;
esac
#Copy Java files
mkdir -p $JAR_LIBS_DIR
cp $MADARA_JAR $JAR_LIBS_DIR
@@ -9,13 +9,10 @@
public class GamsNativeLibrary {
private KnowledgeBase knowledge = new KnowledgeBase();
static {
System.loadLibrary("MADARA_JNI");
static {
System.loadLibrary("c++_shared");
System.loadLibrary("MADARA");
System.loadLibrary("GAMS_JNI");
System.loadLibrary("GAMS");
}
private static GamsNativeLibrary instance;
@@ -332,14 +332,10 @@ if [ $ANDROID -eq 1 ]; then
if [ -z "$BOOST_ANDROID_ROOT" ]; then
echo "BOOST_ANDROID_ROOT is not set. See README-ANDROID.md for instructions"
exit 1
elif [ ! -d "$BOOST_ANDROID_ROOT/build/$ANDROID_ARCH" ]; then
echo -e "\e[91m $BOOST_ANDROID_ROOT/build/$ANDROID_ARCH path seems invalid. Please check README-ANDROID.md \e[39m"
exit 1;
export BOOST_ANDROID_ROOT=$INSTALL_DIR/BoostAndroid
echo "Boost root is set to $BOOST_ANDROID_ROOT is not set."
fi
fi
if [ $DOCS -eq 1 ]; then
@@ -417,11 +413,25 @@ if [ $PREREQS -eq 1 ] && [ $MAC -eq 0 ]; then
fi
(
cd $NDK_ROOT;
./build/tools/make-standalone-toolchain.sh --force \
--toolchain=$ANDROID_TOOLCHAIN --platform=android-$ANDROID_API \
--install-dir=$NDK_TOOLS --arch=$ANDROID_TOOLCHAIN_ARCH || exit $?
./build/tools/make_standalone_toolchain.py --force \
--api=$ANDROID_API \
--install-dir=$NDK_TOOLS --stl=libc++ --arch=$ANDROID_TOOLCHAIN_ARCH || exit $?
) || exit $?
if [ ! -d $BOOST_ANDROID_ROOT ] || [ ! -d "$BOOST_ANDROID_ROOT/build/$ANDROID_ARCH" ]; then
git clone "git@github.com:amsurana/Boost-for-Android.git" $BOOST_ANDROID_ROOT
cd $BOOST_ANDROID_ROOT;
echo "Boost is cloned in $BOOST_ANDROID_ROOT"
./build-android.sh --boost=1.65.1 --arch=$ANDROID_ARCH $NDK_ROOT
fi
if [ ! -d $BOOST_ANDROID_ROOT ] || [ ! -d "$BOOST_ANDROID_ROOT/build/$ANDROID_ARCH" ]; then
echo "Unable to download or setup boos. Refer README-ANDROID.md for manual setup"
exit 1;
fi
fi
if [ $ROS -eq 1 ]; then
sudo apt-get install -y ros-kinetic-desktop-full python-rosinstall ros-kinetic-ros-type-introspection ros-kinetic-move-base-msgs ros-kinetic-navigation libactionlib-dev libactionlib-msgs-dev libmove-base-msgs-dev
@@ -873,6 +883,7 @@ if [ $ANDROID -eq 1 ]; then
echo -e "export NDK_TOOLS=$NDK_TOOLS"
echo -e "export SYSROOT=$SYSROOT"
echo -e "export ANDROID_ARCH=$ANDROID_ARCH"
echo -e "export BOOST_ANDROID_ROOT=$BOOST_ANDROID_ROOT"
fi
if [ $MAC -eq 0 ]; then
@@ -894,3 +905,7 @@ echo -e ""
echo "BUILD_ERRORS=$BUILD_ERRORS"
exit $BUILD_ERRORS
@@ -5,7 +5,7 @@ feature (android) {
verbatim (make, local, true) {
SYSROOT = $(NDK_TOOLS)/sysroot
LDLIBS = -l:libboost_system.a -llog
LDLIBS = -l:libboost_system.a -llog -lc++_shared
ifeq ($(ANDROID_ARCH),arm)
CROSS_COMPILE=arm-linux-androideabi-
else ($(ANDROID_ARCH),armeabi-v7a)

0 comments on commit f7bbff5

Please sign in to comment.