mozilla

Revision 507153 of Hacking Gaia

  • Slug della versione: Mozilla/Firefox_OS/Platform/Gaia/Hacking
  • Titolo della versione: Hacking Gaia
  • ID versione: 507153
  • Data di creazione
  • Autore: EdoPut
  • Versione corrente? No
  • Commento

Contenuto della versione

Questa pagina è diretta agli sviluppatori Gaia. Se stai cercando informazioni su come compilare e installare Firefox OS dovresti leggere Compilare e installare Firefox OS.

Gaia è un insieme di web apps che creano l'interfaccia di Firefox OS. Ciò che vedi sullo schermo in Firefox OS è scritto usando le open Web technologies. Anche la Home e le App di default usano le stesse tecnologie.

Prendere i sorgenti

Per prendere i sorgenti per Gaia, fai una fork su GitHub  e usala per scaricare i file tramite git.

$ git clone https://github.com/mozilla-b2g/gaia.git

Eseguire Gaia

Puoi usare Gaia sia su un desktop, dentro a Firefox, sia su un apparecchio compatibile.

B2G desktop

B2G desktop è uno strumento specifico per il desktop che esegue Gaia.

Puoi scaricare una nightly build di B2G desktop da qui. In base alla versione si cui desideri lavorare potresti volere una versione specifica di latest-mozilla-b2g18. Esistono versioni per Linux(32 bit and 64 bit), Mac OS X e Windows.

Le nightly builds sono pacchettizate con una versione di Gaia recente. Una volta scaricato l'archivio tutto ciò che dovrai fare è estrarlo in una cartella ed eseguire il file compilato di b2g nella cartella.

$ cd b2g
$ ./b2g

Se vuoi usare una versione personalizzata di Gaia usando B2G devi creare un profilo:

$ cd /path/to/gaia
$ DEBUG=1 DESKTOP=0 make

Questo comando genera una cartella chiamata profile nella directory gaia. L'opzione DEBUG esegue Gaia come una hosted app su di un web-server invece che come app pacchettizzate che devono essere ricompilate e ripacchettizate dopo ogni cambiamento. You can find the path to the profile directory by taking a look at last line of output after running the above command, which should look like:

Profile Ready: please run [b2g|firefox] -profile /path/to/gaia/profile

You can then run B2G Desktop with your generated profile like so:

$ ./b2g /path/to/gaia/profile

If you want to you can build your own B2G desktop from source.

Using Gaia in Firefox

It's also possible to run Gaia inside of Firefox. This gives you the advantages of having a rapid development cycle, as well as standard web development tools and debuggers. See Using Gaia in Firefox for details on how to do this.

Using Gaia on a device

If you have a compatible mobile device you can also run Gaia by flashing it with Firefox OS. See Building and installing Firefox OS for details on how to do this. We also have documentation for how to test Firefox OS.

Unit tests

See Gaia unit tests for documentation about how to create and run unit tests for Gaia.

Filing bugs

Bugs are filed on Bugzilla under Boot2Gecko > Gaia. File a new bug under the Gaia component (or one of the sub-components).

Contributing to Gaia

Mozilla depends on contributions from the open source community to help develop Gaia apps and we'd love you to get involved.

Some great places to find some bugs to start hacking on:

Coding style basics

  • Background:
  • Make sure HTML files are declared <!DOCTYPE html> (that is, as HTML5 documents). If you don't, Internet Explorer 9 and later will load them in compatibility mode.
  • Include the "use strict"; statement (just like that, including the quotes) to the top of your JavaScript files to put them into strict mode.
  • Always use two spaces for indentation, rather than tabs.
  • Please use line breaks to separate logical bits of code!
  • Multi-word file names should use the "underscore" character to separate words, like_this.js.
  • Use single quotes instead of double quotes for strings.

Additional rules

Bad:

if (expression) doSomething();

Correct:

if (expression) {
  doSomething();
}

If you're working on the system app, check out the guidance listed here.

Before submitting a patch we recommend you run gjslint on it to check for any style errors:

gjslint --nojsdoc my_file.js

Submitting a patch

First file or assign a bug to yourself on Bugzilla, you'll need a Bugzilla account.

Then create a branch on your fork of Gaia:

$ git branch branchname
$ git checkout branchname

Commit your changes:

