Summary of WebKit compiling on Windows platform

WebKit is recognized as an excellent open source browser kernel in the world. It has the advantages of fast rendering speed, flexible customization and multi platform support. Both Maxthon and UCWEB choose WebKit as the browser kernel. Google and apple have only made Chrome browser and safari browser based on WebKit respectively.

Although WebKit has been accepted by more and more programmers, its compiling process is very painful. Now I will share my experience in compiling WebKit code with you.

1) get WebKit source code

WebKit source code is managed by subversion tool. Therefore, as long as you have a subversion client, you can http://svn.webkit.org/repository/webkit/trunk Get the source code. But that’s not the best way. In the actual compilation process, the code obtained through SVN may bring you a lot of trouble. Therefore, I recommend downloading WebKit source code package directly from night build of WebKit. The specific address is: http://nightly.webkit.org/builds/trunk/src/1 It’s amazing that a project as big as WebKit still follows the principles of daily build.

WebKit source code at the time of writing this article, the version is r52221, but I haven’t compiled this version of WebKit successfully in the last two days. The reason is that visual studio 2005 stops responding a few minutes after opening a project with Visual Studio 2005. I’ve tested r50006, the first version with 5 prefix, and I don’t have this problem. The larger the version number, the newer the source code, and vice versa.

2) building WebKit compilation environment

There is an article on WebKit website to explain the environment construction of WebKit on Windows platform http://webkit.org/building/tools.html But this article is too simple. This is where WebKit is most destructive. After more than ten failures, I finally found a shortcut to my goal.

Hardware

It’s better to find a computer with memory larger than 2G. Because the WebKit project is too large, it will generate hundreds of. Obj files. When performing a link operation, the memory requirement is about 1.6g. If you have a memory eating operating system like Vista installed on your machine, wait and see link.exe Let me tell you something about “out of memory.”. The memory of the machine that I installed vista is only 2G, and I failed to link it several times. Finally, I was forced to compile in safe mode (I didn’t even dare to load the NIC driver). Finally, when the memory peak reached 1.99g, I got through the danger. It’s really exciting, it’s exciting.

Of course, the larger the hard disk, the better, because after the WebKit source code is expanded, it needs 160m-190m disk space, and the intermediate files generated during the compilation process need about 4G storage space. In addition to the disk space occupied by cygwin visual studio, these are quite large. The most important thing is that the system disk had better reserve about 4G space.

In fact, the use of multi-core CPU is also good for compiling WebKit. The compiling script can be called in parallel at the same time cl.exe Compiling WebKit greatly shortens the compilation time.

software

First, you need to install Visual Studio 2005 Sp1. If it’s Vista or window 7, you need to install SP1 update for vista. Visual C + + 2005 express can also compile WebKit, but the Platform SDK needs to be installed separately. Practice has proved that WebKit can be compiled on platform 5.0 6.0.

This will also lead to a problem. What if you have installed Visual Studio 2008 on your machine?Don’t worry, Visual Studio 2005 and Visual Studio 2008 can coexist, and Visual Studio 2005 can be installed after Viusal Studio 2008. However, it should be noted that when visual studio 2005 is installed after visual studio 2008, the Perl script of WebKit will only go to the bin folder of VC (that is, the cl.exe Folder). If the VS 2005 you installed is not on the system disk, you need to copy the bin folder of VC to the directory on the system disk.

After installing Visual Studio 2005, you need to install another big cygwin. Cygwin actually simulates a UNIX Environment on windows. To install cygwin, it’s better not to use the instructions given on the cygwin website directly setup.exe Documents. It’s about using WebKit.org The cygwin downloader tool is provided on the website. Cygwin downloader will download 101 tools (maybe a few more now) needed to compile WebKit, such as Perl, zlib, bash, etc. After downloading, run cygwin installation tool Setup.exe Select Install from local directory. Please note that! Cygwin should be installed in the partition of the system disk. If Disk C is the system disk, cygwin must be installed in C:: (cygwin). After the installation, it will occupy several hundred megabytes of space.

Next, you still need to install QuickTime SDK. It is said that QuickTime SDK can not be installed, but I find that qtmovie project in WebKit solution cannot be compiled successfully if it is not installed. QuickTime must be installed on the system disk: program files, quciktime SDK. Do not change the installation path.

Finally, after decompressing the WebKit source code file, you need to webKit.org Site download WebKitSupportLibrary.zip This file is a pre compiled version of some third-party libraries on Windows platform. For WebKit links. After downloading, the zip file does not need to be unzipped and can be directly placed in the root directory of WebKit.

compilation steps

1) setting environment variables. Set WebKit library dir as the path of WebKit source code directory, WebKit libraries and win, and set WebKit output putdir as the output folder where you want to store obj and DLL. Of course, the partition where the folder is located should have at least 4G free space.

2) execute the update script. Please run the command line window of cygwin on the desktop, and then jump to the WebKit source code directory, WebKit tools and scripts folder through the CD command (the same as the DOS CD command). For example, my WebKit source code is on disk F, which is CD f/WebKit/WebKit tools/scripts/run the two scripts update WebKit and update WebKit support LIBS in this directory. Many blogs don’t mention this step. In fact, this step is the key to successful compilation.

3) after successfully performing the above two steps, you can use Visual Studio 2005 to open the WebKit source code directory located in the\ WebKit.vcproj \Under the directory WebKit.sln It’s a solution. By default, this SLN has six compilation configurations, debug and debug_ all、Debug_ Cairo、Release、Debug_ Internal、Release_ Cairo。 The version compiled with release uses Apple’s own rendering engine, which is consistent with safari. Use release_ What Cairo compiles is a version that supports the Cairo rendering engine. This version can run independently from Apple’s environment, but it can’t run in Apple’s Safari environment at the same time. To monitor the compilation success, use WinLauncher.exe The application loads WebKit for testing.

I’ll write here first, and then I’ll think of something to add.

Author: Michael Lee

Similar Posts: