Understanding the file structure
Lets take a look at the file structure of your project. It should look something like this:
Whilst this may seem large (especially if you look inside of the .engine
) directory, it is all fairly manageable.
samurai.json
The primary configuration file for your project is the samurai.json
file. This is where you will put information about your browser so Samurai 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 Samurai builds your project.
Configs
The configs folder stores a combination of config files that are required by Firefox and assets required by Samurai. By default there are only mozconfig
files, Samurai 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 samurai 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 samurai 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 samurai 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 samurai 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:
.engine/browser/base/content
: These contain the xhtml files that make up a majority of the browser's ui.engine/browser/components
: This contains some self-contained UI features, like screenshots, uitours, downloads, etc..engine/browser/themes
: Here lies most of the browsers CSS. See Customizing Your Browser's UI for more information.
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