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

构建系统入门

本文介绍了Gaia构建系统是如何工作的,包括 makefile, 构建过程,环境变量及潜在定制。 

在构建步骤中绝大多数有意义的工作都是由存放在Gaia子文件夹 build/ 下的脚本执行的,它们主要是使用make, node.js , XPCShell (也称作JS Shell)以及 XULRunner [zh-CN]执行的。Gaia构建系统中包含许多帮助工具,可以将webapp安装,测试,定位和打包到实际设备上。它同样允许开发者通过诸如更改默认壁纸,铃声,应用和设置的方式来对Gaia自定义。

Makefile文件

 Makefile文件中包含许多有用的命令,本节会对最有用的一些命令进行解释: 

install-gaia

该命令会将Gaia层所有的应用推送到设备端。如果想要推送特定的应用,可以使用APP 标志位:

APP=calendar make install-gaia

运行上面命令时所在的位置必须是Gaia  apps 下的文件夹(例如  apps).

reset-gaia

该命令会对设备中的应用进行清理并且在安装完成应用后会设置权限的默认值,除此之外与 install-gaia 命令作用是相同的. 在构建工程时,应用会存放在 /data/local类似的目录. 它同样也会将测试和调试的应用推送到手机中。

注意: 如果在使用 reset-gaia 时加入 APP 环境变量,会使您的手机不可用(此时可以通过再次执行不带 APP 变量的命令恢复). 因此请不要这样做.

production

该命令会将web应用安装在/system/b2g 下,而不是/data/local,除此之外与 reset-gaia 作用是相同的。这个命令能够使您对user版本进行仿真,这个命令同样会将一系列的应用安装在user版本上

 

参考工作负载

These goals push variously sized workloads to the device, helping us with debugging and fixing the performance and scalability issues we might have. These goals accept the APP environment variable, or an APPS environment variable that should contain the app names separated by a space, e.g.,

APP=sms make reference-workload-light
APPS="sms communications/contacts" make reference-workload-heavy
 
 

注意: For more information, read Hacking Gaia: Reference workloads.

环境变量

一些环境变量能够让你控制在设备上的构建与安装的一些方面:

B2G_SYSTEM_APPS=1

这个环境变量能够让你把应用推送到 /system/b2g 而不是 /data/local。 You should use that when you work with a user build. This variable is automatically set when running make production. This can be used for install-gaia or reset-gaia too.

GAIA_OPTIMIZE=1

This triggers an optimization pass on the JavaScript files. This is automatically set when running make production. This can be used for install-gaia or reset-gaia too.

PRODUCTION=1

This is basically an alias for make production (or is it the other way around ?).

DEBUG=1

This lets you generate a debug profile to use with the unit tests or to develop your Firefox OS app in Firefox. You must delete the existing profile directory before trying to generate a new one.

GAIA_DEV_PIXELS_PER_PX=1.5

This generates a profile suitable for running on WVGA devices.

Customizing the preferences

If you find that you have a set of custom preferences you need to set each time you flash your device, create a file called custom-prefs.js inside the build directory and store them in there. This keeps them from being overwritten and out of source control.

Here are some useful preferences:

// this enables marionette which lets you run performance tests
// see https://developer.mozilla.org/en-US/docs/Mozilla/Firefox_OS/Platform/Testing/Gaia_performance_tests
user_pref("marionette.defaultPrefs.enabled", true);

// this sets the port for remote debugging your application on the device
user_pref("devtools.debugger.remote-port", 60000);

// this enables the remote debugger
user_pref("devtools.debugger.remote-enabled", true);

// this outputs debug information about the Radio Interface Layer in logcat
user_pref("ril.debugging.enabled", true);

This file is read each time you generate a profile. The safest way to be sure that everything is generated is to delete your profile first:

rm -rf profile && make profile

Then you can safely use the install-gaia goal.

FAQ

1) The device remains black after a flash

This can sometimes happen if you flash the device while it is idle. To remedy this just restart B2G by issuing the following command from the command line:

adb shell stop b2g && adb shell start b2g

 

文档标签和贡献者

 此页面的贡献者: chrisdavidmills, xfq, ReyCG_sub, ReyCG, ziyunfei
 最后编辑者: chrisdavidmills,