Building Firefox OS on OS X
While Firefox OS 1.1 had been released by Mozilla, and 1.2 being stabilized, my ZTE Open was delivered with 1.0.1. No fun. With no newer images available from ZTE, I quickly begun looking into building my own. After all, how hard could it be?
Basically I first followed all the Mac related instructions on MDN (there's a link to the next step at the bottom). The ZTE Open is built using the inari (think Inara in Firefly, but with an i) device profile. Here's my recipe, yours might have to look different (see links for the actual instructions):
Run the Firefox OS Mac bootstrap, this will make sure you have a bunch of command line tools you'll need, or install the missing ones.
Download and install the OS X 10.6 SDK and symlink it into the current Xcode installation. The build process doesn't work with newer versions.
Create a disk image with a case sensitive filesystem to work from, unless your main filesystem is already case sensitive (by default it isn't).
Install the Android SDK, you'll need their tools to communicate with the phone (backing up, flashing etc). Make sure adb is on your path.
Configure ccache to allow a big cache (3 GB or so).
Enable remote debug on the phone.
Make a copy of the system partition from the phone, it is needed during the build process.
From now on, do all work on the case sensitive disk image.
Check out the B2G git repository.
Config the build environment using the config.sh script. Here you can both specify what branch to build, and what device to build for. This means checking out a lot of code, and it might take a while.
By now you should be able to build Firefox OS, but it didn't work for me. I found the reason on a different MDN page. It turns out with Xcode 5 installed, /usr/bin/gcc is actually gcc from Xcode, and that doesn't work for this build. Luckily this can be fixed.
Install gcc-4.6 using homebrew, and make sure you can run gcc-4.6 -v and g++-4.6 -v and get sensible output before you continue.
Edit the build/core/combo/HOST_darwin-x86.mk file as specified on the page above, to make sure it's using gcc-4.6 instead of the system gcc.
Again, by now you should be able to build Firefox OS, and this time it actually worked for me. Yay!
Another thing that caused my build to fail along the way was that I first checked out the code on a case insensitive disk, and then copied it into my case sensitive one once I realized that could be a problem. In hindsight, this was stupid. Really stupid. The cause of all these case-related problems is that the Linux kernel has files with the same name but different case in the same directory. Checking out the code to a case insensitive disk, only one of these files will survive. For example, my build failed because I didn't have any B2G/kernel/include/linux/netfilter/xt_CONNMARK.h, since it had been overwritten by xt_connmark.h. If you get strange errors like this, delete the code and config it from scratch on a case sensitive filesystem.
If your build fails and nothing seems to work, try removing the entire out directory and build again. This will ensure a fresh build.
You can specify how many parallel build process you want to use. If your build fails but you can't really tell why, build using ./build.sh -j1. This way, only one process will be used, and the output will be much more linear. The last output should be about the cause of the failure.
When the build actually works, it takes a long time. I suggest getting a cup of coffee or watching some TV. If the build fails, the computer will play a sound (unless you've turned off the bell sound in the Terminal settings).
Now what?
Once you have successfully built the OS, it's time to flash the phone. This has brought along a whole slew of new problems for me, but I hope they can be solved shortly. Stay tuned for more frustration fun!