Mobile/Fennec/Android: Difference between revisions

Update to NDK r8c by default
(Update to NDK r8c by default)
Line 8: Line 8:
Also, the [https://wiki.mozilla.org/Mobile/Fennec/Android_OtherBuildEnvs OtherBuildEnvs page] has some notes on a few other environment variations, so take a look at that as well if you have an environment or configuration that deviates from "normal".
Also, the [https://wiki.mozilla.org/Mobile/Fennec/Android_OtherBuildEnvs OtherBuildEnvs page] has some notes on a few other environment variations, so take a look at that as well if you have an environment or configuration that deviates from "normal".


First follow the platform-specific instructions below to set up a build environment on your machine. You can optionally also upgrade to the latest Android NDK (currently version r8c). Once you have done that, follow the steps to get the source code, set up your mozconfig, and build Fennec.
First follow the platform-specific instructions below to set up a build environment on your machine. Once you have done that, follow the steps to get the source code, set up your mozconfig, and build Fennec.


=== Linux ===
=== Linux ===
Line 23: Line 23:
  sudo apt-get install sun-java6-jdk mercurial ccache
  sudo apt-get install sun-java6-jdk mercurial ccache
  sudo apt-get build-dep firefox
  sudo apt-get build-dep firefox
  wget http://dl.google.com/android/ndk/android-ndk-r5c-linux-x86.tar.bz2
  wget http://dl.google.com/android/ndk/android-ndk-r8c-linux-x86.tar.bz2
  tar -xjf android-ndk-r5c-linux-x86.tar.bz2
  tar -xjf android-ndk-r8c-linux-x86.tar.bz2
  wget http://dl.google.com/android/android-sdk_r20.0.3-linux.tgz
  wget http://dl.google.com/android/android-sdk_r20.0.3-linux.tgz
  tar -xzf android-sdk_r20.0.3-linux.tgz
  tar -xzf android-sdk_r20.0.3-linux.tgz
Line 76: Line 76:
===== Install Android NDK =====
===== Install Android NDK =====


Download and extract the [http://developer.android.com/sdk/ndk/ Android NDK]. NDK revs 4-8 have been tested and are known to work. The automated builders currently use version r5c.
Download and extract the [http://developer.android.com/sdk/ndk/ Android NDK]. NDK revs 4-8 have been tested and are known to work. The automated builders currently use version r8c (and r7b for the android-x86 build).


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


===== Install Android SDK =====
===== Install Android SDK =====
Line 119: Line 119:
===== Install Android NDK =====
===== Install Android NDK =====


Download and extract the [http://developer.android.com/sdk/ndk/ Android NDK]. NDK revs 4-8 have been tested and are known to work. The automated builders currently use version r5c, but we are in the process of transitioning to using r8c (see {{bug|816993}}).
Download and extract the [http://developer.android.com/sdk/ndk/ Android NDK]. NDK revs 4-8 have been tested and are known to work. The automated builders currently use version r8c (and r7b for the android-x86 build).


  wget http://dl.google.com/android/ndk/android-ndk-r5c-darwin-x86.tar.bz2
  wget http://dl.google.com/android/ndk/android-ndk-r8c-darwin-x86.tar.bz2
  tar -xjf android-ndk-r5c-darwin-x86.tar.bz2
  tar -xjf android-ndk-r8c-darwin-x86.tar.bz2


===== Install Android SDK =====
===== Install Android SDK =====
Line 138: Line 138:


   export PATH=$PATH:$HOME/android-sdk-macosx/platform-tools:$HOME/android-sdk-macosx/tools
   export PATH=$PATH:$HOME/android-sdk-macosx/platform-tools:$HOME/android-sdk-macosx/tools
=== Optional: Using NDK r8c ===
On some systems, linking libxul can takes several minutes. Using <i>gold</i> instead of <i>ld</i> can reduce this time (from around 7 minutes to a bit more than 1 minute on my machine&#160;; YMMV, on another machine, it gets from 25 seconds to 10, or from 2 minutes to 1 minute with all system caches dropped).
To use gold, the best way is to just use the r8c Android NDK. You can also build gold yourself from binutils source and replace your existing ld binaries in the NDK folder to use gold. However it's simpler to just upgrade the NDK. There are currently no known issues with using the r8c NDK, except that you also need to remove the --enable-warnings-as-errors option in your mozconfig because the gcc-4.6 that comes with r8c is stricter with respect to warnings. There is some discussion in {{bug|769099}} about how r8c is awesome stuff and should be used by default on the buildbots, but that hasn't happened yet.
To upgrade your NDK, download the NDK for [http://dl.google.com/android/ndk/android-ndk-r8c-darwin-x86.tar.bz2 Mac OS X] or [http://dl.google.com/android/ndk/android-ndk-r8c-linux-x86.tar.bz2 Linux] and unpack it. Then, update your mozconfig to point to the new NDK by setting the <code>--with-android-ndk</code> and <code>--with-android-toolchain</code> options in your mozconfig.
For example, assuming that on a Mac OS X platform the NDK is unpacked into $HOME/android-ndk-r8c, you would need the following two lines in your mozconfig:
ac_add_options --with-android-ndk="$HOME/android-ndk-r8c"
ac_add_options --with-android-toolchain="$HOME/android-ndk-r8c/toolchains/arm-linux-androideabi-4.6/prebuilt/darwin-x86"


=== Getting the source ===
=== Getting the source ===
Line 171: Line 158:
  export MOZCONFIG=$PWD/my-fennec-mozconfig
  export MOZCONFIG=$PWD/my-fennec-mozconfig


Here is an example mozconfig file for building Fennec, assuming you have followed the instructions above and are using version r5c of the NDK.
Here is an example mozconfig file for building Fennec, assuming you have followed the instructions above and are using version r8c of the NDK.


<pre>
<pre>
  # Add the correct paths here:
  # Add the correct paths here:
  ac_add_options --with-android-ndk="$HOME/android-ndk-r5c"
  ac_add_options --with-android-ndk="$HOME/android-ndk-r8c"
ac_add_options --with-android-gnu-compiler-version=4.6
  ac_add_options --with-android-sdk="$HOME/android-sdk-linux/platforms/android-16"
  ac_add_options --with-android-sdk="$HOME/android-sdk-linux/platforms/android-16"
  ac_add_options --with-android-version=5
  ac_add_options --with-android-version=5
Confirmed users
586

edits