$ git add /file/to/add
$ git commit -m "Bug XXXXX - Fix the broken Gaia and save the world"

Push your branch:

$ git push origin branchname

Send a pull request by navigating to the branch in your fork on GitHub and finding the pull request button.

To request a review of your patch, attach the pull request to the bug in Bugzilla by referencing the URL of the pull request, and set the review ("r") flag to "?" and enter the bugzilla ID of one of the module owners and peers (very important - otherwise your bug will not likely be seem by anyone). The Github tweaks for bugzilla extension on AMO can help automate this process by automatically creating the attachment and adding it to the bug; you will still need to set the review flag on Bugzilla.

The reviewer may ask you to make some changes; you may need to amend the original commit and force push it to the original branch/pull request. Once they're is happy with your patch, they will merge it into the master branch for you. Before they do this they would prefer it if you could squash all your changes into a single commit, so your contribution can be tracked easily.

The person who merge the commit (usually the reviewer) would add a r= flag in the comment of the merge commit.

Make options

There are many undocumented nor unsupported environment variable presists in the Makefile. Do not depend on them as they may be removed in the future.

Default

make

Make a profile with packaged apps, lunachable by B2G Desktop and can be pushed to device.

Debug make

DEBUG=1 make

The DEBUG part runs Gaia as hosted apps on a built-in web server, rather than the default packaged apps which have to be re-packaged after every change. Launch the profile with the latest Firefox Nightly will also give you nice B2G specific panels on the Firefox Developer Tools.

Push to device

make install-gaia

make reset-gaia

With adb (Android Debug Bridge) setup, these make targets will push Gaia to the device. reset-gaia will purge the profile and all other webapps before pushing the new Gaia copy.

Selective build

APP=system make

APP=system make install-gaia

With a profile already exists, APP allow you to specify which app to re-package, instead of re-pack and re-push all the Gaia apps.

High resolution image assets

GAIA_DEV_PIXELS_PER_PX=1.5 make

When packaging the app, replace images with their *@1.5x.(gif|jpg|png) ones if such image exists.

Gaia is currently targetting HBGA (320x240), qHD (540×960) and WVGA (480×800) only; use GAIA_DEV_PIXELS_PER_PX to make sure the images looks sharp on qHD and WVGA devices. see A pixel is not a pixel for more information about device pixels per css pixels.

Script compression and optimization

GAIA_OPTIMIZE=1 make

Concate and optimize build-in app's javascript to improve load time.

Preference shortcuts

NOFTU=1

Disable First time user guide.

REMOTE_DEBUGGER=1

Enable debug with adb tool

DEVICE_DEBUG=1

While in OS version > 1.2, specify this param when you want debug FirefoxOS webapp with App Manager

Distribution and market customization build

GAIA_DISTRIBUTION_DIR=./dir

Read Customization Overview for detail.

Contacting the Team

Sorgente della versione

<div class="warning">
 <p>Questa pagina è diretta agli sviluppatori Gaia. Se stai cercando informazioni su come compilare e installare Firefox OS dovresti leggere <a href="/en-US/docs/Mozilla/Firefox_OS/Building_and_installing_Firefox_OS" title="/en-US/docs/Mozilla/Firefox_OS/Building_and_installing_Firefox_OS">Compilare e installare Firefox OS.</a></p>
