I recently attended jsconf in Scottsdale, AZ and we all got Boot2Gecko phones. Yippie! However, after the initial fun wore off of pushing some code to the phone, I wanted to get the desktop emulator running so I could actually develop something. Below is the method I had to use to get it up and running with OSX. It was pretty much a conglomeration of 3 different tutorials, however I hope this will at least be helpful for those folks getting started.
You will need the following installed to get started.
Getting the code
There are two different pieces needed to get the desktop emulator up and running. First there is Mozilla-central, which is a Mercurial repository of the Mozilla code. This will contain the b2g executable. The second component needed is gaia. This is the user interface for the b2g phone.
// Get the mercurial repo and save it to a folder called mozilla-central hg clone http://hg.mozilla.org/mozilla-central mozilla-central // Get gaia repo and save to a folder called gaia git clone https://github.com/andreasgal/gaia gaia
Building Mozilla Central
Create a mozconfig
You will need to create a mozconfig file before building. cd into the mozilla-central directory and create a file called “mozconfig”. Then add the following to it and save.
mk_add_options MOZ_OBJDIR=../build mk_add_options MOZ_MAKE_FLAGS="-j9 -s" ac_add_options --enable-application=b2g ac_add_options --disable-libjpeg-turbo # This option is required if you want to be able to run Gaia's tests ac_add_options --enable-tests # turn on mozTelephony/mozSms interfaces ac_add_options --enable-b2g-ril
While still in the mozilla-central directory build the source code. Get some coffee, this will be awhile.
make -f client.mk build
When complete you should see a build folder outside of your mozilla-central directory.
Note: There a quite a few prerequisites for building the mozilla source. They are listed here https://developer.mozilla.org/En/Developer_Guide/Build_Instructions/Linux_Prerequisites. The most common problems are complaining about missing autoconf and YASM. You should be able to get YASM by running “brew install yasm”. This is assuming you have brew installed. For autoconf you will need version 2.13. To get that running you can do the following
wget http://ftp.gnu.org/gnu/autoconf/autoconf-2.13.tar.gz tar -xvzf autoconf-2.13.tar.gz cd autoconf-2.13/ ./configure --program-suffix=2.13 make sudo make install
Now that we have mozilla-central working we need to build a profile for gaia. Navigate into the gaia directory that was created when doing a git clone from above. Now we can build with the following command.
A ton of stuff will happen but if everything works out you should have a “profile” folder in your gaia directory.
Running the emulator
Getting the emulator running on OSX was the trickest part. After much trial and error, below was the only sequence that would work for me. I had to fire the first command to open port 6200. Then, I had to run the b2g executable in safe mode while passing the profile generated in the gaia folder.
// Run this command first if you don't want the "Cannot open socket for RIL!" message nc -l localhost 6200 ../build/dist/B2G.app/Contents/MacOS/b2g -safe-mode -profile /path/to/gaia/profile
If you don’t need all the features of b2g you can also use Firefox Nightly to debug gaia. This method seems to be faster for quick debugging.
/Applications/FirefoxNightly.app/Contents/MacOS/firefox -profile /path/to/gaia/profile -no-remote http://homescreen.gaiamobile.org
Boot2Gecko is an interesting project from Mozilla. Although in the early stages, I for one am anxious to see how it progresses into a true open mobile platform. Happy Hacking!