Someone recently failed to compile WebKit in Windows 7 and asked me how to solve it. I have read it, mainly svganimationelement. files such as CPP cannot be compiled. Some enumeration variables after SVG is enabled are used, but WebKit generates webkitbuild/include/WebCore/csspropertynames during compilation. the H file does not generate these enumeration variables. I checked some compilation options and configured them all as OK. I checked the WebKit compilation rules and found csspropertynames. the generation of H depends on csspropertynames. in. The solution is also simple: add a line to the files such as csspropertynames. In and delete it, And then compile it. Why? The willingness to compile makefile in windows is not as reliable as that in Linux. Sometimes the makefile tool in Windows updates the file modification time when the compilation fails, as a result, the next makefile re-check considers that the file has not changed and thus jumps over. The csspropertynames mentioned above. this is the case with in. I wrote some webki compilation articles in my blog. There are some similar articles on the Internet, and many netizens post and ask when WebKit compilation is not outdated, therefore, I think many people are not very clear about how WebKit is compiled. As a result, they do not know the cause of compilation errors, and naturally do not know how to solve this problem. Over time, more and more people will find that compiling WebKit is a problem, let alone studying WebKit. To help these people overcome their fear of WebKit compilation, I have read in detail the compilation rules of WebKit in Windows over the past few days and written this article similar to the summary.
1. Directory Division
Compile is mainly used in the cmake environment, which is a cross-platform compiling environment, but I found that there are not many people using cmake in windows, this may be mainly because the official WebKit website introduced the cgywin + vs compilation method. WebKit. pro is the compilation rule in the QT environment. QT sets a set of compilation rules and makes a tool similar to makefile qmake, which is cross-platform, however, the next QT compilation environment or SDK is required, so this is mainly maintained by QT, but the development of QT WebKit is still good; android. MK is the compilation rule of WebKit in Android. The Windows compilation rules described in this document are not included in the root directory, but are implemented in the subdirectories below, probably because the rules (cygwin + vs) are only applicable to Windows platforms, it is not a common thing, so it cannot be placed in the root directory. The cygwin + vs environment is mainly maintained by Apple. the Windows version of safari should also be compiled using this environment. By the way, Chrome's compilation rules are suffixed with gypi, for example, The WebCore. gypi file under the WebCore directory.
WebKit consists of javascriptcore, WebCore, and WebKit. Javascriptcore is mainly the JavaScript engine code used by the browser. When the V8 engine is used, this directory does not participate in compilation. The Code under WebCore is the core of the browser, including web page parsing, layout, render, etc. Dom and CSS specifications are also implemented here. If you know how window objects in the browser are implemented, you can go to WebCore/DOM to see them, in WebCore, platform-related files have different directories for different platforms, and compilation dependencies are different. in WebKit, the implementation code of interfaces provided to the browser shell is used. Finally, javascriptcore is compiled into javascriptcore. dll, and The WebCore and WebKit directories are compiled into WebKit. dll. Using javascriptcore. dll as DLL plugin. If you compare the WebKit directory implementation on Mac and windows, you will find thatThe concepts of Object-C and COM are similar in many aspects,Object-CAt the language level, it simplifies some complex implementations of the Com idea.
In other WebKit directories, compilation-related directories include webkitlibraries and webkittools. And decompress it to the webkitlibraries directory. The webkittools mainly contains some tools and examples, and the compilation-related mainly contains the webkittools/scripts directory, for example, both update-WebKit and build-WebKit are placed under this directory, with most Perl scripts and BAT (CMD) and Py being the minority. This multi-language mixing is very common in the compiling environment. From this, we can learn that we use the most suitable tool and language to do what you want to do, there is no need to compete for good or bad people. Every tool and language has its own advantages and weaknesses. Tools are always tools, and there are always time and places to be eliminated. What we really need to pay attention to is our goal.
Compile is compiled in the command line, but more people will use vs IDE for compilation later, because it is more intuitive and familiar. When vs ide has a problem that it occupies a bit of memory, its Smart prompts will often scan files, resulting in a high CPU usage. In the end, it intelligently prompts that the generated NCB file is also very large, however, one advantage of this is that it is better to find the corresponding function implementation during debugging (If your machine is strong enough, install visualAssist x plug-inBetter ). The location of the vs project in each directory is as follows:
Javascriptcore: D:/tools/cygwin/home/xufan/WebKit/javascriptcore. vcproj/javascriptcore. vcproj, D:/tools/cygwin/home/xufan/WebKit/javascriptcore. vcproj/WTF. vcproj, etc.
WebCore: D:/tools/cygwin/home/xufan/WebKit/WebCore. vcproj WebCore. vcproj, etc.
WebKit: D:/tools/cygwin/home/xufan/WebKit/win/WebKit. vcproj under WebKit. vcproj, etc.
The entire WebKit solution file is D:/tools/cygwin/home/xufan/WebKit/win/WebKit. vcproj/WebKit. sln. You can double-click it to open it with vs IDE.
Below we will pick out some representative compilation rules from the WebKit directory for discussion:
2. webkittools/scripts directory
First, start with the update-WebKit script. This script mainly calls SVN commit (92 rows) and decompress it to the webkitlibraries directory (96 rows, 116 rows ).
Next, let's look at the build-WebKit script. The first 344 lines of the Build-WebKit script mainly convert command line parameters to variables in Perl, lines 289 to 315 can see the parameters supported by build-WebKit:
Usage: $ programname [Options] [Options to pass to build system]
-- Help show this help message
-- Clean cleanup the build directory
-- Debug compile in debug mode
-- Wincairo build using Cairo (rather than CoreGraphics) on Windows
-- Chromium build the chromium port on MAC/win/Linux
-- GTK build the GTK + Port
-- QT build the QT Port
-- EFL build the EFL Port
-- Inspector-frontend copy changes to the Inspector front-end files to the build directory
-- Install-headers = set installation path for the headers (QT only)
-- Install-libs = set installation path for the libraries (QT only)
-- V8 use V8 as JavaScript Engine (QT only)
-- Prefix = set installation prefix to the given path (GTK/EFL only)
-- Makeargs = optional makefile flags
-- Minimal no optional features, unless explicitly enabled.
Many of the subsequent functions called by build-WebKit are in webkitdirs. (build-WebKit's 40th line: Use webkitdirs) defined in PM, such as productdir (). This is the directory of WebKit output results. From the implementation of productdir, the output directory is mainly determined by the Environment Variable webkitoutputdir (webkitdirs. if the root directory does not exist, use the webkitbuild directory (row 119: $ baseproductdir = "$ sourcedir/webkitbuild ";). From 360 rows to 500 rows, some checks are performed. The compilation starts from 500 rows to 551 rows, as shown below:
# Build, and abort if the build fails. <br/> for my $ Dir (@ projects) {<br/> chdir $ DIR or die; <br/> my $ result = 0; <br/> # For GTK and QT the WebKit project builds all others <br/> If (isgtk () | isqt () & $ dir ne "WebKit ") {<br/> chdir ".. "Or die; <br/> next; <br/>}< br/> If (isgtk () {<br/> $ result = buildgtkproject ($ Dir, $ clean, @ options); <br/>} elsif (isqt () {<br/> $ result = buildqmakeqtproject ($ Dir, $ clean, @ options ); <br/>} elsif (isapplemacwebkit () {<br/> $ dir = "minibrowser" If $ dir EQ "webkittools/minibroeq "; <br/> my @ local_options = @ options; <br/> push @ local_options, xcodecoveragesupportoptions () If $ coveragesupport & $ dir ne "angle "; <br/> $ result = buildxcodeproject ($ Dir, $ clean, @ local_options, @ argv); <br/>} elsif (isapplewinwebkit ()) {<br/> if ($ dir EQ "WebKit") {<br/> $ result = buildvisualstudioproject ("Win/WebKit. vcproj/WebKit. sln ", $ clean); <br/>}< br/> # various build * callabve may change the cwd. <br/> chdirwebkit (); <br/> If (exitstatus ($ result) {<br/> my $ scriptdir = relativescriptsdir (); <br/> If (usingvisualstudioexpress () {<br/> # Visual Studio Express is so lame it can't stdout build failures. <br/> # So we find its logs and dump them to the console ourselves. <br/> System (File: spec-> catfile ($ scriptdir, "Print-VSE-failure-Logs ")); <br/>}< br/> If (isapplewinwebkit ()) {<br/> Print "/n ==== build failed =======/n "; <br/> Print "Please ensure you have run $ scriptdir/update-WebKit to install dependencies. /n "; <br/> my $ baseproductdir = baseproductdir (); <br/> Print" you can view build errors by checking the buildlog.htm files located: /N $ baseproductdir/obj //. /n "; <br/>}< br/> exit exitstatus ($ result); <br/>}< br/>}
In the cygwin + vs environment, buildvisualstudioproject ("Win/WebKit. vcproj/WebKit. sln ", $ clean), buildvisualstudioproject code is as follows (in webkitdirs. 1205 rows of PM ):
Sub buildvisualstudioproject <br/>{< br/> my ($ project, $ clean) =@_; <br/> setupcygwinenv (); <br/> my $ Config = configurationforvisualstudio (); <br/> dieifwindowsplatformsdknotinstalled () If $ willusevcexpresswhenbuilding; <br/> chomp ($ project = 'cygpath-W "$ project" ') If iscygwin (); <br/> my $ action = "/build "; <br/> if ($ clean) {<br/> $ action = "/clean"; <br/>}< br/> my @ command = ($ vcbuildpath, $ project, $ action, $ config); <br/> Print join ("", @ command), "/N"; <br/> return system @ command; <br/>}
Setupcygwinenv mainly finds the installation location of vs through environment variables, and then calls the pdevenv script (line 1) to call different scripts to set the vs compiling environment according to the vs version. Vsvars32.bat and devenv.com should be familiar to everyone (if you do not know, you can refer to the Visual Studio 2005 command prompt shortcut in the Start Menu). Calling them is done in the pdevenv script.
The expanded vs script can be called to view cygwin command line output (see my @ command = ($ vcbuildpath, $ project, $ action, $ config ); and the line below), my side is:
/Home/xufan/WebKit/webkittools/scripts/pdevenv win/WebKit. vcproj/WebKit. sln/build debug_cairo_cflite
After devenv.exe is called, the compiling rules are completely vs rules. The portal is WebKit/win/WebKit. vcproj/WebKit. SLN, the more important project is the javascriptcore mentioned above. vcproj, WebCore. vcproj and WebKit. vcproj.
Today we will first go here, and tomorrow we will write these more important vs projects, including js dom objects (such as window objects) glue) how is the code to javascriptcore automatically generated? If the code is generated based on the CSS keyword, the compilation sequence and rules of the files under WebCore.