1 Firefox Contributors' Quick Reference
2 =====================================
4 Some parts of this process, including cloning and compiling, can take a long time even on modern hardware.
5 If at any point you get stuck, please don't hesitate to ask at `https://chat.mozilla.org <https://chat.mozilla.org>`__
6 in the `#introduction <https://chat.mozilla.org/#/room/#introduction:mozilla.org>`__ channel.
8 Don’t hesitate to look at the :ref:`Getting Set Up To Work On The Firefox Codebase<Getting Set Up To Work On The Firefox Codebase>` for a more detailed tutorial.
12 Please register and create your account for
14 `Bugzilla <https://bugzilla.mozilla.org/>`__ : web-based general-purpose bug tracking system.
15 To register with Phabricator, make sure you enable Two-Factor Authentication (My Profile >> Edit Profile & Preferences >> Two-Factor Authentication) in Bugzilla.
17 `Phabricator <https://phabricator.services.mozilla.com/>`__: web-based software development collaboration tools, mainly for code review.
18 Please obtain an API Token (Settings >> Conduit API Tokens)
23 #. You need a :ref:`supported version of Windows<tier_1_hosts>`.
24 #. Download the `MozillaBuild Package. <https://ftp.mozilla.org/pub/mozilla/libraries/win32/MozillaBuildSetup-Latest.exe>`__ Installation directory should be:
30 #. Before moving on to the next steps, make sure to fulfill the :ref:`Windows prerequisites <Building Firefox On Windows>`
34 All the commands of this tutorial must be run in the shell provided with the MozillaBuild Package (start-shell.bat)
36 :ref:`More information on building Firefox on Windows <Building Firefox On Windows>`
38 Bootstrap a copy of the Firefox source code
39 -------------------------------------------
41 You can download the source code and have Firefox automatically download and install the other dependencies it needs. The below command as per your Operating System, will download a lot of data (years of Firefox history!) then guide you through the interactive setup process.
43 Downloading can take from 40 minutes to two hours (depending on your connection) and the repository should be less than 5GB (~ 20GB after the build).
45 The default options are recommended.
46 If you're not planning to write C++ or Rust code, select :ref:`Artifact Mode <Understanding Artifact Builds>`
47 and follow the instructions at the end of the bootstrap for creating a mozconfig file.
49 To Setup Firefox On Windows
50 ~~~~~~~~~~~~~~~~~~~~~~~~~~~
55 $ mkdir mozilla-source
57 $ wget https://hg.mozilla.org/mozilla-central/raw-file/default/python/mozboot/bin/bootstrap.py
58 $ python3 bootstrap.py
60 More information on :ref:`building Firefox for Windows <Building Firefox On Windows>`.
62 To Setup Firefox On macOS and Linux
63 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
67 $ curl https://hg.mozilla.org/mozilla-central/raw-file/default/python/mozboot/bin/bootstrap.py -O
68 $ python3 bootstrap.py
70 More information on :ref:`building Firefox for Linux <Building Firefox On Linux>` and :ref:`building Firefox for MacOS <Building Firefox On MacOS>`.
77 Visual Studio Code is the recommended editor for Firefox development.
78 Not because it is better than the other editors but because we decided to
79 focus our energy on a single editor.
81 Setting up your editor is an important part of the contributing process. Having
82 linting and other features integrated, saves you time and will help with reducing
83 build and reviews cycles.
85 See our :ref:`editor page for more information about how to set up your favorite editor <Editor / IDE integration>`.
90 Once the System is bootstrapped, run:
97 which will check for dependencies and start the build.
98 This will take a while; a few minutes to a few hours depending on your hardware.
102 If you build Firefox often, add `ac_add_options \-\-with-ccache=sccache` to .mozconfig.
103 sccache will significantly speed up your builds by caching compilation results.
104 The Firefox build system will download sccache automatically.
108 The default build is a compiled build with optimizations. Check out the
109 :ref:`mozconfig file documentation <Configuring Build Options>`
110 to see other build options. If you don't plan to change C++ or Rust code,
111 an :ref:`artifact build <Understanding Artifact Builds>` will be faster.
115 .. code-block:: shell
119 This command will open your locally built Firefox in a new window.
121 :ref:`More information about building Firefox on Linux <Building Firefox On Linux>` / :ref:`More information about building Firefox on MacOS <Building Firefox On MacOS>`
123 If you encounter build errors, please reference the more detailed "Building Firefox" on your specific operating system document and specifically the "Troubleshooting" section.
130 Make the changes you need in the codebase. You can look up UI text in `Searchfox <https://searchfox.org>`__ to find the right file.
133 If you are unsure of what changes you need to make, or need help from the mentor of the bug,
134 please don't hesitate to use the needinfo feature ("Request information from") on `Bugzilla <https://bugzilla.mozilla.org/home>`__ to get the attention of your mentor.
137 After making your changes, visualize your changes to ensure you're including all the necessary work:
139 .. code-block:: shell
142 # For files changed/added/removed
145 # For detailed line changes
149 # For files changed/added/removed
152 # For detailed line changes
155 Then commit your changes:
157 .. code-block:: shell
167 The commit message should look like:
171 Bug xxxx - Short description of your change. r?reviewer
173 Optionally, a longer description of the change.
175 **Make sure you include the bug number and at least one reviewer (or reviewer group) in this format.**
177 For example, here is an example of a good commit message:
178 "Bug 123456 - Null-check presentation shell so we don't crash when a button removes itself
179 during its own onclick handler. r=person"
181 To :ref:`find a reviewer or a review group <Getting reviews>`, the easiest way is to run
182 ``hg log <modified-file>`` (or ``git log <modified-file>``, if
183 you're using git) on the relevant files, and look who usually is
184 reviewing the actual changes (ie not reformat, renaming of variables, etc).
187 To visualize your patch in the repository, run:
189 .. code-block:: shell
197 :ref:`More information on how to work with stack of patches <Working with stack of patches Quick Reference>`
199 :ref:`More information on Mercurial <Mercurial Overview>`
201 To make sure the change follows the coding style
202 ------------------------------------------------
204 To detect coding style violations, use mach lint:
206 .. code-block:: shell
208 $ ./mach lint path/to/the/file/or/directory/you/changed
210 # To get the autofix, add --fix:
211 $ ./mach lint path/to/the/file/or/directory/you/changed --fix
213 :ref:`More information <Code quality>`
215 To test a change locally
216 ------------------------
218 To run the tests, use mach test with the path. However, it isn’t
219 always easy to parse the results.
221 .. code-block:: shell
223 $ ./mach test dom/serviceworkers
225 To run tests based on :ref:`GTest` (C/C++ based unit tests), run:
227 .. code-block:: shell
229 $ ./mach gtest 'QuotaManager.*'
231 To test a change remotely
232 -------------------------
234 Running all the tests for Firefox takes a very long time and requires multiple
235 operating systems with various configurations. To build Firefox and run its
236 tests on continuous integration servers (CI), multiple :ref:`options to select tasks <Selectors>`
239 To automatically select the tasks that are most likely to be affected by your changes, run:
241 .. code-block:: shell
245 To select tasks manually using a fuzzy search interface, run:
247 .. code-block:: shell
251 To rerun the same tasks:
253 .. code-block:: shell
257 From `Treeherder <https://treeherder.mozilla.org/>`__ (our continuous integration system), it is also possible to attach new jobs. As every review has
258 a try CI run associated, it makes this work easier. See :ref:`attach-job-review` for
263 This requires `level 1 commit access <https://www.mozilla.org/about/governance/policies/commit/access-policy/>`__.
265 You can ask your reviewer to submit the patch for you if you don't have that
268 :ref:`More information <Pushing to Try>`
274 To submit a patch for review, we use a tool called `moz-phab <https://pypi.org/project/MozPhab/>`__.
277 .. code-block:: shell
279 $ ./mach install-moz-phab
281 Once you want to submit your patches (make sure you :ref:`use the right commit message <Commit message>`), run:
283 .. code-block:: shell
287 It will publish all the currently applied patches to Phabricator and inform the reviewer.
289 If you wrote several patches on top of each other:
291 .. code-block:: shell
293 $ moz-phab submit <first_revision>::<last_revision>
296 information on how to use Phabricator and MozPhab <https://moz-conduit.readthedocs.io/en/latest/phabricator-user.html>`__
298 To update the working directory
299 -------------------------------
301 If you're finished with a patch and would like to return to the tip to make a new patch:
303 .. code-block:: shell
308 To update a submitted patch
309 ---------------------------
311 It is rare that a reviewer will accept the first version of patch. Moreover,
312 as the code review bot might suggest some improvements, changes to your patch
315 If your patch is not loaded in your working directory, you first need to re-apply it:
317 .. code-block:: shell
319 $ moz-phab patch D<revision_id>
321 # Or you can use the URL of the revision on Phabricator
322 $ moz-phab patch https://phabricator.services.mozilla.com/D<revision_id>
324 Make your changes in the working folder and run:
326 .. code-block:: shell
328 # Or, if you need to pass arguments, e.g., changing the commit message:
334 After amending the patch, you will need to submit it using moz-phab again.
338 Don't use ``hg commit --amend -m`` or ``git commit --amend -m``.
340 Phabricator tracks revision by editing the commit message when a
341 revision is created to add a special ``Differential Revision:
344 When ``--amend -m`` is used, that line will be lost, leading to
345 the creation of a new revision when re-submitted, which isn't
348 If you wrote many changes, you can squash or edit commits with the
351 .. code-block:: shell
359 The submission step is the same as for the initial patch.
361 :ref:`More information on how to work with stack of patches <Working with stack of patches Quick Reference>`
363 Retrieve new changes from the repository
364 ----------------------------------------
366 To pull changes from the repository, run:
368 .. code-block:: shell
378 To push a change in the code base
379 ---------------------------------
381 Once the change has been accepted and you've fixed any remaining issues
382 the reviewer identified, the reviewer should land the patch.
384 If the patch has not landed on "autoland" (the integration branch) after a few days,
385 feel free to contact the reviewer and/or
386 @Aryx or @Sylvestre on the `#introduction <https://chat.mozilla.org/#/room/#introduction:mozilla.org>`__
389 The landing procedure will automatically close the review and the bug.
391 :ref:`More information <How to submit a patch>`
393 Contributing to GeckoView
394 -------------------------
396 Note that the GeckoView setup and contribution processes are different from those of Firefox;
397 GeckoView setup and contribution docs live in `geckoview.dev <https://geckoview.dev>`__.
399 More documentation about contribution
400 -------------------------------------
402 :ref:`Contributing to Mozilla projects`
404 https://mozilla-version-control-tools.readthedocs.io/en/latest/devguide/contributing.html
406 https://moz-conduit.readthedocs.io/en/latest/phabricator-user.html
408 https://mikeconley.github.io/documents/How_mconley_uses_Mercurial_for_Mozilla_code