-
Notifications
You must be signed in to change notification settings - Fork 0
Building for Android
These are preliminary cross-build instructions of Servo for Android. We can create share object binaries for Android with in-tree Rust compiler.
At first, We need some android development tools like NDK, SDK and toolchain for cross-compile. Android NDK can be downloaded from http://developer.android.com/tools/sdk/ndk/index.html . Android SDK can be downloaded from http://developer.android.com/sdk/index.html . Install NDK and SDK refer to guideline on the website.
First, create an Android toolchain from the NDK. Example command to setup standalone Android tool chain:
'ndk root'/build/tools/make-standalone-toolchain.sh --platform=android-18 --install-dir='dir to install' --ndk-dir='ndk dir'
Install the Debian packages below.
sudo apt-get install autoconf2.13 curl libtool ia32-libs
git clone https://github.com/mozilla/servo.git
cd servo
mkdir -p build && cd build
../configure --target-triples=arm-linux-androideabi --android-cross-path=<Android toolchain path> --android-ndk-path=<Android NDK path> --android-sdk-path=<Android SDK path>
make
make package
Installing:
cd build
adb install ServoAndroid-debug.apk
Running:
adb shell
export SERVO_URL=http://www.mozilla.com/
am start com.example.ServoAndroid/android.app.NativeActivity
Force-stop:
adb shell am force-stop com.example.ServoAndroid
Uninstall:
adb uninstall com.example.ServoAndroid
To set up the emulator, use the android
tool installed with the SDK. Create a default Nexus7 device with an SDCard of size greater than 100MB. After creating it, open the filw ~/.android/avd/nexus7.avd/config.ini and change the hw.dPad
and hw.mainKeys
configuration files to yes
.
Installing (note that we install using -s to install to the SDCard, as there is insufficient space in default device images on the main disk):
cd build
adb install -s ServoAndroid-debug.apk
Running:
adb shell
export SERVO_URL=http://www.mozilla.com/
am start com.example.ServoAndroid/android.app.NativeActivity
Force-stop:
adb shell am force-stop com.example.ServoAndroid
Uninstall:
adb uninstall com.example.ServoAndroid
If you have enabled the RUST_LOG
environment variable in main.cpp, we will redirect those messages generated by the Rust runtime to the Android logging facilities. To display those items, use:
adb logcat
First, you will need to enable debugging in the project files by adding android:debuggable="true"
to the application
tag in AndroidManifest.xml and changing the calls to ndk-build
in Makefile to pass NDK_DEBUG=1
.
cd src/platform/android/servo-android-glue/
~/android-ndk-r9c/ndk-gdb --adb=/Users/larsberg/android-sdk-macosx/platform-tools/adb --launch=android.app.NativeActivity --verbose
To get symbols resolved, you may need to provide additional library paths:
set solib-search-path /Users/larsberg/servo-arm/src/platform/android/servo-android-glue/obj/local/armeabi/:/Users/larsberg/servo-arm/src/platform/android/servo-android-glue/libs/armeabi
If you are using a PandaBoard, Servo is known to run on Android with the instructions above using the following build of Android for PandaBoard: http://releases.linaro.org/12.10/android/leb-panda
-
We uses freeglut of android version for window system. In this case, the application can be executed with android native application, not java app. The android freeglut has android_main internally and starts program from there so that we should link freeglut functions with rust-freeglut ffi functions to prevent program crash.
-
Different to Linux or Mac, on Android, Servo's program entry is in the library, not executable. So we could not execute program with command line arguments. We had hacked the program entry for android. You can set environment argument with 'SERVO_URL' before program beginning to specify URLs to load. example:
export SERVO_URL=http://github.com/mozilla/servo
- Default directories are listed below
android toolchain path : /opt/ndk_standalone
android NDK path : /opt/android-ndk
android SDK path : /opt/android-sdk
You may change these using command line arguments when configure. You can see more 'configure --help'
- Default settings
default font directory : /system/fonts (in android)
default resource path : /sdcard/servo (in android)
default font configuration : /sdcard/servo/.fcconfig (in android)
default fallback font : Roboto