Understanding the file structure

Lets take a look at the file structure of your project. It should look something like this:

β”œβ”€  .gitignore
β”œβ”€  foxfork.json
β”œβ”€  configs
β”‚   β”œβ”€  common
β”‚   β”‚   └─  mozconfig
β”‚   β”œβ”€  linux
β”‚   β”‚   └─  mozconfig
β”‚   β”œβ”€  macos
β”‚   β”‚   └─  mozconfig
β”‚   └─  windows
β”‚       └─  mozconfig
β”œβ”€  src
β”‚   β”œβ”€  README.md
β”‚   └─  browser
β”‚       └─  themes
β”‚           β”œβ”€  custom
β”‚           β”‚   β”œβ”€  linux
β”‚           β”‚   β”‚   └─  linux.inc.css
β”‚           β”‚   β”œβ”€  macos
β”‚           β”‚   β”‚   └─  macos.inc.css
β”‚           β”‚   β”œβ”€  shared
β”‚           β”‚   β”‚   └─  shared.inc.css
β”‚           β”‚   └─  windows
β”‚           β”‚       └─  windows.inc.css
β”‚           β”œβ”€  linux
β”‚           β”‚   β”œβ”€  browser-css.patch
β”‚           β”‚   └─  jar-mn.patch
β”‚           β”œβ”€  osx
β”‚           β”‚   β”œβ”€  browser-css.patch
β”‚           β”‚   └─  jar-mn.patch
β”‚           β”œβ”€  shared
β”‚           β”‚   β”œβ”€  browser-shared-css.patch
β”‚           β”‚   └─  jar-inc-mn.patch
β”‚           └─  windows
β”‚               β”œβ”€  browser-css.patch
β”‚               └─  jar-mn.patch
β”œβ”€  .foxfork
β”‚   └─  ...
└─  engine
    └─  ...

Whilst this may seem large (especially if you look inside of the engine) directory, it is all fairly manageable.

foxfork.json

The primary configuration file for your project is the foxfork.json file. This is where you will put information about your browser so FoxFork can build it correctly. It should look something like this:

Up the top of the config file, we have general information about the browser you are building. This includes its name, the vendor creating it, its appId, and the name of the binary that will be output.

The version key is used to specify information about the product you are building. product is the Firefox branch you are building against. version is the version of Firefox you are building against, which will vary with the branch. Here firefox refers to the stable branch of Firefox.

buildOptions provides a number of internal toggles for how FoxFork builds your project.

Configs

The configs folder stores a combination of config files that are required by Firefox and assets required by FoxFork. By default there are only mozconfig files, FoxFork should generate most parts of this config for you. The only part that you will need to change is the source control repo:

This directory is also where you would put branding assets for your browser

src/

The source folder contains all of the modifications that you have made to Firefox. These come in two types, inserted files (and folders) and patches. Both of these are applied using the FoxFork import command.

Inserted files are just files (and folders) that you have inserted into the Firefox source code. These will overwrite existing files if they already exist. On Linux and MacOS, these are symlinked so when you change a file in src/, the change will be mirrored in Firefox's source code instantly. On Windows, you will need to run FoxFork import for these changes to apply.

Patches are changes to Firefox's files. As a rule of thumb, you should prefer splitting new content into a new file rather than using patches, but there are times when you must modify Firefox's source code. Each of these patch files are just git patch files:

In this patch, you can see that I am adding a * to the start of a line. You generate these patches by modifying the file in the engine/ directory and running FoxFork export to export your changes to the src directory. Be careful, if you do not export your changes, they will not be saved and will not work on other developers' computers or yours after an update!

engine/

The engine directory contains all of Firefox's source code. It is massive - around 15GB in size (around 11GB of that are build assets from when you run FoxFork build). I am not able to provide a full explanation of the contents of the directory.

However, most of the changes you will want to make will be in engine/browser/, which contains the source code for the browser's UI. Here are some of the important directories inside of the engine/browser/ directory:

One of the best ways to find what you are looking for and get to know the code base is by searching it. However, if you try and search through it on your computer you are in for a world of pain. Instead, I recommend you use SearchFox, which is significantly faster.

Last updated