Contributing To Mozilla: Build Firefox with Mercurial bundles

Contributing To Mozilla: Build Firefox with Mercurial bundles

Setting up Firefox with Mercurial bundles is best advisable when issues of poor network is encounter while using the hg clone command to set up Firefox on your system. If interested in using hg clone, here's the link to clone and build Firefox, click me.

The first line of action is to install Mercurial as the Version Control System, which Mozilla uses by running the following command.

Mac

Homebrew

brew install mercurial

macport

sudo port install mercurial

Linux

apt

sudo apt-get install mercurial

To check if you have successfully installed Mercurial, run the below command,

hg --version

The response would look like the picture below: mercurialVersion.png

Are you new to Mercurial? Yes? Here's a quick guide to using Mercurial. But there's a place for the git user who are not experienced with Mercurial. You may want to install git-cinnabar that would help you to interact with the Mercurial repos using git commands.

You would also need Python installed on your local system. This would come handy later. Let's continue.

Clone the sources

Up-to-date bundles of some of the Mozilla repositories are available on a CDN at https://hg.cdn.mozilla.net/. Download the zstd bundle for the repository you're interested in, for they are smaller in file size and faster to decompress. But for this exercise the mozilla-central is what we are interested in.

Setting up the repository

Once the download is finshed, we can now recreate the mozilla-central repository locally on our system.

  1. Create a new directory called mozilla-central, then using Mercurial initialize a new repository in the directory:

    mkdir mozilla-central
    hg init mozilla-central
    
  2. Un-bundle the bundle file to that repository:

    • To use the below command in Windows, export the \path\to\hg and invoke the command from the command prompt.
    • On Linux/Mac check if the file name is bundle.hg, if not rename it to bundle.hg. Right click on the file, check the properties of the file and you can find the path.
      cd mozilla-central
      hg unbundle paste/path/to/your/bundle.hg
      
      At this point, relax and play CODm or watch that anime while the file unbundles. This process takes quite a long time to complete.
  3. Next step is to set up the config file, .hg/hgrc to automatically let Mercurial pull changes from future updates when available. Open the config file on the terminal by running hg config --edit or on your editor by running EDITOR=<editor-of-your-choice> hg config --edit. Example with Visual Studio code:

    EDITOR=code hg config --edit
    

    Then add the following at the bottom of the file

    [path]
    default = https://hg.mozilla.org/mozilla-central/
    
  4. It's advisable to make sure the local repository is currently at the same update with the official repository by running the below commands.
    hg pull
    hg update
    

You finally have a clone of the mozilla-central that's the same with the one made using the hg clone command. You can decide to either adjust your build setting, or you can jump right in to build the Firefox finally.

Build Firefox

Now let assembly all these together to build Firefox. In your terminal window, cd to the directory that contains the source files, mozilla-central and run the following commands sequentially.

cd mozilla-central
./mach bootstrap
./mach build

The ./mach bootstrap command is to catch-all for any dependencies not covered in this article. At this point select the Artifact Builds in the first question, if working on Firefox or Firefox for Android frontends or building Firefox without any changes to it. Building with Artifact is much faster. Then choose the first option for the desktop version or third option for android version. Relax and allow the Firefox to build, it might take two hours or more on older hardware. BuildOptions.png

Then reply consequent questions with yes when appropriate.

Run Firefox

When all the mach build is completed and ready, your Firefox is ready to run. Now run it with

./mach run

Congrats fellow, you can now start your contribution.

If you were stuck at any point, feel absolutely free to join and ask on Riot/Matrix at https://chat.mozilla.org in #introduction channel or email me