Updating your code

If this isn't your very first time building B2G, you might want to pull the latest code before you start to build. To do that, you should update both the B2G tools and the dependencies, using the following two commands:

git pull
./repo sync -d

You can update a specific make target's repository by specifying its name:

./repo sync gaia

The repo command has other options available that might be interesting; repo help will give you a lot of information.

Time for another coffee break, or possibly a nap (especially if this is your first build). As in the configure step on the previous page, if you are using a directory of previously-extracted Android system files, you should set ANDROIDFS_DIR before running build.sh.

Building specific modules

If you want to build just a particular module, such as Gecko, you can specify it by name:

./build.sh gecko

In order to refresh only one application, you can build only gaia module by using the BUILD_APP_NAME environment variable:

BUILD_APP_NAME=calendar ./build.sh gaia

To get a list of the modules you can build, you can do:

./build.sh modules

Setting the number of processor cores to use

By default, the B2G build scripts use the number of cores your system has plus two as the number of parallel tasks to run. You can change this by specifying the -j parameter when running build.sh. This can be handy if you're using your system for other things while building in the background and need to reduce CPU load a bit. It's also handy when you're having build problems, as it can make reading error output from the build process easier if you have just one task going at a time!

For example, to build using just two parallel tasks:

./build.sh -j2

The most common use case for this, however, is to prevent builds from running in parallel at all. This makes the output of the process much easier to read, making it easier to sort out build problems. To do this:

./build.sh -j1

Building multilocale

To create a multilocale build, do the following:

Gaia

Clone the appropriate locales from http://hg.mozilla.org/gaia-l10n into a directory; we use gaia-l10n/. You could use the locales/ directory . You'll need to clone a repo for each locale listed in the languages file.

In your environment, set LOCALE_BASEDIR to the absolute path of the directory in step 2. Set LOCALES_FILE to the absolute path of the file in step 1.

Also, you can set a GAIA_DEFAULT_LOCALE if you want to set a default locale.

For example, to add Spanish and Italian keyboard layout, run the previous command adding

GAIA_KEYBOARD_LAYOUTS=en,es,it

At this point you're ready to flash Gaia to the phone for the first time. Connect the phone and make sure Remote Debugging is checked in Settings > Device Information > More Information > Developer. You only need to do this once, for your own build of Gaia will have that pref turned on thanks to REMOTE_DEBUGGER=1:

make clean && make production LOCALES_FILE=locales/languages-own.json

Gecko

Determine which Gecko languages file to use. We're currently using b2g/locales/all-locales as our Gecko languages file.

Clone the appropriate locales into a directory; this can be gecko-l10n/ .

KeyedVector.h:193:31: error: indexOfKey was not declared in this scope

Community Note: It is possible to use gcc 4.7.x with slight modifications to the B2G code (gcc will guide you) but you won't get any help! Neither with modifying the code nor with bugs you encounter.

arm-linux-androideabi-g++: Internal error: Killed (program cc1plus)

If you see this message, it most likely means that free memory is lacking. Ensure there is enough free memory before running ./build.sh. It should run fine if your system has 4GB of RAM.

"...is referenced by DSO" error

While building the emulator, if you get /usr/bin/ld: out/host/linux-x86/obj/EXECUTABLES/triangleCM_intermediates/triangleCM: hidden symbol `_XGetRequest' in out/host/linux-x86/obj/STATIC_LIBRARIES/libSDL_intermediates/libSDL.a(SDL_x11dyn.o) is referenced by DSO.

You can get this with some versions in binutils. If you run Debian Stable, you can use the gold linker by installing the package binutils-gold. Note that the gold linker is already installed by binutils, but it's not used by default; binutils-gold does just that.

If you get build errors while the build system is running tests

Sometimes (especially after build tool or operating system updates) you'll get weird errors like this when the build system runs its post-build tests:

In this situation, try deleting the gaia/xulrunner-sdk directory and re-pulling the code:

rm -r gaia/xulrunner-sdk

This deletes the downloaded, precompiled copy of XULRunner that the build system retrieves automatically; on your next build, a new copy of XULRunner will be automatically retrieved.

Cannot fetch platform/libcore

If you tried to configure your B2G build for Nexus S (./config.sh nexus-s) and got an error related to libcore, it is because of a problem with the linaro git that feeds into this. To fix this, checkout the B2G manifest like so:

git clone https://github.com/mozilla-b2g/b2g-manifest.git

Edit the nexus-s.xml file in this repo, replacing the linaro git entry with a reference to the aosp entry, which should read like so:

Commit these changes (git commit -a) and then change the config.sh file in the master branch of the main B2G repo that you checked out to point to your modified local manifest instead of the Mozilla one:

GITREPO=${GITREPO:-"file:///home/path/to/my/b2g-manifest"}

clang errors when building with Xcode 5 on Mac

If you are building on Mac OS X 10.8 with Xcode 5, you will likely see errors like the following:

This is because Xcode 5 changes the g++ compiler in /usr/bin, which breaks the build process if you try to use it to compile. In order to work around the problem, edit the following line in build/core/combo/HOST_darwin-x86.mk:

Submitting bugs on B2G/Firefox OS/Gaia

Once you've got a B2G/Firefox OS build running, you'll probably want to start to file bugs against this specific version, so the Firefox OS community can improve things as effectively as possible. You'll want to file the bug on Bugzilla, under the "Firefox OS" project, but you should include version specifics:

To start with, tell us the major version number, e.g. 1.4.0.0-prerelease. This can be found on the device under Settings > Device Information.

You can provide more specific version identifiers by returning the current hashes from the gaia and gecko repositories. This can be done like so: