参考文章:Building and installing Firefox OS
这篇文件简单说下,自己实践获取B2G的源码并编译。
硬件要求:
1. An installed 64 bit GNU/Linux distribution (we recommend Ubuntu 12.04). 2. At least 4 GB of RAM/swap space. 3. At least 20 GB of available hard disk space.
我的硬件RAM 2GB,自己增加SWAP space到4.1GB,具体方法参考Ubuntu搭建android编译环境总结 这篇文章中第7个错误的位置。
软件要求:
You will also need the following tools installed: autoconf 2.13 bison bzip2 ccache curl flex gawk git gcc / g++ / g++-multilib make OpenGL headers patch X11 headers 32-bit ncurses 32-bit zlib
sudo apt-get install autoconf2.13 bison bzip2 ccache curl flex gawk gcc g++ g++-multilib git ia32-libs lib32ncurses5-dev lib32z1-dev libgl1-mesa-dev libx11-dev make zip这里面在安装的时候,可能会涉及到一些依赖的包,,按照提示安装即可。如果在64位的系统中编译,需要在执行以下命令$ 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获取source code:$ git clone https://github.com/mozilla-b2g/B2G.git这个完成后,挥发先B2G文件下,只有一些脚本文件,根本没有source code 。接下来要继续执行$ cd B2G$ ./config.sh emulator
目前Firefox OS 支持的设备和模拟器
$ ./config.sh Valid devices to configure are: – galaxy-s2 – galaxy-nexus – nexus-4 – nexus-s – nexus-s-4g – otoro – unagi – inari – keon – peak – leo – hamachi – helix – tara – pandaboard – emulator – emulator-jb – emulator-x86 – emulator-x86-jb
此时,已经在获取source code,下载过android source code的人都应该知道这是一个漫长的过程啊。
其实在你下载完成后,在ubuntu Terminal的最后一行会有run ./build.sh类似的提示。不过在编译之前呢,先获取下最新的code
$ git pull$ ./repo sync
当然,你也可以只更新某一模块的code,比如:
$ ./repo sync gaia$ ./repo sync gecko$ ./repo sync gonk-misc/
build code:
直接执行以下命令
$ ./build.sh -j2
这个-j2 是编译的线程数,这个最好和自己PC的cpu核数一致。当然也可以不需要 -j2这个参数的。build时间可能稍长点。
所有可以单独编译的modules 列表$ ./build.sh modules
启动emulator:
$./run-emulator.sh 模拟器启动后感觉和android的模拟器一样的,其实不然,稍等要进入firefox os home 会发现不同的。
以上这张图片就是启动模拟器后,firefox os的UI中的一部分了。
走过的路成为背后的风景,不能回头不能停留,若此刻停留,