</div>
<p>Gaia è un insieme di <a href="https://developer.mozilla.org/apps" rel="nofollow">web apps</a> che creano l'interfaccia di <a href="https://developer.mozilla.org/en-US/docs/Mozilla/Firefox_OS">Firefox OS</a>. Ciò che vedi sullo schermo in Firefox OS è scritto usando le open Web technologies. Anche la Home e le App di default usano le stesse tecnologie.</p>
<h2 id="Prendere_i_sorgenti">Prendere i sorgenti</h2>
<p>Per prendere i sorgenti per Gaia, <a href="https://github.com/mozilla-b2g/gaia" title="https://github.com/mozilla-b2g/gaia">fai una fork su GitHub</a>&nbsp; e usala per scaricare i file tramite <a href="http://git-scm.com/" title="http://git-scm.com/">git</a>.</p>
<pre>
$ git clone https://github.com/mozilla-b2g/gaia.git</pre>
<h2 id="Eseguire_Gaia">Eseguire Gaia</h2>
<p>Puoi usare Gaia sia su un desktop, dentro a Firefox, sia su un apparecchio compatibile.</p>
<h3 id="B2G_desktop">B2G desktop</h3>
<p>B2G desktop è uno strumento specifico per il desktop che esegue Gaia.</p>
<p>Puoi scaricare una nightly build di B2G desktop da <a href="http://ftp.mozilla.org/pub/mozilla.org/b2g/nightly/" title="http://ftp.mozilla.org/pub/mozilla.org/b2g/nightly/">qui</a>. In base alla versione si cui desideri lavorare potresti volere una versione specifica di latest-mozilla-b2g18. Esistono versioni per Linux(32 bit and 64 bit), Mac OS X e Windows.</p>
<p>Le nightly builds sono pacchettizate con una versione di Gaia recente. Una volta scaricato l'archivio tutto ciò che dovrai fare è estrarlo in una cartella ed eseguire il file compilato di b2g nella cartella.</p>
<pre class="brush: bash">
$ cd b2g
$ ./b2g</pre>
<p>Se vuoi usare una versione personalizzata di Gaia usando B2G devi creare un profilo:</p>
<pre class="brush: bash">
$ cd /path/to/gaia
$ DEBUG=1 DESKTOP=0 make</pre>
<p>Questo comando genera una cartella chiamata <code>profile</code><code> </code>nella directory <code>gaia</code>. L'opzione <code>DEBUG</code> esegue Gaia come una hosted app su di un web-server invece che come app pacchettizzate che devono essere ricompilate e ripacchettizate dopo ogni cambiamento. You can find the path to the profile directory by taking a look at last line of output after running the above command, which should look like:</p>
<pre>
Profile Ready: please run [b2g|firefox] -profile /path/to/gaia/profile</pre>
<p>You can then run B2G Desktop with your generated profile like so:</p>
<pre>
$ ./b2g /path/to/gaia/profile</pre>
<p>If you want to you can build your own B2G desktop from source.</p>
<h3 id="Using_Gaia_in_Firefox">Using Gaia in Firefox</h3>
<p>It's also possible to run Gaia inside of Firefox. This gives you the advantages of having a rapid development cycle, as well as standard web development tools and debuggers. See <a href="/en-US/docs/Mozilla/Firefox_OS/Using_Gaia_in_Firefox" title="/en-US/docs/Mozilla/Firefox_OS/Using_Gaia_in_Firefox">Using Gaia in Firefox</a>&nbsp;for details on how to do this.</p>
<h3 id="Using_Gaia_on_a_device">Using Gaia on a device</h3>
<p>If you have a compatible mobile device you can also run Gaia by flashing it with Firefox OS. See <a href="/en-US/docs/Mozilla/Firefox_OS/Building_and_installing_Firefox_OS" title="Mozilla/Firefox_OS/Building_and_installing_Firefox_OS">Building and installing Firefox OS</a> for details on how to do this. We also have documentation for <a href="/en-US/docs/Mozilla/Firefox_OS/Platform/Testing" title="https://developer.mozilla.org/en-US/docs/Mozilla/Firefox_OS/Platform/Testing">how to test Firefox OS</a>.</p>
<h2 id="Unit_tests">Unit tests</h2>
<p>See <a href="/en-US/docs/Mozilla/Firefox_OS/Platform/Testing/Gaia_unit_tests" title="Mozilla/Firefox_OS/Platform/Testing/Gaia_unit_tests">Gaia unit tests</a> for documentation about how to create and run unit tests for Gaia.</p>
<h2 id="Filing_bugs">Filing bugs</h2>
<p>Bugs are filed on Bugzilla under <a href="https://bugzilla.mozilla.org/buglist.cgi?product=Boot2Gecko&amp;component=Gaia&amp;resolution=---" rel="nofollow">Boot2Gecko &gt; Gaia</a>. File a new bug <a href="https://bugzilla.mozilla.org/enter_bug.cgi?product=Boot2Gecko" title="https://bugzilla.mozilla.org/enter_bug.cgi?product=Boot2Gecko">under the Gaia component</a> (or one of the sub-components).</p>
<h2 id="Contributing_to_Gaia">Contributing to Gaia</h2>
<p>Mozilla depends on contributions from the open source community to help develop Gaia apps and we'd love you to get involved.</p>
<p>Some great places to find some bugs to start hacking on:</p>
<ul>
 <li><a href="https://bugzilla.mozilla.org/buglist.cgi?quicksearch=component:gaia%20sw:polish%20@nobody;list_id=4566236" rel="nofollow">Unowned Gaia polish bugs on Bugzilla</a></li>
 <li><a href="http://www.joshmatthews.net/bugsahoy/?b2g=1" rel="nofollow">Mentored bugs</a></li>
