Preparing for your first B2G build

  • Revision slug: Mozilla/Firefox_OS/Preparing_for_your_first_B2G_build
  • Revision title: Preparing for your first B2G build
  • Revision id: 345951
  • Created:
  • Creator: Sheppy
  • Is current revision? No
  • Comment Moved From Firefox_OS/Preparing_for_your_first_B2G_build to Mozilla/Firefox_OS/Preparing_for_your_first_B2G_build

Revision Content

{{ B2GMain() }}

Before you can build B2G, you need to clone the repository and configure your build. This article explains how to do that.

Cloning the B2G repository

The first step, before you can start your first build, is to clone the B2G repository. This will not fetch everything! Instead, it will fetch the B2G build system and setup utilities. Most of the actual B2G code is in the main Mozilla Mercurial repository.

To clone the repository, use git:

git clone git://github.com/mozilla-b2g/B2G.git

After cloning (which should take just a few moments), cd into the B2G directory:

cd B2G

Copying your B2G tree to a new machine

If you've gotten a new computer (lucky you!), you'll find your life will be much easier if you simply migrate your entire B2G tree from one computer to another.

To do that, mount your old computer's drive onto your new computer, then do this:

rsync -a source/ dest/

Where source is the full path (including the trailing slash) of the source tree, and dest is where you want to put it (the trailing slash is also important!).

Note: If you copy the files from a computer with another platform ensure to run './build.sh clean' before you start the build process. If you don't do this you might encounter compilation issues.

If you do this, you can skip all of the rest of this article and move right on to building.

Configuring B2G for your device

Important: Remember that only devices running Android 4 (aka Ice Cream Sandwich) are supported. Please check that your phone is actually running ICS, otherwise this step will most likely fail since some drivers are pulled from non-Nexus devices. Also, if you have to flash your device with ICS, keep in mind that some USB hubs don't work well with flashing tools, so you may have to connect your device to a built-in USB port..

Once you've retrieved the core B2G build system, you need to configure it for the device on which you plan to install it. To get a list of supported devices, you can use the config.sh utility, as follows:

./config.sh

This will display a list of the supported devices; for example:

Usage: ./config.sh (device name)

Valid devices to configure are:
- galaxy-s2
- galaxy-nexus
- nexus-s
- nexus-s-4g
- otoro
- unagi
- pandaboard
- emulator
- emulator-x86
 

If your device isn't listed, you should stop right now and either help port B2G to your device or wait until someone else does it. We'd prefer it if you help out!

Note: If for any reason you want to build against a specific version of Gecko, see {{ anch("Building against a custom Gecko") }} before you proceed.

Configuring for a mobile device

First, connect your device; the configure process will need to access it.

If your device is listed, you can start the configure process by running config.sh again, this time specifying your device's name. For example, to build for the Samsung Google Nexus S, you would type:

./config.sh nexus-s

Near the start of the configuration you might need to set the option for color usage, after this the process continues. This would be a good time for a coffee break, since at this point, you'll be doing your first pull of all the code needed to build Boot to Gecko.

If your phone no longer has Android on and your B2G tree doesn't have the binary blobs in it, and you wisely made a backup of the /system partition like an earlier page told you to, you can use it like this:

ANDROIDFS_DIR=<absolute path to parent dir of system dir> ./config.sh <target>

Configuring to build an emulator

If you want to build one of the emulators, you can specify "emulator" to get the ARM device emulator, or "emulator-x86" to build the x86 emulator. The latter is faster but not as accurate a representation of an actual mobile device.

So, for example, to build the ARM emulator, you would configure like this:

./config.sh emulator

Near the start of the configuration you might need to set the option for color usage, after this the process continues. This would be a good time for a coffee break, since at this point, you'll be doing your first pull of all the code needed to build Boot to Gecko.

Note: ./config.sh may take more time / network resources than you were prepared for. You may stop it with Ctrl-C and restart it at a later time. If you think some part of the process may have been terminated without completing, run './repo sync' to repair any possible problems.

Building against a custom Gecko

There may be times that you want or need to build Boot to Gecko based on a different version of Gecko than the one that's used by default (as specified in the manifest). You can do so by editing the file .userconfig before you pull the repository (before the config.sh step above). For example, if you want to build against mozilla-central:

GECKO_PATH=/path/to/mozilla-central
GECKO_OBJDIR=/path/to/mozilla-central/objdir-gonk

Note: if building against a custom Gecko in Mac OS X, the mozilla-central directory must be in a case sensitive file system.

See Customization with the .userconfig file for additional customizations you can do.

Next, start the build.

Revision Source

<p>{{ B2GMain() }}</p>
<p>Before you can build B2G, you need to clone the repository and configure your build. This article explains how to do that.</p>
<h2 id="Cloning_the_B2G_repository">Cloning the B2G repository</h2>
<p>The first step, before you can start your first build, is to clone the B2G repository. This will not fetch everything! Instead, it will fetch the B2G build system and setup utilities. Most of the actual B2G code is in the main Mozilla <a href="/en/Mercurial" title="en/Mercurial">Mercurial</a> repository.</p>
<p>To clone the repository, use git:</p>
<pre>
git clone git://github.com/mozilla-b2g/B2G.git</pre>
<p>After cloning (which should take just a few moments), <code>cd</code> into the B2G directory:</p>
<pre>
cd B2G
</pre>
<h2 id="Copying_your_B2G_tree_to_a_new_machine">Copying your B2G tree to a new machine</h2>
<p>If you've gotten a new computer (lucky you!), you'll find your life will be much easier if you simply migrate your entire B2G tree from one computer to another.</p>
<p>To do that, mount your old computer's drive onto your new computer, then do this:</p>
<pre>
rsync -a <em>source</em>/ <em>dest</em>/
</pre>
<p>Where <code>source</code> is the full path (including the trailing slash) of the source tree, and <code>dest</code> is where you want to put it (the trailing slash is also important!).</p>
<div class="note">
  <p>Note: If you copy the files from a computer with another platform ensure to run '<em>./build.sh clean'</em> before you start the build process. If you don't do this you might encounter compilation issues.</p>
