In the Fox's Den: First build
The first step if you wish to contribute to an open-source project is to get the source code, manage to build it locally and execute it on your machine.
For smaller projects, this is usually not very complicated, although — sometimes — installing the necessary development requirements can be tricky1. Bigger projects often offer a “bootstrap” script that contains the necessary logic to fetch the sources, install dependencies and build the program/application.
This is the case for Firefox and its bootstrap.py script.
I followed the instructions in the Firefox Source Docs and ran the following commands in the terminal:
curl -LO https://raw.githubusercontent.com/mozilla-firefox/firefox/refs/heads/main/python/mozboot/bin/bootstrap.py
python3 bootstrap.py
The sources were pulled from GitHub and, finally, I was prompted to configure the build version.
Please choose the version of Firefox you want to build:
1. Firefox for Desktop Artifact Mode [default]
2. Firefox for Desktop
3. GeckoView/Firefox for Android Artifact Mode
4. GeckoView/Firefox for Android
5. SpiderMonkey JavaScript engine
Per the bootstrap.py output:
Artifact builds download prebuilt C++ components rather than building them locally. Artifact builds are faster!
Artifact builds are recommended for people working on Firefox or Firefox for Android frontends, or the GeckoView Java API. They are unsuitable for those working on C++ code.
For this first contact with the Firefox source code, I went with the default option (i.e. artifact mode).
A new firefox directory was created and after entering it, I was ready to build and run Firefox.
The commands are straightforward and self-explanatory, and I only needed to use mach2.
I ran:
./mach build
./mach run
and that was it3.
A window running a locally built Firefox Nightly popped up on my screen and I could browse the web normally with all the latest features that the Firefox community has implemented. The bleeding edge of Firefox at my fingertips.
What’s next? Everything is set up to make some changes and observe their effects.
Stay tuned.
-
For my projects I have settled on using Nix Flakes, since I believe they solve most of the pain points. ↩
-
Mach is a generic command dispatcher for the command line. During Firefox development it is used to build the project, lint the source code, run the tests and run the generated executable. It has many more subcommands that I have yet to explore. ↩
-
Shout-out to all the people who have worked to make sure that the “bootstrapping” process is smooth. Apart from some Python version inconsistencies, everything else went without any problem. ↩
It is part of a series of posts that aim to explore the Firefox source code. Check them out here.