Before obtaining the code to build Firefox OS, you need a properly configured build system — this page shows you how. You can currently build on 64-bit Linux distributions .I built the B2G emulator on Ubuntu 14.04 (64-bit).Steps given here are same like in MDN, except few changes.
64 bit requirement installation
With Ubuntu 14.04, multi-arch packages are now the main way to support multiple architectures (e.g. 32-bit on a 64-bit install). You must tell your Ubuntu system that you want to support 32-bit packages as well:
sudo dpkg --add-architecture i386
sudo apt-get update
Once you’ve completed that, then you can install the necessary packages:
sudo apt-get install --no-install-recommends autoconf2.13 bison bzip2 ccache curl flex gawk gcc g++ g++-multilib gcc-4.6 g++-4.6 g++-4.6-multilib git lib32ncurses5-dev lib32z1-dev zlib1g:amd64 zlib1g-dev:amd64 zlib1g:i386 zlib1g-dev:i386 libgl1-mesa-dev libx11-dev make zip libxml2-utils
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.6 1
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.8 2
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.6 1
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.8 2
sudo update-alternatives --set gcc "/usr/bin/gcc-4.6"
sudo update-alternatives --set g++ "/usr/bin/g++-4.6"
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.
Way that you can solve this problem:
Solution : 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:
After having run this command, you will still have to manually create some symlinks for the emulator build to succeed:
sudo ln -s /usr/lib/i386-linux-gnu/libX11.so.6 /usr/lib/i386-linux-gnu/libX11.so
sudo ln -s /usr/lib/i386-linux-gnu/mesa/libGL.so.1 /usr/lib/i386-linux-gnu/libGL.so
Clone 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 (or git clone https://github.com/mozilla-b2g/B2G.git)
After cloning (which should only take a minute with a fast connection),
cd into the B2G directory:
Till so far it was exactly same as what’s given in MDN.Now here are some changes.May be some of you are behind college firewall, Codeaurora.org and some other repo won’t allow to get the codes (Details are here : https://bugzilla.mozilla.org/show_bug.cgi?id=979986). So my mentor Gabriele Gsvelto came up with a good solution.We did some modifications in Xml files of B2G repo.Only thing you have to do is to use this patch.That’s it.We are done. 🙂 Really i struggled a lot for this.So, i thought to share with you guys.May it help you in future.Thanks to my mentor who came up with such a great solution.
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 — run the following command from within the B2G directory:
Now run this command :
env BRANCH="bug-979986-https-only" GITREPO="https://github.com/gabrielesvelto/b2g-manifest" ./config.sh emulator
Time for coffee break 🙂 To build Boot to Gecko, simply use the
build.sh tool.This will collect all the necessary code for building b2g emulator from various repos.So you don’t need to get those from all repos one by one. Whole procedure gonna take long time.If your internet connection is good, still i may take 3-4 hours.It’s around 12 GB 🙂 Next step is to build the emulator.
To build Boot to Gecko, simply use the
Time for another coffee break, or possibly a nap (especially if this is your first build).
FInally we are done 🙂 cheers 🙂
Starting the emulator
To start the B2G emulator, type the following command:
This will handle all the emulator startup tasks for you. Now wait patiently while the emulator starts up and Boot to Gecko boots up on it. It can take a couple of minutes, so be patient.
Now you are thinking what is the use of doing all this, we can do same in simulator or in gaia (running in Nightly browser). Nope, there are some functionality that you cannot simulate on above stuff.So to simulate those functionality like Hardware Events Emulation, Telephony Emulation,SMS Emulation and much more you need b2g emulator.
Using the Emulator Console
Each running emulator instance provides a console that lets you query and control the emulated device environment. For example, you can use the console to manage port redirection, network characteristics, and telephony events while your application is running on the emulator. To access the console and enter commands, use telnet to connect to the console’s port number.
To connect to the console of any running emulator instance at any time, use this command:
telnet localhost <console-port>
An emulator instance occupies a pair of adjacent ports: a console port and an
adb port. The port numbers differ by 1, with the
adb port having the higher port number. The console of the first emulator instance running on a given machine uses console port 5554 and
adb port 5555. Subsequent instances use port numbers increasing by two — for example, 5556/5557, 5558/5559, and so on. Up to 16 concurrent emulator instances can run a console facility.
So open up a new terminal and type this command
telnet localhost 5554
It will show results something like this in your terminal
rishav@rishav:~$ telnet localhost 5554
Connected to localhost.
Escape character is '^]'.
Android Console: type 'help' for a list of commands
Bingo you did this! cheers 🙂 Now you can test stuffs by writing commands in same terminal.Some of the examples i have shown below :
The emulator console lets you generate an SMS message and direct it to an emulator instance. Once you connect to an emulator instance, you can generate an emulated incoming SMS using the following command:
sms send <senderPhoneNumber><textmessage>
For ex : sms send 12345 hello b2g
The emulator includes its own GSM emulated modem that lets you simulate telephony functions in the emulator. For example, you can simulate inbound phone calls, establish data connections and terminate them. The system handles simulated calls exactly as it would actual calls. The emulator does not support call audio.
You can use the
gsm command to access the emulator’s telephony functions after connecting to the console. The syntax for this command is as follows:
For ex : gsm call 12345
Stuck somewhere? Got any problem! Feel free to ask either on irc channel (#b2g, #gaia) or in dev-gaia/dev-b2g mailing list.
You can ping me too (comment here or mail me : firstname.lastname@example.org).Happy to help 🙂
Till then HAPPY HACKING ! 🙂 🙂