How to set up a SeaMonkey tinderbox with Microsoft Visual C++ 2005 Express Edition

by Robert Kaiser <kairo@kairo.at>

This document tries to describe all I have done to build the tpol tinderbox (as seen in the Mozilla1.8-SeaMonkey tree). I hope I didn't forget anything important in this doc...

  1. Install Windows XP Professional SP2 and all available updates
  2. Install the Microsoft Platform SDK ("PSDK") with the following components:
  3. Go to the \include\atl folder under the PSDK directory, and: Now the PSDK should be fixed in a way that we can build ATL stuff using it. Unfortunately MFC still doesn't work (see below).
    NOTE: This step might not be needed if you use the --disable-activex build option instead, as ATL should only be needed for ActiveX.
  4. Install Visual C++ 2005 Express Edition ("VC8"): Leave default installation settings (only IDE selected)
  5. Install MSASM32.
  6. Install Cygwin: NOTE: You may use ActiveState perl instead of the perl package in cygwin if you prefer, but I had problems getting tinderbox to run with that, so I went back to cygwin perl.
  7. Install moztools ("Netscape wintools") and compiler-specific libraries:
  8. In a new C:\moz directory, create a buildsetup.bat with the following content:
    @ECHO OFF
    SET MOZ_TOOLS=C:\moztools
    SET VCMOZTOOLS=C:\vc8
    SET MASM=C:\masm32
    SET VSTUDIO=%ProgramFiles%\Microsoft Visual Studio 8
    SET VCPATH=%VSTUDIO%\VC
    SET NETSDK=%VSTUDIO%\SDK\v2.0
    SET NETFW=%SystemRoot%Microsoft.NET\Framework\v2.0.50727
    SET PSDK=%ProgramFiles%\Microsoft Platform SDK
    
    SET PATH=%VCMOZTOOLS%;%VCMOZTOOLS%\bin
    SET PATH=%PATH%;%VCPATH%\bin;%PSDK%\Bin;%NETSDK%\Bin
    SET PATH=%PATH%;%MOZ_TOOLS%\bin;C:\cygwin\bin
    SET PATH=%PATH%;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\wbem
    SET PATH=%PATH%;%VSTUDIO%\Common7\IDE
    SET PATH=%PATH%;%PSDK%\Bin\win64
    SET PATH=%PATH%;%NETFW%
    SET PATH=%PATH%;%MASM%\BIN
    
    SET LIB=%VCPATH%\lib;%PSDK%\Lib;%NETSDK%\Lib
    SET LIB=%LIB%;%MASM%\LIB
    
    SET INCLUDE=%VCPATH%\include;%PSDK%\Include;%NETSDK%\Include
    SET INCLUDE=%INCLUDE%;%MASM%\INCLUDE
    SET INCLUDE=%INCLUDE%;%PSDK%\Include\atl
    SET INCLUDE=%INCLUDE%;%PSDK%\Include\crt
    SET INCLUDE=%INCLUDE%;%PSDK%\Include\mfc
    
    SET GLIB_PREFIX=%VCMOZTOOLS%
    SET LIBIDL_PREFIX=%VCMOZTOOLS%
    SET CVSROOT=:pserver:anonymous@cvs-mirror.mozilla.org:/cvsroot
    SET HOME=C:\moz
    SET CVS_RSH=ssh
    ECHO Installation environment variables set!
    @ECHO ON
  9. Install Blat (needed by tinderbox):
  10. Install tinderbox in C:\tinderbox\SeaMonkey and set up a fitting tinder-config.pl there:
  11. Create a mozconfig in C:\tinderbox\SeaMonkey with the following content:
    # tpol tinderbox config
    mk_add_options MOZ_OBJDIR=../build
    
    mk_add_options MOZ_CO_PROJECT=suite
    ac_add_options --enable-application=suite
    
    # these are done in tinder-config.pl since this doesn't seem to work:
    export MOZILLA_OFFICIAL=1
    mk_add_options MOZILLA_OFFICIAL=1
    export BUILD_OFFICIAL=1
    mk_add_options BUILD_OFFICIAL=1
    
    ac_add_options --disable-tests
    # disable embedding's MFC tests (don't build with free tools)
    export NO_MFC=1
    ac_add_options --without-system-jpg
    ac_add_options --without-system-zlib
    ac_add_options --enable-extensions=default,tasks
    ac_add_options --enable-crypto
    ac_add_options --disable-debug
    ac_add_options --enable-optimize="-Ox -Zc:wchar_t-"
    
    # SVG and canvas
    ac_add_options --enable-svg
    ac_add_options --enable-canvas
    Especially care that --enable-optimize="-Zc:wchar_t-" and export NO_MFC=1 are in there, both are needed to successfully build with your VC8 environment.
  12. Run a checkout of the code, best with the tinderbox start command noted below (terminated by Ctrl+C once it has checked out the whole source).
  13. Apply patch(es) for .manifest embedding (see bug 249782)
  14. Run tinderbox: Go to C:\tinderbox\SeaMonkey in a command prompt and run
    c:\moz\buildsetup.bat
    perl build-seamonkey.pl --depend --mozconfig mozconfig
    NOTE: Instead of the perl command, you can also use the tinderbox start script to run it, which needs to be run through bash, but completely runs tinderbox in the background. For this, run the following command after loading buildsetup.bat:
      bash -c "./tinderbox depend start"

