Time for another coffee break, or possibly a nap (especially if this is your first build).

编译具体的模块

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

./build.sh gecko

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

./build.sh modules

设置所使用的处理器的核心数

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

若你的编译系统在运行测试的时候出了差错

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:

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:

To solve this, it is not necessary to remove the whole objdir-gecko or out directories. Just remove the backup directory, like this (for the example above):

$rm -rf backup-peak

Emulator build issues

If you are making an emulator build, you need to pay attention to these issues:

First, note that you shouldn't use the x86 emulator — it is hard to install and not well supported.

Next, the build-system for the emulator builds both 32bit and 64bit versions of the emulator. As the emulator depends on OpenGL, this means that you need to have both 32bit and 64bit versions of OpenGL libraries installed on your system. See the discussion in bug 897727.

There are two ways that you can solve this problem:

Solution #1: have both 32bit and 64bit OpenGL libs installed, with the right symlinks

If your linux distro has multilib packages for OpenGL libraries, you can attempt installing them. You might then have to manually create some symlinks.

For example, here is the situation on Ubuntu 12.04 LTS x86-64. On this distribution, the libgl1-mesa-dev package cannot be installed simultaneously in x86-64 and i386 versions, but you can have the following combination of packages simultaneously installed:

Solution #2: just patch the emulator so it only builds 64bit

Just apply this patch to the sdk/ git repository under the B2G repo. This will cause the B2G emulator to only attempt to build the 64bit emulator if you're on a 64bit system, thus avoiding any multilib issues. The 32bit emulator is unused anyway on a 64bit system. This is the simplest solution, until this patch eventually bit-rots.

下一步

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: