mozilla

Revision 457465 of Building Firefox OS

  • Revision slug: Mozilla/Firefox_OS/Building
  • Revision title: Building Firefox OS
  • Revision id: 457465
  • Created:
  • Creator: chrisdavidmills
  • Is current revision? No
  • Comment

Revision Content

{{ B2GMain() }}

Once you've set up your build system and performed your initial pull and configure of the code, you can build Boot to Gecko.

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.

Building

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 build.sh tool:

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:

./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

  1. Determine which Gaia languages file to use. We're currently using locales/languages_dev.json and locales/languages_all.json as our Gaia languages files.
  2. 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.
  3. 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.

For instance,

export LOCALE_BASEDIR=$PWD/gaia-l10n
export LOCALES_FILE=$PWD/gecko/gaia/shared/resources/languages-dev.json

Gecko

  1. Determine which Gecko languages file to use. We're currently using b2g/locales/all-locales as our Gecko languages file.
  2. Clone the appropriate locales into a directory; this can be gecko-l10n/ .
  3. Clone compare-locales.
  4. In your environment, set L10NBASEDIR to the absolute path of the directory in step 2. Set MOZ_CHROME_MULTILOCALE to a string of space-delimited locales from step 1.

    Add the compare-locales/scripts dir to your PATH, and compare-locales/lib to your PYTHONPATH.

    For instance,
    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.

Known errors

"Build failed!"

If you get a general "Build failed" message, you should always try reconnecting your phone to your computer; sometimes the phone can become unmounted for a variety of reasons.

Undefined symbols "_sqlite3_androidopt_handle_pragma" and "_sqlite3_androidopt_open"

This error appears if you are building on OS X 10.7 or newer with XCode 4.5 or newer. To fix this, apply the patch at https://groups.google.com/forum/#!msg/android-building/yAfPyUqCsiQ/7zvICk4GWjYJ to the external/sqlite/dist/Android.mk file.

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 Customizing with the .userconfig file 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 free memory is lacking. Ensure there is enough free memory before running ./build.sh. It should run fine if you system has 4GB of RAM.

while building the emulator: /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:

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[1]: *** [permissions] Error 3
make: *** [gaia/profile.tar.gz] Error 2

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.

Next steps

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:

Revision Source

<div>
  {{ B2GMain() }}</div>
<p>Once you've <a href="/en-US/docs/Mozilla/Firefox_OS/Firefox_OS_build_prerequisites" title="Mozilla/Firefox_OS/Firefox_OS_build_prerequisites">set up your build system</a> and performed your <a href="/en-US/docs/Mozilla/Firefox_OS/Preparing_for_your_first_B2G_build" title="Mozilla/Firefox_OS/Preparing_for_your_first_B2G_build">initial pull and configure</a> of the code, you can build Boot to Gecko.</p>
<h2 id="Updating_your_code">Updating your code</h2>
<p>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:</p>
<pre>
git pull
./repo sync
</pre>
<p>You can update a specific make target's repository by specifying its name:</p>
<pre>
./repo sync gaia
</pre>
<p>The repo command has other options available that might be interesting; <code>repo help</code> will give you a lot of information.</p>
<h2 id="Building">Building</h2>
<div class="note">
  <p><strong>Note:</strong> Before building, you may want to set up a <code>.userconfig</code> file to customize the build. See <a href="/en-US/docs/Mozilla/Firefox_OS/Customization_with_the_.userconfig_file" title="Mozilla/Firefox_OS/Customization_with_the_.userconfig_file">Customization with the .userconfig file</a> for details.</p>