Redistributable builds

The generated builds run fine on the build machine, but for redistributing, all included .exe and .dll files need to find the VC8 libraries. Actually, only msvcr80.dll is needed. Interestingly, even if the EULA grants the permission to redistribute the libraries (from how I read it), the Express Edition creates no redist folder that would contain them for redistribution. Of couse, it installs them on your system though.

NOTE: With the full Visual C++ 2005, you get not only the redist folder, but also a vcredist_x86.exe that can be installed on the target system. Once that's done, all VC8 builds run out-of-the-box there.

So, you need to get your build to have and find msvcr80.dll on the target system. It's harder to find out how to do that than one would expect, but it's possible. First, find your msvcr80.dll, which should be in a folder called "C:\WINDOWS\WinSxS\x86_Microsoft.VC80.CRT_1fc8b3b9a1e18e3b_8.0.50727.42_x-ww_0de06acd", and copy this file into the application's main directory (next to seamonkey.exe in our case). With luck, the build should run with Windows versions up to Windows 2000 now. Windows XP makes use of so-called "Side-by-side" Assemblies, and uses much tighter versioning of binaries, which makes deployment of our packages more complicated unfortunately, as the VC8 linker writes a requirement for different versions of the libraries into our files than the versions distributed with VC8.

To make it short, you need to add a Microsoft.VC80.CRT.manifest next to msvcr80.dll. This is a simple XML file with the following content:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
    <noInheritable></noInheritable>
    <assemblyIdentity type="win32" name="Microsoft.VC80.CRT" version="8.0.50608.0" processorArchitecture="x86" publicKeyToken="1fc8b3b9a1e18e3b"></assemblyIdentity>
    <file name="msvcr80.dll" hash="2a0d797a8c5eac76e54e98db9682e0938c614b45" hashalg="SHA1"><asmv2:hash xmlns:asmv2="urn:schemas-microsoft-com:asm.v2" xmlns:dsig="http://www.w3.org/2000/09/xmldsig#"><dsig:Transforms><dsig:Transform Algorithm="urn:schemas-microsoft-com:HashTransforms.Identity"></dsig:Transform></dsig:Transforms><dsig:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"></dsig:DigestMethod><dsig:DigestValue>phRUExlAeZ8BwmlD8VlO5udAnRE=</dsig:DigestValue></asmv2:hash></file>
    <file name="msvcp80.dll" hash="cc4ca55fb6aa6b7bb8577ab4b649ab77e42f8f91" hashalg="SHA1"><asmv2:hash xmlns:asmv2="urn:schemas-microsoft-com:asm.v2" xmlns:dsig="http://www.w3.org/2000/09/xmldsig#"><dsig:Transforms><dsig:Transform Algorithm="urn:schemas-microsoft-com:HashTransforms.Identity"></dsig:Transform></dsig:Transforms><dsig:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"></dsig:DigestMethod><dsig:DigestValue>7AY1JqoUvK3u/6bYWbOagGgAFbc=</dsig:DigestValue></asmv2:hash></file>
    <file name="msvcm80.dll" hash="55e8e87bbde00d1d96cc119ccd94e0c02c9a2768" hashalg="SHA1"><asmv2:hash xmlns:asmv2="urn:schemas-microsoft-com:asm.v2" xmlns:dsig="http://www.w3.org/2000/09/xmldsig#"><dsig:Transforms><dsig:Transform Algorithm="urn:schemas-microsoft-com:HashTransforms.Identity"></dsig:Transform></dsig:Transforms><dsig:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"></dsig:DigestMethod><dsig:DigestValue>hWq8zazTsMeKVxWFBa6bnv4hEOw=</dsig:DigestValue></asmv2:hash></file>
</assembly>
SeaMonkey has a quite big set of .dll files in the components folder as well, we have to direct them to the VC library as well, so copy our .manifest in there, but with one slight change: the name="msvc*80.dll" attributes get changed to name="..\msvc*80.dll" so that we can trick modern Windows versions into loading only one copy of the libraries. Note that older Windows version might need another copy of msvcr80.dll in the components folder, we haven't tested that (yet).

With those changes, you should actually be able to run your builds on a computer that doesn't have VC8 installed.
From what I've heard, Windows NT 3.51 or Windows 95 still can't run the builds however...

Sources, acknowledgements and further reading tips: