wiki:WebKitGTK/StartHacking

Version 3 (modified by Andres Gomez, 11 years ago) (diff)

Added compiling section

Start hacking in WebKitGTK+

HW conditionants

WebKit is such a bahamut that the first thing to take into account is the location we want to use as our working place.

Basically, we will be able to compile in two flavors: Release and Debug. As its name says, the debug compilation mode will keep the debugging symbols. This is handy for debugging but will take longer time in the compilation, will use much more space and will need much more RAM. In addition, the performance may be affected when trying to open a debugging session with GDB.

  • A local copy of the Git repository will take ~7Gb.
  • As the GTK port uses for its build jhbuild, the dependencies needed will take ~3Gb.
  • The objects of a Release build will take another additional ~1Gb.
  • The objects of a Debug build will take another several additional Gbs (approx. amount to be completed).

In addition, there may be other factors to get into account:

  • You may want to speed up your compilation through the usage of ccache and, therefore, reserve another ~8Gb (with few builds my cache is taking ~3Gb).
  • You may want to combine WebKitGTK development with Epiphany development, the reference application using WebKitGTK and the official GNOME web browser. This will take another additional Gbs (approx. amount to be completed).
  • You may want to do your hacking in a chroot environment so it doesn't interfere with your production distribution. A basic Ubuntu Quantal Quetzal x64 in which to work takes to me ~4Gb.

With all this, I would reccommend to start working in a hard drive partition in which we have at least a minimum of 50Gb of free space.

In addition, WebKit needs tons of RAM memory and CPU power. If you don't want to get bored waiting for your compilations to end you will need a powerful machine with several cores and Gbs or RAM. Not only that, nowadays hackers usually carry out their job in laptops. As time goes by they become more powerful but still several WebKit hackers get the support of desktop computers to speed up their compilations with the help of distributed compiling tools like distcc.

My computer is a Lenovo Thinkpad X220 with a SSD hard drive, 8Gb RAM and a dual-core Intel® Core™ i7-2620M (2.7GHz, 4MB L3 cache). A clean Release build takes ~1h.

You will have to take all of this into consideration before starting to work in WebKit.

Getting the code

This is already explained in the BuildingGtk section and the instructions to use Git in UsingGitWithWebKit but, trying to give straight commands, you most probably would like to use Git as your revision control tool. WebKit actually uses SVN for its official revision control tool but tons of developers use Git and its usage is well supported.

$ git clone git://git.webkit.org/WebKit.git WebKit

As you may also want to keep track of the official SVN repository, let's do:

$ cd WebKit
$ git svn init --prefix=origin/ -T trunk http://svn.webkit.org/repository/webkit
$ git config --replace svn-remote.svn.fetch trunk:refs/remotes/origin/master
$ git svn fetch

Done! You are ready to start using the code.

Compiling

Before even starting to think in compiling we may want to be sure that we won't have to repeat the same huge effort shortly after. Hence, we would like to put into place some build speeding techniques.

Summarizing, if you are working isolated with a single computer, just start using ccache.

If you are in a network in which other computers are available to help on compiling, just start using distcc or some other distributed compiling software like icecc.

After you have your settings ready, you can just follow the instructions in BuildingGtk. Basically, you will compile and install the needed dependencies with jhbuild and will compile WebKitGTK with the default options.

There are a couple of things still to be considered:

  • Release or Debug? The default compilation will do a Release build. You may think that it may be worthy to actually do a Debug build since you are planning to start hacking and make use of gdb. However, a Debug build will take longer, more hard drive space and more RAM. In addition, running a debug build in gdb may be a pain. Because of this, most of the WebKit hackers choose to just use a Release build and make an extensive usage of printf as debugging tool. Also, there is the possibility to tweak a Release build to keep certain debugging helpers and yet not being a full Debug build.
  • In any case, don't worry too much since a Release and a Debug build can co-exist as WebKit store the resulting objects in different directories.
  • You may want to disable the compilation of unneeded pieces for if you are not working on them. For example, you can pass:
    • Disable SVG: --no-svg
    • Disable GTK doc: --disable-gtk-doc
    • Disable WebKit1: --no-webkit1
      $ Tools/Scripts/build-webkit --gtk --no-svg --disable-gtk-doc --no-webkit1
      
  • You should check all the possible flags to pass to the building script:
    $ Tools/Scripts/build-webkit --help
    

Rebuilding