</div>
<p>To build Boot to Gecko, simply use the <code>build.sh</code> tool:</p>
<pre>
cd B2G
./build.sh
</pre>
<p>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.</p>
<h3 id="Building_specific_modules">Building specific modules</h3>
<p>If you want to build just a particular module, such as Gecko, you can specify it by name:</p>
<pre>
./build.sh gecko
</pre>
<p>In order to refresh only one application, you can build only <code>gaia</code> module by using the <code>BUILD_APP_NAME</code> environment variable:</p>
<pre>
BUILD_APP_NAME=calendar ./build.sh gaia</pre>
<p>To get a list of the modules you can build, you can do:</p>
<pre>
./build.sh modules
</pre>
<h3 id="Setting_the_number_of_processor_cores_to_use">Setting the number of processor cores to use</h3>
<p>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 <code>-j</code> parameter when running <code>build.sh</code>. 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!</p>
<p>For example, to build using just two parallel tasks:</p>
<pre>
./build.sh -j2
</pre>
<p>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:</p>
<pre>
./build.sh -j1
</pre>
<h3 id="Building_multilocale">Building multilocale</h3>
<p>To create a multilocale build, do the following:</p>
<h4 id="Gaia">Gaia</h4>
<ol>
  <li>Determine which Gaia languages file to use. We're currently using <a href="http://hg.mozilla.org/integration/gaia-nightly/file/e2eed5263e77/shared/resources/languages-dev.json"><code>locales/languages_dev.json</code></a> and <a href="http://hg.mozilla.org/integration/gaia-nightly/file/e2eed5263e77/shared/resources/languages-all.json"><code>locales/languages_all.json</code></a> as our Gaia languages files.</li>
  <li>Clone the appropriate locales from <a href="http://hg.mozilla.org/gaia-l10n">http://hg.mozilla.org/gaia-l10n</a> into a directory; we use <code>gaia-l10n/</code> . You'll need to clone a repo for each locale listed in the languages file.</li>
  <li>In your environment, set <code>LOCALE_BASEDIR</code> to the absolute path of the directory in step 2. Set <code>LOCALES_FILE</code> to the absolute path of the file in step 1.</li>
</ol>
<p>For instance,</p>
<pre>
export LOCALE_BASEDIR=$PWD/gaia-l10n
export LOCALES_FILE=$PWD/gecko/gaia/shared/resources/languages-dev.json
</pre>
<h4 id="Gecko">Gecko</h4>
<ol>
  <li>Determine which Gecko languages file to use. We're currently using <a href="http://hg.mozilla.org/releases/mozilla-b2g18/file/default/b2g/locales/all-locales">b2g/locales/all-locales</a> as our Gecko languages file.</li>
  <li>Clone the appropriate locales into a directory; this can be <code>gecko-l10n/</code> .
    <ul>
      <li>For mozilla-central, use <a href="http://hg.mozilla.org/l10n-central/">http://hg.mozilla.org/l10n-central/</a></li>
      <li>For mozilla-aurora, use <a href="http://hg.mozilla.org/releases/l10n/mozilla-aurora/">http://hg.mozilla.org/releases/l10n/mozilla-aurora/</a></li>
      <li>For mozilla-beta or mozilla-b2g18, use <a href="http://hg.mozilla.org/releases/l10n/mozilla-beta/">http://hg.mozilla.org/releases/l10n/mozilla-beta/</a></li>
    </ul>
  </li>
  <li>Clone <a href="http://hg.mozilla.org/build/compare-locales">compare-locales</a>.</li>
  <li>
    <p>In your environment, set <code>L10NBASEDIR</code> to the absolute path of the directory in step 2. Set <code>MOZ_CHROME_MULTILOCALE</code> to a string of space-delimited locales from step 1.</p>
    <p>Add the <code>compare-locales/scripts</code> dir to your <code>PATH</code>, and <code>compare-locales/lib</code> to your <code>PYTHONPATH</code>.</p>
    For instance,
    <pre>
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"
</pre>
    <p>Once you have the above set up, you can run build.sh.</p>
    <p>It looks like you can <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=818560#c9/">use .userconfig</a> as well.</p>
    <p>These instructions may change as we smooth things out.</p>
  </li>
