Thursday, December 11, 2008

Building Firefox on Windows with Visual Studio .NET 2008

As I wanted some feature modification in Firefox, I started off with building it first. I tried to follow steps given in Build-Documentation, but I ran into few problems. I realized that the build environment I have got on my box is different from what Firefox Build-Scripts were expecting. I wondered why there isn't any sln file that would work straight away.

I have both Visual-Studio 2005 (VS8) and Visual Studio 2008 (VS9) installed on my machine and got SDK6.1, and .NET 2.0 and 3.5. Well, I thought I should be able to build it easily but I was wrong.

Browsing my windows SDK installation directories, I could see versions 5.0, 6.0A, and 6.1 on my box, but none of these were expected by firefox scripts. Finally, I had to hack these scripts little to make them work for me.

Here is the sequence of steps I did to create custom built firefox installer. Most of these steps are same as build-and-install guidelines and I only added about the problems I encountered.
  1. Downloaded source code from here. Let's call this source-root.
  2. Downloaded mozilla-setup-1.3.exe and installed it. Let this be called build-root.
  3. Created mozconfig-custom config file in my source-root similar to FireFox's default release configuration. You can find such configuration here.
  4. Exported MOZCONFIG envrionment variable with value set to config file created in step above.
  5. I used objdir as suggested by the configuration guidelines.
  6. I ran start-msvc9.bat inside build-root and got an error saying 'unexpected version 5 at this time'.
  7. start-msvc9.bat internally uses guess-msvc.bat which guesses the installed VC and SDK versions. As I told earlier, there is a mismatch in expectation and script wanted v6.0 for SDK, but I have got 6.0A and 6.1. It surely failed to guess this time.
  8. So, I edited guess-msvc.bat so that it will search for v6.1.
  9. Run start-msvc9.bat again, and got another error 'Framework32\v2.0.50727 unexpected'.
  10. start-msvc9.bat calls vcvars32.bat of VS9 installation and vcvars32 is screwing up PATH variable.
  11. It seems that VS9 installation did not correctly prepare vcvars32.bat. So, I modified vcvars32.bat file to correctly prepare PATH variable. This file prepares VC environment and adds required directories in PATH. It had
    • SET FrameworkDir=Framework32
    • SET FrameworkVersion=v2.0.50727
    • something similar to SET PATH=%PATH%;%FrameworkDir%\%FrameworkVersion%;
  12. I modified these three statements and corrected PATH.
  13. Run start-msvc9.bat again
  14. I got a bash shell (I quickly set my favorite aliases).
  15. Run 'make -f client.mk build'
  16. It asked me to run 'dos2unix.py' and convert all files to have unix style endings. Fine, ran it, failed, ran again, failed, ran again. Succeeded finally.
  17. Run 'make -f client.mk build'.
  18. It ran for a while and then bailed out saying 'No rule to make xyz.html0000664'.
  19. For some strange reason, 0000664 was appended to several files and MakeFile.in has got a rule for xyz.html only. So, I renamed these files back to 'xyz.html'.
  20. Run make command again.
  21. Voila, Successful build.
  22. I ran the executable inside my 'objdir\dist', and it worked like a charm. It used all my original bookmarks too.
  23. Now, I want to make an installer as given in the pages.
  24. Run 'make -C objdir/browser/installer installer'
  25. OOOHHH HHHOOO. I got it inside my 'objdir/dist/install/sea'.

Sure, it would really be wonderful if there is a single sln file and we just open and click Build-NOW. We just love it, wont we? But we dont get things for free, we have to make it ourselves.

1 comment:

Abdullah said...

I am running into similar issues when I try to build Lightning 0.9 on vista x64.
Can you list out the changes you did in guess-msvc.bat?