记录在win10编译crashpad过程。
编译环境
参考网址 官方推荐使用depot_toos下载源码,因此本文使用depot_tools下载拉去crashpad源码。
设置代理
因为crashpad源码在外网上,默认不能访问,因此需要配置一个代理。
打开window控制台,设置代理信息
1 2 3
| @echo off set HTTP_PROXY=http://127.0.0.1:8293 set HTTPS_PROXY=http://127.0.0.1:8293
|
下载depot_tools压缩包, 或者使用git clone下来 git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git
然后配置环境变量, 添加depot_tools目录到环境变量path中
安装window 10 sdk
编译crashpad在window上需要window sdk, 当前在win10上编译crashpad需要最新window sdk版本为10.0.20348.0, 下载网址,下载完成安装。
下载crashpd源码
打开控制台,进入指定目录创建crashpd目录,然后进入crashpd目录后执行fetch crashpd获取crashpd源码
1 2 3 4
| cd c:\home mkdir crashpd cd crashpd fetch crashpd
|
编译步骤
打开控制台,进入crashpd目录,使用gn生成编译文件
1 2
| chcp 65001 cd c:\home\crashpd\crashpd
|
编译32位crashpd程序
通过gn生成编译环境后需要修改对应目录下的args.gn文件,修改对应的target_cpu类型(x86)
编译debug版
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
| gn args out/x86.debug
======================= target_cpu="x86" is_debug=true =======================
修改toolchain.ninja文件 修改rule cxx、rule cc规则 增加/WX-参数 rule cxx command = ninja -t msvc -e environment.x86 -- cl.exe /nologo /showIncludes ${defines} ${include_dirs} ${cflags} ${cflags_cc} /WX- /c ${in} /Fo${out} /Fd"${target_out_dir}/${label_name}_cc.pdb" description = CXX ${out} deps = msvc rule cc command = ninja -t msvc -e environment.x86 -- cl.exe /nologo /showIncludes ${defines} ${include_dirs} ${cflags} ${cflags_c} /WX- /c ${in} /Fo${out} /Fd"${target_out_dir}/${label_name}_c.pdb" description = CC ${out} deps = msvc
ninja -C out\x86.debug
|
编译release版
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
| gn args out/x86.release
======================= target_cpu="x86" is_debug=false =======================
修改toolchain.ninja文件 修改rule cxx、rule cc规则 增加/WX-参数 rule cxx command = ninja -t msvc -e environment.x86 -- cl.exe /nologo /showIncludes ${defines} ${include_dirs} ${cflags} ${cflags_cc} /WX- /c ${in} /Fo${out} /Fd"${target_out_dir}/${label_name}_cc.pdb" description = CXX ${out} deps = msvc rule cc command = ninja -t msvc -e environment.x86 -- cl.exe /nologo /showIncludes ${defines} ${include_dirs} ${cflags} ${cflags_c} /WX- /c ${in} /Fo${out} /Fd"${target_out_dir}/${label_name}_c.pdb" description = CC ${out} deps = msvc ninja -C out\x86.release
|
编译64位crashpd程序
编译debug版
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
| gn args out/x64.debug
======================= target_cpu="x64" is_debug=true =======================
修改toolchain.ninja文件 修改rule cxx、rule cc规则 增加/WX-参数 rule cxx command = ninja -t msvc -e environment.x86 -- cl.exe /nologo /showIncludes ${defines} ${include_dirs} ${cflags} ${cflags_cc} /WX- /c ${in} /Fo${out} /Fd"${target_out_dir}/${label_name}_cc.pdb" description = CXX ${out} deps = msvc rule cc command = ninja -t msvc -e environment.x86 -- cl.exe /nologo /showIncludes ${defines} ${include_dirs} ${cflags} ${cflags_c} /WX- /c ${in} /Fo${out} /Fd"${target_out_dir}/${label_name}_c.pdb" description = CC ${out} deps = msvc
ninja -C out\x64.debug
|
编译release版
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
| gn args out/x64.release
======================= target_cpu="x64" is_debug=false =======================
修改toolchain.ninja文件 修改rule cxx、rule cc规则 增加/WX-参数 rule cxx command = ninja -t msvc -e environment.x86 -- cl.exe /nologo /showIncludes ${defines} ${include_dirs} ${cflags} ${cflags_cc} /WX- /c ${in} /Fo${out} /Fd"${target_out_dir}/${label_name}_cc.pdb" description = CXX ${out} deps = msvc rule cc command = ninja -t msvc -e environment.x86 -- cl.exe /nologo /showIncludes ${defines} ${include_dirs} ${cflags} ${cflags_c} /WX- /c ${in} /Fo${out} /Fd"${target_out_dir}/${label_name}_c.pdb" description = CC ${out} deps = msvc
ninja -C out\x64.release
|