</ul>
<h3 id="Coding_style_basics">Coding style basics</h3>
<ul>
 <li>Background:
  <ul>
   <li><a href="/en-US/docs/Developer_Guide/Coding_Style#General_practices" title="Developer_Guide/Coding_Style#General_practices">Coding Style: General practices</a></li>
   <li><a href="/en-US/docs/Developer_Guide/Coding_Style#JavaScript_practices" title="Developer_Guide/Coding_Style#JavaScript_practices">Coding Style: JavaScript practices</a></li>
   <li><a href="/en-US/docs/Developer_Guide/Coding_Style#Naming_and_formatting_guide" title="Developer_Guide/Coding_Style#Naming_and_formatting_guide">Coding Style: Naming and formatting guide</a></li>
  </ul>
 </li>
 <li>Make sure HTML files are declared <code>&lt;!DOCTYPE html&gt;</code> (that is, as HTML5 documents). If you don't, Internet Explorer 9 and later will load them in compatibility mode.</li>
 <li>Include the <code>"use strict";</code> statement (just like that, including the quotes) to the top of your JavaScript files to put them into strict mode.</li>
 <li>Always use two spaces for indentation, rather than tabs.</li>
 <li>Please use line breaks to separate logical bits of code!</li>
 <li>Multi-word file names should use the "underscore" character to separate words, <code>like_this.js</code>.</li>
 <li>Use single quotes instead of double quotes for strings.</li>
</ul>
<h4 id="Additional_rules">Additional rules</h4>
<p>Bad:</p>
<pre>
if (expression) doSomething();
</pre>
<p>Correct:</p>
<pre>
if (expression) {
  doSomething();
}
</pre>
<p>If you're working on the system app, check out the guidance listed <a href="https://groups.google.com/d/msg/mozilla.dev.gaia/rEhSrw6XmT4/UNvE7qW9pgYJ" title="See_here_for_some_rules._https://groups.google.com/d/msg/mozilla.dev.gaia/rEhSrw6XmT4/UNvE7qW9pgYJ">here</a>.</p>
<p>Before submitting a patch we recommend you run <a href="http://closure-linter.googlecode.com/svn/trunk/closure_linter/gjslint.py" title="http://closure-linter.googlecode.com/svn/trunk/closure_linter/gjslint.py">gjslint</a> on it to check for any style errors:</p>
<pre>
gjslint --nojsdoc my_file.js</pre>
<h3 id="Submitting_a_patch">Submitting a patch</h3>
<p>First file or assign a bug to yourself on <a href="https://bugzilla.mozilla.org/buglist.cgi?product=Boot2Gecko&amp;component=Gaia&amp;resolution=---" title="https://bugzilla.mozilla.org/buglist.cgi?product=Boot2Gecko&amp;component=Gaia&amp;resolution=---">Bugzilla</a>, you'll need a Bugzilla account.</p>
<p>Then create a branch on your fork of Gaia:</p>
<pre>
$ git branch branchname
$ git checkout branchname</pre>
<p>Commit your changes:</p>
<pre>
$ git add /file/to/add
$ git commit -m "Bug XXXXX - Fix the broken Gaia and save the world"</pre>
<p>Push your branch:</p>
<pre>
$ git push origin branchname</pre>
<p>Send a pull request by navigating to the branch in your fork on GitHub and finding the pull request button.</p>
<p>To request a review of your patch, <a href="http://globau.wordpress.com/2013/10/21/github-pull-requests-and-bugzilla/">attach the pull request</a> to the bug in Bugzilla by referencing the URL of the pull request, and set the review ("r") flag to "?" and enter the bugzilla ID of one of the <a href="https://wiki.mozilla.org/Modules/FirefoxOS" title="https://wiki.mozilla.org/Modules/FirefoxOS">module owners and peers</a> (very important - otherwise your bug will not likely be seem by anyone). The <a href="https://addons.mozilla.org/en-US/firefox/addon/github-tweaks-for-bugzilla/" title="https://addons.mozilla.org/en-US/firefox/addon/github-tweaks-for-bugzilla/">Github tweaks for bugzilla extension on AMO</a> can help automate this process by automatically creating the attachment and adding it to the bug; you will still need to set the review flag on Bugzilla.</p>
<p>The reviewer may ask you to make some changes; you may need to amend the original commit and force push it to the original branch/pull request. Once they're is happy with your patch, they will merge it into the master branch for you. Before they do this they would prefer it if you could squash all your changes into a single commit, so your contribution can be tracked easily.</p>
<p>The person who merge the commit (usually the reviewer) would add a <code>r=</code> flag in the comment of the merge commit.</p>
<h2 id="Make_options">Make options</h2>
<p>There are many undocumented nor unsupported environment variable presists in the Makefile. Do not depend on them as they may be removed in the future.</p>
<h3 id="Default">Default</h3>
<pre>
make</pre>
<p>Make a profile with packaged apps, lunachable by B2G Desktop and can be pushed to device.</p>
<h3 id="Debug_make">Debug make</h3>
<pre>
DEBUG=1 make</pre>
<p>The <code>DEBUG</code> part runs Gaia as hosted apps on a built-in web server, rather than the default packaged apps which have to be re-packaged after every change. Launch the profile with the latest Firefox Nightly will also give you nice B2G specific panels on the Firefox Developer Tools.</p>
<h3 id="Push_to_device">Push to device</h3>
<pre>
make install-gaia

