Hi all!
In this post we are going to learn how to build B2G from the sources.
What is B2G in Firefox OS? Simple is the backend part, the one close to the linux that will provide the Gecko engine to run Gaia (the html5 + css + js frontend).
If we compile B2G, we can run int from our computer, that means we will have an emulator!
But wait … Mozilla is already creating nightly builds for us, that we can run in our computers, why I would need to compile by myself? Simple … cause then we can modify the source code!! Isn’t that awesome?
Ok, so get ready, we are going to compile B2G in a Mac, quite similar for Linux 🙂
- Prerequisites:
Let’s get some tools for compiling and fetching the code. Building B2G is like building any other mozilla product so you can check this instructions for mac here and for linux here.
$ brew install yasm mercurial libidl
$ brew install https://raw.github.com/Homebrew/homebrew-versions/master/autoconf213.rb
- Getting the code from Mozilla CentralWe will get the code using a Mercurial bundle, that is a compressed version of the repository, then we will update it with lates changes.
wget http://ftp.mozilla.org/pub/mozilla.org/firefox/bundles/mozilla-central.hg
hg init src
cd src
hg unbundle /path/to/your/mozilla-central.hg
Add the following content to the file src/.hg/hgrc
[paths]
default = http://hg.mozilla.org/mozilla-central/
hg pull
hg up
- Once you do that you will have an updated version of the Mozilla code in the src directory. Now let’s add the configuration options to compile B2G.
Create a file in the directory src called .mozconfigwith the following content:
mk_add_options MOZ_OBJDIR=../obj-b2g
mk_add_options MOZ_MAKE_FLAGS="-j4 -s"
ac_add_options --enable-application=b2g
ac_add_options --disable-libjpeg-turbo
ac_add_options --enable-tests
ac_add_options --enable-b2g-ril
- Now you are ready to compile, execute from the srcdirectory:
make -f client.mk
- Ok the compilation (after a while) finished, where are my binaries??? Remember the .mozconfig file? Remember the option MOZ_OBJDIR, we setup to ../obj-b2g, so our binaries will be:
cd ../obj-b2g/dist/bin/
In that directory we have an executable b2g, the same that runs in the mobile but you can run it from your computer!
Cool, so now you have your own emulator, build gaia (you can read it from previous posts) remember when building you will have a profile directory.
Running using your B2G emulator \o/:
./b2g -profile /path/to/your/gaia/profile -jsconsole
Yeah! Next steps … modifying the operating system!!