学习开源项目chromium之在windows下下载chromium代码并生成vs项目的sln文件
首先,参考官方的下载说明链接
#1 VS的要求:”Visual Studio Community Edition should work if its license is appropriate for you. You must install the “Desktop development with C++” component and the “MFC/ATL support” sub-components. “
因此,VS2019的社区版即可满足要求,不需要专业版及其以上的版本即可编译。仅需要在使用vs installer安装的时候勾选上使用C++进行桌面开发及其MFC的支持的子选项即可。
#2 Install depot_tools,即下载depot_tools,下载链接
“Add depot_tools to the start of your PATH (must be ahead of any installs of Python). Assuming you unzipped the bundle to C:\src\depot_tools, open:
Control Panel → System and Security → System → Advanced system settings”
添加depot_tools的解压路径至环境变量,例如解压的路径为C:\src\depot_tools,那么就在path里面添加即可。然后添加系统变量,其名为DEPOT_TOOLS_WIN_TOOLCHAIN并将值设定为0。
#3 打开CMD.exe,执行命令gclient
我的话,是在解压depot_tools的文件夹内,直接按住shift再按住右键,开启power shell窗口,执行gclient的命令,无任何参数。
#4 修改GIT的设置文件,在你文件的解压目录下有个git文件夹,里面有个config文件,用记事本打开,更改设置如下
之后保存即可(name和email改成自己的)。
#5 打开cmd,cd到你的depot_tools的安装目录,输入mkdir chromium && cd chromium
创建文件夹并cd。
然后fetch chromium
,静静等待即可。
(有条件的话建议挂梯子,因为源代码实在很大,有差不多21GB的内容。)
#6 “When fetch completes, it will have created a hidden .gclient file and a directory called src in the working directory. The remaining instructions assume you have switched to the src directory”
当下载完成后,会创建一个隐藏的.gclient的文件和一个src文件夹。
于是继续在当前cmd窗口输入cd src
,然后用gn gen out/Default
创立构建目录,对于每个新的构建目录,该命令仅需要运行一次。
然后gn gen --ide=vs out\Default
devenv out\Default\all.sln
即可输出VS项目文件。
VS文件位于构建目录下,即你的depot_tools文件目录的/chromium/src/build文件夹里面。
#7 参考链接:
Chromium官方指导链接