make reset-gaia</pre>
<p>With <code>adb</code> (Android Debug Bridge) setup, these make targets will push Gaia to the device. <code>reset-gaia</code> will purge the profile and all other webapps before pushing the new Gaia copy.</p>
<h3 id="Selective_build">Selective build</h3>
<pre>
APP=system make

APP=system make install-gaia</pre>
<p>With a profile already exists, <code>APP</code> allow you to specify which app to re-package, instead of re-pack and re-push all the Gaia apps.</p>
<h3 id="High_resolution_image_assets">High resolution image assets</h3>
<pre>
GAIA_DEV_PIXELS_PER_PX=1.5 make</pre>
<p>When packaging the app, replace images with their <code>*@1.5x.(gif|jpg|png)</code> ones if such image exists.</p>
<p>Gaia is currently targetting HBGA (320x240), qHD (540×960) and WVGA (480×800) only; use GAIA_DEV_PIXELS_PER_PX to make sure the images looks sharp on qHD and WVGA devices. see <a href="https://developer.mozilla.org/en-US/docs/Mozilla/Mobile/Viewport_meta_tag#A_pixel_is_not_a_pixel" title="https://developer.mozilla.org/en-US/docs/Mozilla/Mobile/Viewport_meta_tag#A_pixel_is_not_a_pixel">A pixel is not a pixel</a> for more information about device pixels per css pixels.</p>
<h3 id="Script_compression_and_optimization">Script compression and optimization</h3>
<pre>
GAIA_OPTIMIZE=1 make</pre>
<p>Concate and optimize build-in app's javascript to improve load time.</p>
<h3 id="Preference_shortcuts">Preference shortcuts</h3>
<pre>
NOFTU=1
</pre>
<p>Disable First time user guide.</p>
<pre>
REMOTE_DEBUGGER=1</pre>
<p>Enable debug with adb tool</p>
<pre>
DEVICE_DEBUG=1</pre>
<p>While in OS version &gt; 1.2, specify this param when you want debug FirefoxOS webapp with App Manager</p>
<h3 id="Distribution_and_market_customization_build">Distribution and market customization build</h3>
<pre>
GAIA_DISTRIBUTION_DIR=./dir</pre>
<p>Read <a href="https://wiki.mozilla.org/B2G/MarketCustomizations" title="https://wiki.mozilla.org/B2G/MarketCustomizations">Customization Overview</a> for detail.</p>
<h2 id="Contacting_the_Team">Contacting the Team</h2>
<ul>
 <li><a href="https://lists.mozilla.org/listinfo/dev-gaia" rel="nofollow">Gaia Mailing List</a></li>
 <li>#gaia IRC channel on irc.mozilla.org</li>
</ul>
Ripristina questa versione