Google的Chromium开源项目里面有很多非常值得学习的地方就不用多说了,由于自己对Chromium项目非常感兴趣,加之目前项目需要
要做一个手机浏览器性能分析library库,因此,想借鉴下Chromium项目是怎么做的,借此机会可以好好研究下Chromim。
下面是我下载和编译chrome的一个过程,简单记录下:
需要的环境 参考( 环境)
第一步:下载源码:
Google为Chromium项目提供了一个源码下载管理的工具 depot_toos
安装好后,把depot_toos 所在的路径添加到环境变量中,路径上不要带空格,切记。
1.初始化gclient的下载地址
gclient config http://src.chromium.org/svn/trunk/src
2.下载源码
gclient sync
这一步的时间比较长,中间过程经常会被打断或出现假死的情况,重新直接下面命令就OK,
gclient sync
这个命令支持断点续传。
当gclient sync命令执行完成后,会运行.gyp文件,生成Windows平台VS可以识别的项目工程vcproj
sln项目工程文件,你就可以在src/chrome目录下看到有一个chrome.sln的工程文件,如果没有说明
glcient sync命令没有执行完,重新运行。
第二步 配置及编译:
Step1: 安装vs 2010
Step2: 安装 Windows 8 SDK
Note: If you install the SDK in a path different than C:\Program Files (x86)\Windows Kits\8.0 you need to set the following following enviroment variable:
GYP_DEFINES=windows_sdk_path="path to sdk"
Step3: 安装 DirectX SDK
DirectX SDK 安装完成后,会在系统环境变量里面多一个DXSDK_DIR的环境变量出来。
配置DirectX SDK
在C:\Users\{your name}\AppData\Local\Microsoft\MSBuild\v4.0目录下面:
1)编辑Microsoft.Cpp.Win32.user.props文件
在IncludePath 和LibraryPath节点处,添加DirectX SDK相应的路径(刚开始没太注意,直接新加了IncludePath和
LibraryPath,结果编译Chromium报一大堆.h文件找不到,切记不要和我一样**了,呵呵)
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<IncludePath>$(DXSDK_DIR)\include;$(IncludePath)</IncludePath>
<LibraryPath>$(DXSDK_DIR)\lib\x86;$(LibraryPath)</LibraryPath>
</PropertyGroup>
</Project>
2)编辑Microsoft.Cpp.x64.user.props,和上面相同只是libraryPath需要把路径修改为x64
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<IncludePath>$(DXSDK_DIR)\include;$(IncludePath)</IncludePath>
<LibraryPath>$(DXSDK_DIR)\lib\x64;$(LibraryPath)</LibraryPath>
</PropertyGroup>
</Project>
Step4:编译
打开chrome/chrome.sln,找到chrome project 右键编译,第一编译失败,提示Debug目录下找不到base.lib库
于是就找到base project 右键编译,编译很顺利,在Debug目录下生成了base.lib文件,然后在返回到chrome project
重新build,在控制台输出中,提示在Debug目录生成了chrome.exe,但还是有一个failed,先不管了,好好玩下chrome。
主要参考:
http://blog.csdn.net/xt_xiaotian/article/details/5672454
http://www.cnblogs.com/cdamo/archive/2012/10/12/2720842.html
http://dev.chromium.org/developers/how-tos/build-instructions-windows