Compiling Ember On Android

From WorldForgeWiki
Jump to: navigation, search

NOTE: Android support is under development. The Scratch board script is not wokring out of box, instead it gives some clues on how to get started with the Android build.

Scratch board

#!/bin/bash

set -e

#NOTE: I'm still using 32 bit Linux, so android SDK is 32 bit binaries

# Android SDK
wget http://dl.google.com/android/adt/22.6.2/adt-bundle-linux-x86-20140321.zip
tar -xjf adt-bundle-linux-x86-20140321.zip

#Android NDK
wget http://dl.google.com/android/ndk/android-ndk-r9d-linux-x86.tar.bz2
tar -xjf android-ndk-r9d-linux-x86.tar.bz2

export ANDROID_SDK=/home/sajty/dev/android/adt-bundle-linux-x86-20140321/sdk
export ANDROID_NDK=/home/sajty/dev/android/android-ndk-r9d
export PATH=$PATH:$ANDROID_SDK/platform-tools:$ANDROID_SDK/tools:$ANDROID_NDK

#build Ogre deps
hg clone https://bitbucket.org/cabalistic/ogredeps
cd ogredeps
mkdir build
cd build
#NOTE: default install prefix is inside the ndk, which is ok.
cmake -DCMAKE_TOOLCHAIN_FILE=../cmake/android.toolchain.cmake -DANDROID_ABI=armeabi ..
make
make install
cd ../..

#zzip has also a wrong name in ogre/CMake/Templates/Android.mk.in and it is not found by the linker (but cmake accepts it), so for now symlink solves it:
ln -s libzziplib.a libzzip.a


#Android is not officially supported by boost. I read riports that asio has limited features.
#There seems to be a problem with std::atomic on Android, and since Boost.Asio is using it (by default),
#combined with threads, one occasionally got deadlocked. Fortunately Boost.Asio makes it easy to switch
#from Std.Atomic to Boost.Atomic and this has been taken care of in the Boost-for-Android project in this commit.
#http://stackoverflow.com/questions/14036311/official-boost-library-support-for-android-and-ios
#https://github.com/MysticTreeGames/Boost-for-Android
git clone https://github.com/MysticTreeGames/Boost-for-Android
cd Boost-for-Android
./build-android.sh --toolchain=arm-linux-androideabi-4.8

#copy includes to /home/sajty/dev/android/android-ndk-r9d/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86/user/include
#copy boost libs to /home/sajty/dev/android/android-ndk-r9d/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86/user/lib

#Ogre is not supporting officially boost on android
#Ogre will not find boost without these symlinks
ln -s libboost_atomic-gcc-mt-1_53.a libboost_atomic.a
ln -s libboost_system-gcc-mt-1_53.a libboost_system.a
ln -s libboost_thread-gcc-mt-1_53.a libboost_thread.a
ln -s libboost_date_time-gcc-mt-1_53.a libboost_date_time.a
ln -s libboost_chrono-gcc-mt-1_53.a libboost_chrono.a

#add this line to ogre/CMake/Templates/Android.mk.in
LOCAL_LDLIBS += -lboost_date_time -lboost_system -lboost_thread -lboost_chrono -lboost_atomic

#latest 1.9.x version which has "android" keyword in the commit message
#(to make sure that the build was tested on android)
hg clone https://bitbucket.org/sinbad/ogre -r 77f3a5a
cd ogre
mkdir build
cd build
cmake -DCMAKE_TOOLCHAIN_FILE=../CMake/toolchain/android.toolchain.cmake -DANDROID_ABI=armeabi -DANDROID_NATIVE_API_LEVEL=9 \
-DOGRE_DEPENDENCIES_DIR="/home/sajty/dev/android/android-ndk-r9d/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86/user" ..
#NOTE: When building Ogre for android, it seems the compiler is using 800MB+ RAM/thread. Don't try -j4 on x86 linux!
make
make install

#it seems apk contains only static libs. Ogre is static linked.


#https://github.com/ironsteel/cegui
#https://github.com/ironsteel/cegui-android-test
#https://github.com/ironsteel/cegui-android-deps-prebuild
#https://github.com/ironsteel/ogre-android-demo
#git clone https://github.com/ironsteel/cegui.git -b compile-fixes
#We should use https://bitbucket.org/cegui/cegui-dependencies for dependencies.

#SDL2
#http://stackoverflow.com/questions/14904791/building-sdl2-with-ndk-toolchain