How to Build Firefox

By  on  

Firefox Nightly Open source is a dream and a gateway to an amazing career -- I'm a testament to that. One of the most amazing open source projects to ever exist, Mozilla Firefox, is a project I'm proud to work on as an employee of Mozilla. It's rewarding, challenging, and a unique experience...and I want you to join me!

Take a few moments with me to learn how to build the amazing Firefox!

Step 1: Clone Mozilla Central

Mozilla Central is the name of the mercurial repository that contains the source code of Firefox. Start by installing mercurial and cloning "MC":

hg clone https://hg.mozilla.org/mozilla-central/

hg clone {repo_url} is the first and most basic mercurial command, but check out my Mercurial Productivity Tips post to learn more hg commands! "MC" will be installed in a mozilla-central directory.

Step 2: Install Dependencies

From C++ to Rust, Firefox has a fair bit of requirements you'll need to install. From within the mozilla-central directory, run the following:

./mach bootstrap

The bootstrap command will install dependencies as well as configure mercurial extensions as required. Congratulations -- you're now ready to build!

Step 3: Create a mozconfig

You'll thank me for this one! Create a mozconfig file to use artifact builds, which will save loads of time during the build process by downloading pre-built binaries for Firefox's internals.

# Automatically download and use compiled C++ components:
ac_add_options --enable-artifact-builds

# Write build artifacts to:
mk_add_options MOZ_OBJDIR=./objdir-frontend

Place the code above in your mozconfig file and you're builds will be super fast!

Step 4: Build!

Once you have the code and the dependencies, it's time to build the amazing Firefox! You can build Firefox with the following command:

./mach build

Hello Firefox!

Step 5: Run Firefox

Once you've built the amazing Firefox, you can run Firefox with the following mach command:

./mach run --jsdebugger

Congratulations! You've taken the Firefox source code and turned it into an application that you can run! The --jsdebugger option opens the "browser toolbox" which allows you to debug the Firefox you've just built.

Updating Mozilla Central Code

The Mozilla Central repository is updated several times a day as Mozilla employees and contributors like you submit patches. You can update your local checkout with the following:

hg pull && hg update --clean

You local commits will always be draft status while patches which have been merged into MC will be public status.

Configuring Options

Whenever Firefox developer and the community develop new features, they're hidden behind a preference until the feature reaches maturity. To toggle feature flags, you can visit about:config in your local Firefox or any Firefox release.

about:config

The config page allows you to toggle and set a number of options. Many "edge" features debut behind feature flags in Firefox Nightly.

Congratulations! You've turned a massive repository of code into a living, breathing Firefox web browser! In the next post in the Firefox series, we'll explore contribution and testing!

Recent Features

  • By
    Create Namespaced Classes with MooTools

    MooTools has always gotten a bit of grief for not inherently using and standardizing namespaced-based JavaScript classes like the Dojo Toolkit does.  Many developers create their classes as globals which is generally frowned up.  I mostly disagree with that stance, but each to their own.  In any event...

  • By
    How to Create a RetroPie on Raspberry Pi – Graphical Guide

    Today we get to play amazing games on our super powered game consoles, PCs, VR headsets, and even mobile devices.  While I enjoy playing new games these days, I do long for the retro gaming systems I had when I was a kid: the original Nintendo...

Incredible Demos

  • By
    spellcheck Attribute

    Many useful attributes have been provided to web developers recently:  download, placeholder, autofocus, and more.  One helpful older attribute is the spellcheck attribute which allows developers to  control an elements ability to be spell checked or subject to grammar checks.  Simple enough, right?

  • By
    Create Digg URLs Using PHP

    Digg recently came out with a sweet new feature that allows users to create Tiny Digg URLs which show a Digg banner at the top allowing easy access to vote for the article from the page. While I love visiting Digg every once in a...

Discussion

    Wrap your code in <pre class="{language}"></pre> tags, link to a GitHub gist, JSFiddle fiddle, or CodePen pen to embed!