Compilation process under Chrome Visual Studio 2005

  • 2020-05-05 11:50:50
  • OfStack


To study Chrome, you need to compile it first, which is a great help for subsequent code analysis and reading, and it's pretty cool to think of yourself compiling an Chrome browser to use.

The compilation environment prepares
The compilation of
Chrome is, in terms of difficulty, a comparison of solving quadratic equations with one variable versus solving partial differential equations (I haven't compiled WebKit completely yet, so take a look at myself). Although Chrome is also an evolution from WebKit, it is more or less a replacement of WebKit's JS engine with V8. Admittedly, Google makes WebKit a few orders of magnitude easier to compile.

Anyway, the official Chrome website is based on Visual Studio 2005, and there are some brothers on the Internet based on Visual Studio 2008 compiled successfully, but I do not have Visual Stdio 2008, so I do not know. This article also takes the Visual Studio2005 environment as an example. I have compiled Visual C++ 2005 Express version on my home computer, without success. It was successfully compiled on XP Professional and Vista Home operating systems.

Before downloading the Chrome code, you need to install the following software:

1.   installation Visual Studio 2005.

2.   installation Visual Studio 2005 Service Pack 1.

3.   install the hot patch Hotfix 947315.

If the operating system is Vista, you also need to install Visual Studio 2005 Service Pack 1 Update for Windows Vista.

5.   installs Windows 2008 SDK. According to the Internet, if it was Visual Studio 2008, you wouldn't need to install this.

6.   is configured with Windows 2008 SDK. In the beginning - > Program - > Microsoft Windows SDK v6.1 > Visual Studio Registration > Windows SDK Configuration Tool. Select the make current button and, with luck, it should work once. If not, there is a manual configuration help on the Chrome website for your reference.

Download the code
Google provides a one-deployment tool depot_tools for Chrome, including the ability to download code, synchronize code, upload code, and so on. The tool is written in Python and includes some Javascript scripts. Depot_tools contains an gclient tool that is the focus of our attention.

There are several ways to download code:

1. The   Chrome website provides a source code package which can be downloaded directly. But this is not the latest bag. I used this method to download, relatively fast.

2.   using SVN to download the client tool, such as TortoiseSVN client tools, SVN http is server address:. / / src chromium. org/svn/trunk/src.

3.   USES the depot_tools tool provided by google.

Download and install depot_tools.

l   sets the installation directory of depot_tools to the system directory (system Path environment variable).

l   creates a directory for Chrome code, such as d:\chrome. Directories do not contain Spaces.

From the command line, first switch the current directory to the directory of the chrome code, such as the one above (d:\chrome).

l   run gclient config http: / / src chromium. org/svn/trunk/src command. Gclient will download the svn tool and python tool, and then call svn for code synchronization.

Note: gclient downloads svn and python using the javascript implementation. If you are in an environment where proxy needs to be set, you need to modify the script.

1. Open X:\ depot _tools\bootstrap\ get_file.js file. X is your installation drive.

2. Put 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);

  }

Compile the code
If you are downloading the source code package, you need to unzip it first. This code package is double compressed. It takes me about half an hour to unpack all the code. It took me about half an hour to unpack all the code in my notebook.

After a long search on the Internet for materials related to Chrome compilation, we all reported that there are chrome.sln files in src\chrome directory. However, I searched all the codes but couldn't find this file, which made me depressed for a long time. I began to suspect that it was the version of my code. I checked Chrome's SVN directory online, and found that the latest version did not have this file either. Check out the articles on the web that are mostly from 2008 and wonder if chrome has changed, but check out chrome's website:

Building Chromium

1   Open the   chrome/chrome.sln   solution file in Visual Studio and build the solution. This can take from 25 minutes to 1 hour.

2   If you just want the Chromium browser, and none of the tests, you can speed up your build by right-clicking the   chrome   project in the solution explorer and selecting   Build . You may want to make sure this project is the   Startup   project (which will display as bold) by right-clicking it and selecting   Set as Startup Project . This will make Chromium (as opposed to some random test) build and run when you press   F5 .

Look, there doesn't seem to be an update. Finally, after browsing chrome's development group forum online, I learned that Chrome had indeed been modified, and those files in the original code.sln,.vcproj were all abandoned. GYP USES a custom set of rules for generating various project 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 content of this file is quite different from that of visual studio 2005. Nothing more than a description of the project files, compilation Settings, and so on.

The compilation steps are described below:

1.   runs the command line tool.

2.   switch to Chrome home directory (my computer is d:\chrome directory).

3.   performs gclient runhooks --force. This command will invoke the GYP tool to parse Chrome.gyp and generate individual Visual Studio2005 project files.

4.   double-click chrome/ chrome.sln to open Visual Studio 2005.

Right-click on the solution, select build solution, and the build begins. This process lasted about 2 hours in my notebook, and over an hour before CPU, it lasted 100%, so much so that I couldn't even watch the movie. The compiled file is placed in the chrome\debug directory (I compiled the debug version). After compiling the entire Debug directory, nearly 7 G items have been added. To compile Chrome, reserve at least 10 G Spaces.

Conclusion
The whole process of compiling Chrome actually took me a lot of effort, but when I looked at the compiled chrome, I felt very happy.

 


I encountered several major problems during the compilation process:

1.   has Visual Studio2005, but because of Proxy, depot_tools tool cannot be used. In order to break the limitation of proxy, a lot of efforts have been made.

      2. The organization of Chrome has changed, but it is not updated on the website. Other information on the website is based on the introduction of the old version.


Related articles: