Please note, this is a STATIC archive of website developer.mozilla.org from 03 Nov 2016, cach3.com does not collect or store any user information, there is no "phishing" involved.

运行 Gaia 代码

本文对如何在本地运行 Gaia 代码以及在设置过程中的有效工具进行了深入讲解。

首先,我们应该指出,在操作Gaia 时,您并不需要编译 Gecko 或 B2G。您只需要将 Gaia 源代码下载到本地,以一定的方式运行和编辑它。


共有下面几种方式来运行 Gaia:

  • 使用带有更新的 Gaia 版本来烧写手机
  • 在 B2G 桌面版本中启动 Gaia 
  • 在 WebIDE 中运行 Gaia
  • 在 Firefox桌面版 中启动 Gaia 

你能在我们的 用多种方法运行Gaia 页面找到关于以多种方法运行Gaia的简略信息以及到更详细信息的链接。一般来说,这些信息是由从复杂问题(最常需要的信息)到简单问题(最少需要的信息)排序的。

在这篇文章里,我们会使用Firefox Mulet或WebIDE来运行Gaia -- 对于大部分你想对于Gaia代码库进行的更改,它们提供了最快捷的调试你的更新的方式。但显然,为了使用一些功能(如调试设备API或者与手机硬件进行交互等),你需要一个真正的设备。

注意: 如需得到更深入的帮助, 最好的地方就是 #gaia IRC 频道 (参见 Mozilla IRC 以获取更多信息) 以及 Gaia开发邮件单

运行 Gaia 

  1. 首先,fork我们在Github上的主项目存档库 Gaia.
  2. 然后,在本地clone它:
    git clone https://github.com/your-username/gaia.git
  3. 之后,再加入一个像这样的upstream:
    cd gaia
    git remote add upstream https://github.com/mozilla-b2g/gaia
  4. 最后, 在你的系统上安装 Fira Sans 字体:这是在真实设备上Gaia使用的字体, 所以在桌面上运行 Gaia 时也使用它是十分有用的,尤其是当你测试有关重叠或字体大小的功能时。
  5. 现在你需要为Gaia创建一个调试档案。 在你的Gaia存档库文件夹内运行DEBUG=1 make指令就会在profile-debug目录下创建一个档案(profile),这个档案是为了做到最优调试而创建的。它会创建未压缩(即主机调试版本)的Gaia应用,可以通过Firefox桌面版内置的扩展HTTPD服务器直接进行调试。当你对你的应用做了一个改变时,你只需要刷新你的浏览器窗口就可以看到结果,而不用再进行重新编译文件、重新推送到设备等等繁杂的过程。这对于快速的CSS/JS/HTMl修改尤其有用。

  6. With your debug profile built, run it in your desktop Firefox build (we'd recommend you use Firefox Nightly) from the command line, using a command with the following structure:
    /path/to/firefoxnightly -profile /path/to/B2G/gaia/profile-debug -no-remote
    For example, on Mac OS X, we ran the following command:
    /Applications/FirefoxNightly.app/Contents/MacOS/firefox -profile /Users/bob/git/gaia/profile-debug -no-remote

This should load up your Gaia profile running in a desktop Firefox tab, like so (you'll notice that the URL is https://system.gaiamobile.org:8080/):

A screenshot of Firefox OS Gaia being run inside a desktop Firefox nightly build.

Note: If you open a tab in the Firefox desktop window Gaia is running in, enter about:config, and search for "gaia", you'll find a number of extensions.gaia.* prefs — which the httpd.js extension is using. You'll also be able to find the network.dns.localDomains pref, which is the trick that makes https://system.gaiamobile.org:8080 connect on your localhost.

Note: The make command is run inside the Gaia directory to create a profile (including apps, setting, etc.) that can be loaded on a phone, run inside an emulator, etc. The make command has a number of options to create different kinds of build. Just running make creates a standard production profile inside gaia/make, with packaged apps, which is not set up for optimum modification and debugging.

有效的工具

You'll see that this view has a number of different tools available, including:

  • Responsive design view in the top left corner.
  • All the standard Firefox Toolbox debugging tools available to the right of the screen (by default; this can be moved to the bottom of the screen if you like, but on the right makes more sense when debugging the small screen display on the left.)
  • A special Firefox OS tools tab on the toolbox that provides some specific tools for debugging Firefox OS in this mode:
    • Notification: fire a test system notification.
    • Reload application: reload the current application.
    • Take screenshot: take a screenshot and save it in a screenshots directory in your default image location, for example [HOME-FOLDER]/Pictures/screenshots on a Mac.
    • Import workload: pushes large workloads to certain apps, for stress testing, for example sending 2000 contacts to the contacts app, or sending 2000 messages to the email app.
       

文档标签和贡献者

 此页面的贡献者: chrisdavidmills, wcfsdcard, ReyCG_sub
 最后编辑者: chrisdavidmills,