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
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.
Note: Before building, you may want to set up a
.userconfig file to customize the build. See Customization with the .userconfig file for details.
To build Boot to Gecko, simply use the
cd B2G ./build.sh
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:
In order to refresh only one application, you can build only
gaia module by using
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:
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:
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:
To create a multilocale build, do the following:
- Determine which Gaia languages file to use. We're currently using
shared/resources/languages-all.jsonas our Gaia languages files.
- Clone the appropriate locales from http://hg.mozilla.org/gaia-l10n into a directory; we use
gaia-l10n/. You'll need to clone a repo for each locale listed in the languages file.
- In your environment, set
LOCALE_BASEDIRto the absolute path of the directory in step 2. Set
LOCALES_FILEto the absolute path of the file in step 1.
export LOCALE_BASEDIR=$PWD/gaia-l10n export LOCALES_FILE=$PWD/gecko/gaia/shared/resources/languages-dev.json
- 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
- For mozilla-central, use http://hg.mozilla.org/l10n-central/
- For mozilla-aurora, use http://hg.mozilla.org/releases/l10n/mozilla-aurora/
- For mozilla-beta or mozilla-b2g18, use http://hg.mozilla.org/releases/l10n/mozilla-beta/
- Clone compare-locales.
In your environment, set
L10NBASEDIRto the absolute path of the directory in step 2. Set
MOZ_CHROME_MULTILOCALEto a string of space-delimited locales from step 1.
Add theFor instance,
compare-locales/scriptsdir to your
export L10NBASEDIR=$PWD/gecko-l10n export MOZ_CHROME_MULTILOCALE="ja zh-TW" export PATH="$PATH:$PWD/compare-locales/scripts" export PYTHONPATH="$PWD/compare-locales/lib"
Once you have the above set up, you can run build.sh .
It looks like you can use .userconfig as well.
These instructions may change as we smooth things out.
KeyedVector.h:193:31: error: indexOfKey was not declared in this scope
This error appears when your gcc version is too recent. Install gcc/g++/g++-multilib 4.6.x versions.
See set up your build system for more information.
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 are lacking of free memory. Ensure having enough free memory before running
./build.sh. It should run fine if you system has 4GB of ram.
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:
Generating permissions.sqlite... test -d profile || mkdir -p profile run-js-command permissions WARNING: permission unknown:offline-app WARNING: permission unknown:indexedDB-unlimited build/permissions.js:122: NS_ERROR_UNEXPECTED: Component returned failure code: 0x8000ffff (NS_ERROR_UNEXPECTED) [nsIPermissionManager.add] make: *** [permissions] Error 3 make: *** [gaia/profile.tar.gz] Error 2
In this situation, try deleting the
gaia/xulrunner-sdkdirectory 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.
After building, your next step depends on whether you built Boot to Gecko for the emulator or for a real mobile device; see the following articles for details: