Update: This documentation is out-of-date: Please read developer.mozilla.org/en-US/Firefox_OS/Building for latest information
You can run Boot2Gecko(B2G) inside an emulator or inside a Firefox web browser. Using Boot2Gecko(B2G) with QEMU emulator is very resource intensive, so we will focus on the later in this post. I'll assume you are comfortable with Mozilla build environment. So, get that pot of coffee brewing and prepare for a long night of hacking.
Building Boot2Gecko(B2G) Firefox App
Before you start, let us make sure that you have all the prerequisites for building Firefox on your computer. Please have a look at the build prerequisites for your Linux, Window and OSX operating system.
# Let get the source code # Download mozilla-central repository $ hg clone http://hg.mozilla.org/mozilla-central mozilla-central # Download the Gaia source code $ git clone https://github.com/mozilla-b2g/gaia gaia # Change directory and create our profile $ cd gaia $ make profile # Change directory into your mozilla-central directory $ cd mozilla-central # Create a .mozconfig file inside your mozilla-central directory: $ nano .mozconfig mk_add_options MOZ_OBJDIR=../b2g-build mk_add_options MOZ_MAKE_FLAGS="-j9 -s" ac_add_options --enable-application=b2g ac_add_options --disable-libjpeg-turbo ac_add_options --enable-b2g-ril ac_add_options --with-ccache=/usr/bin/ccache # Build the Firefox B2G app and wait for the build to finish $ make -f client.mk build # Create a simple b2g bash script to launch B2G app; change paths you suit your environment # Note: Have to use to -safe-mode option due to bug on my Ubuntu box #!/bin/sh export B2G_HOMESCREEN=http://homescreen.gaiamobile.org/ /home/arky/src/b2g-build/dist/bin/b2g -profile /home/arky/src/gaia/profile
If everything goes well. You should have boot2gecko running inside a firefox now.
Customizing Firefox B2G App
For better Boot2Gecko (B2G) experience, we will customize Firefox features offline cache and touch events using a custom Firefox profile.
Create a Custom Firefox Profile
You can use dist/bin/b2g -ProfileManager option to launch Firefox Profile Manager. Create a new profile called 'b2g'. Now we can add customizations to this new profile.
On Linux computers, the profile is created under ~/.mozilla/b2g/ directory. You can find the information about location of firefox profiles for your operating system here.
You launch B2G with your new custom profile using the '-P' option. Modify your B2G bash script and add the custom profile option. dist/bin/b2g -P b2g
Disable offline cache
Create a user.js file inside your custom 'b2g' firefox profile directory. Add the following line to disable offline cache.
Enabling Touch events
Add the following line in your user.js file inside your custom 'b2g' Firefox profile directory to enable touch events.
That's it. You now have a Boot2Gecko(B2G) running inside Firefox on your computer. Happy Hacking!