</ol>
<h2 id="Known_errors">Known errors</h2>
<h3>"Build failed!"</h3>
<p>If you get a general "Build failed" message, you should always try reconnecting your phone to your computer; sometimes the phone can become unmounted for a variety of reasons.</p>
<h3>Undefined symbols "_sqlite3_androidopt_handle_pragma" and "_sqlite3_androidopt_open"</h3>
<p>This error appears if you are building on OS X 10.7 or newer with XCode 4.5 or newer. To fix this, apply the patch at <a href="https://groups.google.com/forum/#!msg/android-building/yAfPyUqCsiQ/7zvICk4GWjYJ">https://groups.google.com/forum/#!msg/android-building/yAfPyUqCsiQ/7zvICk4GWjYJ</a> to the external/sqlite/dist/Android.mk file.</p>
<h3>KeyedVector.h:193:31: error: indexOfKey was not declared in this scope</h3>
<p>This error appears when your gcc version is too recent. Install gcc/g++/g++-multilib 4.6.x versions.</p>
<p>See <a href="/en-US/docs/Mozilla/Firefox_OS/Customization_with_the_.userconfig_file" title="Mozilla/Firefox_OS/Customization_with_the_.userconfig_file">Customizing with the .userconfig file</a> for more information.</p>
<div class="note">
  <p><strong>Community Note:</strong> 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.</p>
</div>
<h3 id="arm-linux-androideabi-g.2B.2B.3A_Internal_error.3A_Killed_(program_cc1plus)">arm-linux-androideabi-g++: Internal error: Killed (program cc1plus)</h3>
<p>If you see this message, it most likely means that free memory is lacking. Ensure there is enough free memory before running <code>./build.sh</code>. It should run fine if you system has 4GB of RAM.</p>
<h3 id="while_building_the_emulator.3A_.2Fusr.2Fbin.2Fld.3A_out.2Fhost.2Flinux-x86.2Fobj.2FEXECUTABLES.2FtriangleCM_intermediates.2FtriangleCM.3A_hidden_symbol_.60_XGetRequest'_in_out.2Fhost.2Flinux-x86.2Fobj.2FSTATIC_LIBRARIES.2FlibSDL_intermediates.2FlibSDL.a(SDL_x11dyn.o)_is_referenced_by_DSO">while building the emulator: /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</h3>
<p>You can get this with some versions in binutils. If you run Debian Stable, you can use the <em>gold</em> linker by installing the package <code>binutils-gold</code>. Note that the <em>gold</em> linker is already installed by <code>binutils</code>, but it's not used by default, <code>binutils-gold</code> does just that.</p>
<h3 id="If_you_get_build_errors_while_the_build_system_is_running_tests">If you get build errors while the build system is running tests</h3>
<p>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:</p>
<pre>
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[1]: *** [permissions] Error 3
make: *** [gaia/profile.tar.gz] Error 2</pre>
<p>In this situation, try deleting the <code>gaia/xulrunner-sdk</code> directory and re-pulling the code:</p>
<pre>
rm -r gaia/xulrunner-sdk
</pre>
<p>This deletes the downloaded, precompiled copy of <a href="/en-US/docs/XULRunner" title="/en-US/docs/XULRunner">XULRunner</a> that the build system retrieves automatically; on your next build, a new copy of XULRunner will be automatically retrieved.</p>
<h2 id="Next_steps">Next steps</h2>
<p>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:</p>
<ul>
  <li><a href="/en-US/docs/Mozilla/Firefox_OS/Using_the_B2G_emulators" title="Mozilla/Firefox_OS/Using_the_B2G_emulators">Using the B2G emulators</a></li>
  <li><a href="/en-US/docs/Mozilla/Firefox_OS/Using_the_B2G_desktop_client" title="Mozilla/Firefox_OS/Using_the_B2G_desktop_client">Using the B2G desktop client</a></li>
  <li><a href="/en-US/docs/Mozilla/Firefox_OS/Installing_on_a_mobile_device" title="Mozilla/Firefox_OS/Installing_on_a_mobile_device">Installing Boot to Gecko on a mobile device</a></li>
  <li><a href="/en-US/docs/Mozilla/Firefox_OS/Pandaboard" title="Mozilla/Firefox_OS/Pandaboard">Installing Boot to Gecko on a pandaboard</a></li>
</ul>
Revert to this revision