</div>
<p>If you do this, you can skip all of the rest of this article and move right on to <a href="/en/Mozilla/Boot_to_Gecko/Building_Boot_to_Gecko" title="en/Mozilla/Boot_to_Gecko/Building_Boot_to_Gecko">building</a>.</p>
<h2 id="Configuring_B2G_for_your_device">Configuring B2G for your device</h2>
<div class="warning">
  <strong>Important</strong>: Remember that only devices running <strong>Android 4</strong> (aka <strong>Ice Cream Sandwich</strong>) are supported. Please check that your phone is actually running ICS, otherwise this step will most likely fail since some drivers are pulled from non-Nexus devices. Also, if you have to flash your device with ICS, keep in mind that some USB hubs don't work well with flashing tools, so you may have to connect your device to a built-in USB port..</div>
<p>Once you've retrieved the core B2G build system, you need to configure it for the device on which you plan to install it. To get a list of supported devices, you can use the <code>config.sh</code> utility, as follows:</p>
<pre>
./config.sh
</pre>
<p>This will display a list of the supported devices; for example:</p>
<pre>
Usage: ./config.sh (device name)

Valid devices to configure are:
- galaxy-s2
- galaxy-nexus
- nexus-s
- nexus-s-4g
- otoro
- unagi
- pandaboard
- emulator
- emulator-x86</pre>
<div>
  &nbsp;</div>
<p>If your device isn't listed, you should stop right now and either help port B2G to your device or wait until someone else does it. We'd prefer it if you help out!</p>
<div class="note">
  <strong>Note:</strong> If for any reason you want to build against a specific version of Gecko, see {{ anch("Building against a custom Gecko") }} before you proceed.</div>
<h3 id="Configuring_for_a_mobile_device">Configuring for a mobile device</h3>
<p>First, connect your device; the configure process will need to access it.</p>
<p>If your device is listed, you can start the configure process by running <code>config.sh</code> again, this time specifying your device's name. For example, to build for the Samsung Google Nexus S, you would type:</p>
<pre>
./config.sh nexus-s
</pre>
<p>Near the start of the configuration you might need to set the option for color usage, after this the process continues. This would be a good time for a coffee break, since at this point, you'll be doing your first pull of all the code needed to build Boot to Gecko.</p>
<p>If your phone no longer has Android on and your B2G tree doesn't have the binary blobs in it, and you wisely made a backup of the <code>/system</code> partition like an earlier page told you to, you can use it like this:</p>
<pre>
ANDROIDFS_DIR=&lt;absolute path to parent dir of system dir&gt; ./config.sh &lt;target&gt;
</pre>
<h3 id="Configuring_to_build_an_emulator">Configuring to build an emulator</h3>
<p>If you want to build one of the emulators, you can specify "emulator" to get the ARM device emulator, or "emulator-x86" to build the x86 emulator. The latter is faster but not as accurate a representation of an actual mobile device.</p>
<p>So, for example, to build the ARM emulator, you would configure like this:</p>
<pre>
./config.sh emulator
</pre>
<p>Near the start of the configuration you might need to set the option for color usage, after this the process continues. This would be a good time for a coffee break, since at this point, you'll be doing your first pull of all the code needed to build Boot to Gecko.</p>
<div class="note">
  <p>Note: ./config.sh may take more time / network resources than you were prepared for. You may stop it with Ctrl-C and restart it at a later time. If you think some part of the process may have been terminated without completing, run './repo sync' to repair any possible problems.</p>
</div>
<h2 id="Building_against_a_custom_Gecko">Building against a custom Gecko</h2>
<p>There may be times that you want or need to build Boot to Gecko based on a different version of Gecko than the one that's used by default (as specified in the manifest). You can do so by editing the file <code>.userconfig</code> before you pull the repository (before the <code>config.sh</code> step above). For example, if you want to build against mozilla-central:</p>
<pre>
GECKO_PATH=/path/to/mozilla-central
GECKO_OBJDIR=/path/to/mozilla-central/objdir-gonk
</pre>
<div class="note">
  <p><strong>Note</strong>: if building against a custom Gecko in Mac OS X, the mozilla-central directory must be in a case sensitive file system.</p>
</div>
<p>See <a href="/en-US/docs/Mozilla/Boot_to_Gecko/Customization_with_the_.userconfig_file" title="/en-US/docs/Mozilla/Boot_to_Gecko/Customization_with_the_.userconfig_file">Customization with the .userconfig file</a> for additional customizations you can do.</p>
<p>Next, <a href="/en/Mozilla/Boot_to_Gecko/Building_Boot_to_Gecko" title="en/Mozilla/Boot_to_Gecko/Building_Boot_to_Gecko">start the build</a>.</p>
Revert to this revision