For the last couple days it has been a roller coaster yet also a great rewarding learning experience. Building Firefox from essentially a directory of hundreds of files is no easy task and through doing so I learned that I don’t have most of the required libraries and tools needed to build such a browser.
The process works as follows:
- Get the latest Mozilla Build version from https://hg.mozilla.org/ (As of this post its 3.0)
- Install Mozilla Build to C:/mozilla-build
- From the same site https://hg.mozilla.org/ (which holds all the files Mozilla related). You need to download mozilla-central and unzip it to the path C:/mozilla-source/mozilla-cental/
- Now launch start-shell.bat from the mozilla-build directory cd to mozilla-central
- Set path PATH=$PATH:~/.cargo/bin and run the following commands
- mach bootstrap
- mach build
- mach run
- After these steps you SHOULD have a successful Mozilla Firefox build provided you have ALL the prerequisites and the REQUIRED environment variables created
I listed this process and ripped it from Mozilla’s guide because by the look of it it seems super straight forward, however in reality its a completely different game. The amount of hours I spent fixing error after error was intense and very very tedious with multiple attempts of starting completely from scratch and even on different computers. With errors and debugging I consider myself fairly resilient and will exhaust every possibility so I fix whatever I’m working on however this project of building Firefox was something else which is why I also say it is a great learning experience and I am glad I got it working in the end.
First it started with simple errors like “you need this specific C++ library or the Windows 10 SDK.” That was all fine and good and I downloaded a couple gigabytes of libraries and required applications. Then it got to errors like you have to set “llvm_config” as a environment variable indicating llvm-config.exe not found. This is when the slippery slope of undocumented requirements and bugs started to manifest. In Mozilla’s own instruction they don’t indicate that you need to download LLVM/Clang so by doing research I found out how to get it off their website (LLVM) which is actually not the right way to get it because for some reason the only executable I need (llvm-config.exe) is NOT included in the download from that website. From this point began more research to find a build of LLVM that has llvm-config.exe so I can make a environment variable and continue with the Mozilla Build process which is just fix errors simulator. Eventually I found one (ClangOnWin) that contains my desired .exe and went on with the process. Through the rest of process there were more weird errors with certain paths not made and simple executables like makecab.exe not being seen by the Mozilla Build shell but it is seen by simple command prompt.
Then came the final error which I am 99.99% sure is a bug with the latest Mozilla Build because I tried two different computers from scratch and encountered the same error. The only workaround is to use some files from a previous Mozilla Build release which corrects the issue thus indicating that if ANYONE wants to build Mozilla on windows they will encountered a barely documented compiler issue.
To fix this you need to download Mozilla build 2.2.0 and copy the start-shell.bat and the start-shell-msvc2015.bat to your mozilla-build directory and then use start-shell-msvc2015.bat to build. So I did all of that and now have a working Firefox build that I modified to show that it is indeed working.
Here is what I modified:
- When you click open new window it will open a page showing random cat animated gifs
- Modified the top tab bar to show as orange by doing the following code edit to background: url(‘your-desired-image’);
- Tab color and font color modified to red and transparent greenish
- Modified browser.dtd to show menu options differently. Named “New Window” to “New Tindow” in the hope the cross between a tab and a window will catch on 😉
Overall though these are super simple code edits the hope is for this to lead to real world Mozilla Firefox bug work and possibly develop new improvements for the browser.