Editor / IDE integration¶
You can use any editor or IDE to contribute to Firefox, as long as it can edit text files. However, there are some steps specific to mozilla-central that may be useful for a better development experience. This page attempts to document them.
This page is a work in progress. Please enhance this page with instructions for your favourite editor.
There’s C++ and Rust auto-completion support for VIM via
YouCompleteMe. As long as that
is installed and you have run
./mach build or
it should work out of the box. Configuration for this lives in
.ycm_extra_conf at the root of the repo.
If you don’t like YouCompleteMe, other solutions also work, but they’ll require
you to create a
compile_commands.json file (see below for instructions).
Rust auto-completion should work both with the default completer (RLS, as of this writing), or with rust-analyzer.
The easiest way to integrate ESLint with VIM is using the Syntastic plugin.
In order for VIM to detect jsm files as JS you might want something like this
mach eslint --setup installs a specific ESLint version and some ESLint
plugins into the repositories’
You need something like this in your
.vimrc to run the checker
automatically on save:
You need to have
eslint in your
PATH, which you can get with
npm install -g eslint. You need at least version 6.0.0.
You can also use something like eslint_d which should also do that automatically:
C/C++ Development Packages¶
General Guidelines to Emacs C++ Programming¶
The following guides give an overview of the C++ editing capabilities of emacs.
It is worth reading through these guides to see what features are available. The rest of this section is dedicated to Mozilla/Gecko specific setup for packages.
irony (LLVM/Clang-based Code Completion)¶
Instructions on the installation of irony-mode are available at the irony-mode github repo.
irony-mode requires a compilation database.
Note that irony-mode, by default, uses elisp to parse the
compile_commands.json file. As gecko is a very large codebase, this
file can easily be multiple megabytes, which can make irony-mode take multiple
seconds to load on a gecko file.
It is recommended to use this fork of irony-mode, which requires the boost System and Filesystem libraries.
Checking the bug to get this patch into the mainline of irony-mode is recommended, to see if the fork can be used or if the mainline repo can be used. Using the Boost version of the irony-mode server brings file load times to under 1s.
Projectile (Project Management)¶
Instructions on the installation of projectile are available at the projectile github repo.
Projectile comes preconfigured for many project types. Since, gecko uses its own special build system (mach), a new project type needs to be added. This can be done via adding the following elisp configuration command to your emacs configuration file.
(projectile-register-project-type 'gecko '("mach" "moz.build") "python mach --log-no-times build" "python mach mochitest" "python mach run")
Assuming projectile-global-mode is on, this will allow projectile to run the correct commands whenever it is working in a gecko repo.
Emacs comes with great integration with gdb, especially when using gdb-many-windows.
However, when gdb is invoked via mach, some special arguments need to be passed in order to make sure the correct display mode is used. To use M-x gdb with mach on firefox, use the following command:
gecko_repo_directory/mach run --debug --debugparams=-i=mi
You can generate an Eclipse project by running:
./mach ide eclipse
See also the Eclipse CDT docs on MDN.
You can run a Visual Studio project by running:
./mach ide visualstudio
CompileDB back-end / compileflags¶
You can generate a
compile_commands.json in your object directory by
./mach build-backend --backend=CompileDB
This file, the compilation database, is understood by a variety of C++ editors / IDEs to provide auto-completion capabilities. You can also get an individual compile command by running:
./mach compileflags path/to/file
This is how the VIM integration works, for example.