Mobile/Fennec/Android OtherBuildEnvs

< Mobile‎ | Fennec
Revision as of 18:33, 17 October 2011 by Kats (talk | contribs) (→‎Mac OSX)

Ubuntu

Quick Script

 sudo apt-get update
 sudo apt-get install sun-java6-jdk mercurial ccache
 sudo apt-get build-dep firefox
 wget http://dl.google.com/android/ndk/android-ndk-r6-linux-x86.tar.bz2
 tar -xjf android-ndk-r6-linux-x86.tar.bz2
 wget http://dl.google.com/android/android-sdk_r12-linux_x86.tgz
 tar -xzf android-sdk_r12-linux_x86.tgz
 # go get lunch, this will take a while
 ./android-sdk-linux_x86/tools/android update sdk -u
 ./android-sdk-linux_x86/tools/android update adb

Explained

Install Java

First install the Sun Java jdk6, which the Android SDK depends on. If you're on Ubuntu, you'll need to the partners repo to get it.

 sudo apt-get update
 sudo apt-get install sun-java6-jdk

Install Gecko Requirements

Then install the usual stuff needed for a firefox build, you probably already have it

 sudo apt-get install mercurial ccache
 sudo apt-get build-dep firefox

Install Android NDK

Download and extract the NDK. NDK revs 4, 5 and 6 have been tested and confirmed to work.

 wget http://dl.google.com/android/ndk/android-ndk-r6-linux-x86.tar.bz2
 tar -xjf android-ndk-r6-linux-x86.tar.bz2

Install Android SDK

You should just install the latest sdk, we set the API level in our manifest files. The sdk download will take a while, make sure you have a decent internet connection and go get coffee, or maybe lunch.

 wget http://dl.google.com/android/android-sdk_r12-linux_x86.tgz
 tar -xzf android-sdk_r12-linux_x86.tgz
 ./android-sdk-linux_x86/tools/android update sdk -u
 ./android-sdk-linux_x86/tools/android update adb

RedHat

Fedora 13

yum install \
 cvs zip gcc-c++ glib2-devel gtk2-devel fontconfig-devel libnotify-devel \
 libIDL-devel alsa-lib-devel libXt-devel freetype-devel pkgconfig \
 dbus-glib-devel curl-devel autoconf213 xorg-x11-proto-devel libX11-devel \
 libXau-devel libXext-devel wireless-tools-devel glibc-static yasm

Install java: http://wporta.wordpress.com/2010/07/06/installing-jdk-in-fedora-13/

Then install Android sdk and ndk :

 wget http://dl.google.com/android/android-sdk_r06-linux_86.tgz
 tar xzf android-sdk_r06-linux_86.tgz
 wget http://ftp.mozilla.org/pub/mozilla.org/mobile/source/android-ndk-r4c-0moz3.tar.bz2
 tar xjf android-ndk-r4c-0moz3.tar.bz2
 ./android-sdk-linux_86/tools/android update sdk

Fedora 14 x64

If you're running Fedora 14 x64, in addition to the Fedora 13 requirements above, you may also need to install some or all of zlib-devel.i686 glibc.i686 glibc-devel.i686 libstdc++.i686

Windows

Mac OSX

Set up a regular Firefox build environment as explained here. Install the Android SDK and NDK for Mac OS X. Use a mozconfig like this one:

. $topsrcdir/browser/config/mozconfig
mk_add_options MOZ_OBJDIR=@TOPSRCDIR@/obj-android
mk_add_options MOZ_MAKE_FLAGS="-s -j16"
ac_add_options --enable-debug
ac_add_options --disable-optimize
ac_add_options --enable-ccache
ac_add_options --disable-crashreporter
ac_add_options --disable-install-strip
# Android SDK/NDK
ac_add_options --with-android-ndk="/PATH/TO/android-ndk-r6"
ac_add_options --with-android-sdk="/PATH/TO/android-sdk-mac_x86/platforms/android-13"
ac_add_options --with-android-version=5
ac_add_options --with-android-tools="/PATH/TO/android-sdk-mac_x86/tools"
ac_add_options --with-android-toolchain="/PATH/TO/android-ndk-r6/toolchains/arm-linux-androideabi-4.4.3/prebuilt/darwin-x86"
ac_add_options --with-android-platform="/PATH/TO/android-ndk-r6/platforms/android-5/arch-arm"
# Android options
ac_add_options --enable-application=mobile
ac_add_options --target=arm-linux-androideabi
ac_add_options --with-endian=little


Pending bug 694499 getting fixed, there is a workaround you can use to get a cross-compile from Mac OS X working on an Android device. Apply this patch:

diff -r d9e824e28209 js/src/jscpucfg.cpp
--- a/js/src/jscpucfg.cpp	Thu Oct 13 21:13:01 2011 -0700
+++ b/js/src/jscpucfg.cpp	Fri Oct 14 11:27:16 2011 -0400
@@ -64,13 +64,13 @@
      * processors, and determines which processor to configure for based
      * on compiler predefined macros.  We do the same thing here.
      */
-    printf("#ifdef __LITTLE_ENDIAN__\n");
+    //printf("#ifdef __LITTLE_ENDIAN__\n");
     printf("#define IS_LITTLE_ENDIAN 1\n");
     printf("#undef  IS_BIG_ENDIAN\n");
-    printf("#else\n");
-    printf("#undef  IS_LITTLE_ENDIAN\n");
-    printf("#define IS_BIG_ENDIAN 1\n");
-    printf("#endif\n\n");
+    //printf("#else\n");
+    //printf("#undef  IS_LITTLE_ENDIAN\n");
+    //printf("#define IS_BIG_ENDIAN 1\n");
+    //printf("#endif\n\n");
 #elif defined(IS_LITTLE_ENDIAN) || defined(FORCE_LITTLE_ENDIAN)
     printf("#define IS_LITTLE_ENDIAN 1\n");
     printf("#undef  IS_BIG_ENDIAN\n\n");

and rebuild using a mozconfig such as the one above. As leaving this change in your local hg clone might prevent some operations, you can use a hack with hard-links to only apply the patch when building. Keep two copies of the jscpucfg.cpp file in a directory somewhere, one with the patch applied and one original. Then, just before building, hard-link the modified file into the js/src folder, and after the build is complete, change the hard-link back the original file. This will retain the timestamps on the file and prevent the build scripts from rebuilding all of the js engine while also leaving hg blissfully unaware of the change.