Blog ⋅ Peter Nelson

Summer of WebKit, Part 1: Compiling WebKit

by peterdn 19. July 2010 14:52

(Updated December 18 2010.  The build process has changed subtly – updated info is marked in bold.)

With summer upon us, I’m finally getting a bit more time to work on some WebKit and WebKit .NET stuff.  My intention is to make my way through the TODOs in the project roadmap and blog about any interesting bits as I go.  As can be seen, there is a fair amount to be done, hence the ‘Part 1!’

I started, as I usually do, with the mammoth task of compiling WebKit, which inevitably takes much longer than I anticipate.  The exact process seems to change very subtly each time.  Here I’ll describe the exact steps I went though this time (with WebKit revision 63600 or so).  Although mainly for my own reference, it may save someone else a couple of hours if they run into the same problems that I did.  So, to get it building (assuming a build environment is configured as described here, Visual Studio 2008 is installed, and the WebKit source and support libraries have been downloaded):

  1. Grab the dependencies required to build the Cairo port (updated October 2 2010; thanks Brent Fulgham) and extract them somewhere.
  2. Fire up Visual Studio 2008 and open WebKit/win/WebKit.vcproj/WebKit.sln.  Run through the conversion process and finish.  Add the ‘include’ and ‘include/cairo’ directories from the dependencies in the previous step to the Visual C++ include directory list.  Similarly, add the ‘lib’ directory to the Visual C++ libraries directory list.  Close Visual Studio.
  3. Open a cygwin prompt, navigate to the WebKit root directory and run the script (Updated December 18 2010: The WebKitTools directory has been renamed to Tools):
    Tools/Scripts/build-webkit
    This downloads another set of libraries and installs them, along with the support libraries.  As we’ve converted the project to VS 2008, and the script is configured to build with VS 2005, the build will fail, but we can ignore that.  There is probably a more elegant way to install these libraries, but this method suffices for the moment.  No worries there.
  4. Added December 18 2010: It's now also necessary to run the following script to install another set of libraries:
    Tools/Scripts/update-webkit
    This will also update to the latest SVN revision.
  5. Open up WebKit.sln in VS 2008 again and set the build configuration to Release_Cairo (or Debug_Cairo as the case may be).  VC++ 2008 is much more strict than VC++ 2005 so issues more warnings, and by default, the WebKit projects are configured to treat warnings as errors.  In the C++ configuration properties for every project (specifically, JavaScriptCore, WTF, jsc, testapi, WebCore, QTMovieWin, WebKit, and WebKitLib), disable the ‘Treat Warnings as Errors’ option.  Optionally, turn off warnings completely for a smoother build experience (I got over 60,000 on warning level 4 before my machine seized up).
  6. Optionally, disable optimization for JavaScriptCore, WebCore, WebKit, and WebKitLib, but remember to enable again before a release!  This drastically decreased build time for me.
  7. In the WebCore librarian configuration properties, add the following switch to the command line options:
    /expectedoutputsize:3000000000
    This is a workaround for a problem where the linker runs out of memory and issues a “LNK1106: invalid file or disk full: cannot seek to 0x…” error message.  More information can be found in this Microsoft KB article.
  8. Optionally, but required for the DOM access functionality in WebKit .NET 0.4+, replace WebKit/win/DOMCoreClasses.cpp and WebKit/win/DOMCoreClasses.h with these modified versions.  Hopefully I’ll get these changes committed to the actual WebKit repository at some point, but until then you can grab them from here.
  9. We’re pretty much done.  Hit build and go make a cup of tea or do something else constructive for a while.  In my experience, it takes about 45-60 minutes to build from scratch with optimizations disabled, and 2-3 hours with them enabled.

And voila, we (should) have a fully-functioning WebKit Cairo build to use.

As it turns out, I did get enough time to implement basic printing functionality in WebKit .NET (no page setup or print preview yet) as well, but I’ll leave that for part 2 when it’s more complete.  The changes should be up on SVN very soon, and a 0.5 release is well on its way.

Tags: , , ,

WebKit | WebKit .NET