Compile article
To study chrome, you have to compile it first, which is very helpful for subsequent code analysis and reading, and it's a cool thing to think about compiling a Chrome browser to use.
Compiling environment preparation
Chrome's compilation and WebKit, compared to the difficulty, is simply a two-time equation solution and partial differential equations to solve the comparison (I still do not have the complete compilation of WebKit, despise yourself). Although Chrome is also evolved from WebKit, almost is the WebKit JS engine replaced by the V8. But it has to be admitted that Google has reduced the difficulty of compiling WebKit by several orders of magnitude.
To get to the news, the Chrome Web site is compiled based on Visual Studio 2005, and there are brothers on the web that have successfully compiled on Visual Studio 2008, but I don't have visual Stdio 2008 on hand, so I don't know. This article also takes the Visual Studio2005 environment as an example. I used to compile the version of Visual C + + Express in my home computer without success. Compiled successfully on XP Professional and Vista home two operating systems.
Before downloading the chrome code, you need to install the following software:
1. Install Visual Studio 2005.
2. Install Visual Studio Service Pack 1.
3. Install hot patch Hotfix 947315.
4. If the operating system is Vista, you will also need to install Visual Studio Service Pack 1 Update for Windows Vista.
5. Install the Windows 2008 SDK. According to online parlance, if it is Visual Studio 2008, you do not need to install this.
6. Configure the Windows 2008 SDK. At the beginning-> program-> Microsoft Windows SDK v6.1 > Visual Studio registration > Windows SDK Configuration Tool. If you are lucky, you should be able to succeed at once. If not, there is a manual configuration Help on the official Chrome website, which you can refer to.
Download code
Google provides Chrome with a deployment tool depot_tools, including the ability to download code, Sync code, upload code, and more. This tool is written in Python and contains a few Javascript scripts. The depot_tools contains a gclient tool that we need to focus on.
There are several ways to download code:
1. Chrome official web provides a source code package that can be downloaded directly. But this package is not the latest package. I am using this method to download, relatively fast.
2. Use the SVN client tool to download, such as TORTOISESVN client tools, SVN server address is http://src.chromium.org/svn/trunk/src.
3. Use the Depot_tools tool provided by Google.
L Download and install Depot_tools.
L Set the Depot_tools installation directory to the system directory (System Path environment variable).
L Create a directory that holds the chrome code, such as D:\chrome. The directory does not contain spaces.
L at the command line, first switch the current directory to the directory of the Chrome code, such as above (D:\chrome).
L Run the gclient Config http://src.chromium.org/svn/trunk/src command. Gclient will download the SVN tool and the Python tool first, then call SVN for code synchronization.
Note: In Gclient, SVN and Python are used as JavaScript implementations. If you need to set up a proxy in the environment, you need to modify the script.
1. Open X:\ Depot _tools\bootstrap\win\get_file.js file. Where X is your installation letter.
2. Will line9-line22 between lines of code
try {
Xml_http = new ActiveXObject ("MSXML2. ServerXMLHTTP ");
catch (e) {
WScript.StdOut.WriteLine ("[-] XMLHTTP" + new Number (E.number). Tohex () +
": Cannot create Active-X object (" + e.description) + ").";
Wscript.Quit (1);
}
try {
Xml_http.open ("Get", url, false);
catch (e) {
WScript.StdOut.WriteLine ("[-] XMLHTTP" + new Number (E.number). Tohex () +
": Invalid URL.");
Wscript.Quit (1);
}
Modified into
try {
Xml_http = new ActiveXObject ("MSXML2. serverxmlhttp.5.0 ");
catch (e) {
WScript.StdOut.WriteLine ("[-] XMLHTTP" + new Number (E.number). Tohex () +
": Cannot create Active-X object (" + e.description) + ").";
Wscript.Quit (1);
}
try {
Xml_http.setproxy (2, Proxyip:port);
Xml_http.open ("Get", url, false);
Xml_http. Setproxycredentials (USERNAME,PWD);
catch (e) {
WScript.StdOut.WriteLine ("[-] XMLHTTP" + new Number (E.number). Tohex () +
": Invalid URL.");
Wscript.Quit (1);
}
Compiling code
If you are downloading the source code package, you need to extract first, this code packet is double compression. Estimated to put all the code down, half an hour or so, I spent nearly half an hour on my laptop to extract out, the size of all the code is 3 more G.
From the Internet search for a long time related to the chrome compilation of materials, everyone feedback in the Src\chrome directory has Chrome.sln files, directly open this sln can be compiled with Visual Studio 2005. But I searched through all the code but could not find the file, let me depressed for a long time, began to suspect that it is my code version of the problem, online view of the Chrome SVN directory, found that the latest version of this file is not. Check that the articles on the Web are basically 2008 articles and begin to wonder if Chrome has changed, but from Chrome's official web:
Building Chromium
1 Open The Chrome/chrome.sln solution file in Visual Studio and build the solution. This can take from minutes to 1 hour.
2 If You just want the Chromium browser, and none of the tests, you can speed up your builds by right-clicking the chrome Project in the Solution Explorer and selecting Build. You could want to make sure this project is the Startup project (which'll display as bold) by right-clicking it and Sele Cting Set as Startup Project. This'll make Chromium (as opposed to some random test) builds and run when you press F5.
Look, there seems to be no update. Finally, online browsing the Chrome Development Group forum, only to know that Chrome did make changes, the original code of those. sln,. vcproj files are all discarded, Google has developed a scripting tool Gyp tool, which is also written in Python 。 Gyp uses a custom set of rules for generating various engineering files. We can take a look at the Gyp file below.
{
' Includes ': [
'.. /.. /build/common.gypi ',
],
' Targets ': [
{
' Target_name ': ' Memory_watcher ',
' type ': ' Shared_library ',
' Msvs_guid ': ' 3BD81303-4E14-4559-AA69-B30C3BAB08DD ',
' Dependencies ': [
'.. /.. /base/base.gyp:base ',
],
' Defines ': [
' Build_memory_watcher ',
],
' Include_dirs ': [
'.. /..',
],
' Sources ': [
' call_stack.cc ',
' Call_stack.h ',
' dllmain.cc ',
' Hotkey.h ',
' ia32_modrm_map.cc ',
' ia32_opcode_map.cc ',
' memory_hook.cc ',
' Memory_hook.h ',
' memory_watcher.cc ',
' Memory_watcher.h ',
' mini_disassembler.cc ',
' preamble_patcher.cc ',
' Preamble_patcher.h ',
' preamble_patcher_with_stub.cc ',
],
},
],
}
In fact, the contents of this file and the. vcproj file in Visual Studio 2005 are quite different, but the description doesn't change much, it's simpler and more concise. Nothing more than the description of the project file, compile settings and so on.
The following is a description of the compilation steps:
1. Run the command line tool.
2. Switch to the Chrome home directory (My computer is the D:\chrome directory).
3. Implementation of Gclient Runhooks--force. This command will invoke the Gyp tool, parse the CHROME.GYP, and generate the various Visual Studio2005 engineering files.
4. Double-click the Chrome/chrome.sln file to open Visual Studio 2005, a total of 215 projects, very large.
Right-click the solution, select the build Solution, and the compilation begins. This process in my notebook is 2 hours or so, the CPU before one hours are continuous 100%, so I even see the film is not a good card. The compiled file is placed under the Chrome\debug directory (I compile the debug version). The entire compilation down, the Debug directory adds nearly 7 G's Dongdong, is really the horror! To compile Chrome, you need to retain at least 10 G of space.
Summarize
The whole process of compiling the chrome actually took me a lot of effort, but looking at the compiled chrome, the heart is still very happy.
Some of the main problems I have encountered during my compilation are:
1. The company has visual Studio2005, but because of proxy reasons, Depot_tools tools can not be carried out, in order to break the restrictions of proxy, spent a lot of effort.
2. The structure of the chrome project has changed, but there is no update on the official web site, other information on the Internet is based on the old version of the introduction, so in adapting to the new Gyp way to spend a lot of effort.