离线编译chromium 59.0.3071.104,方法适合任意版本

时间:2024-04-15 19:52:58

离线编译chromium 59.0.3071.104,方法适合任意版本
离线编译任意版本chromium
准备
修改
运行&编译
可能出现的问题及解决
离线编译任意版本chromium
没错, **离线 **且 **任意版本 ** chromium。离线还是要下载必要的代码的,但是可以分步进行,极大的提高编译成功率。

准备
chromium在墙内的git地址可以直接访问 https://github.com/chromium/chromium,
但是稳定的tag限于73以后,73以前的tag代码可以从 https://chromium.googlesource.com/chromium/src/+refs 下载指定的版本。

我以59.0.3071.104为例,下载好tar包:chromium-59.0.3071.104.tar.xz,大小500多M,直接FQ下载很稳定,或者直接下载 源码离线包

下载最新depot_tools 见 http://commondatastorage.googleapis.com/chrome-infra-docs/flat/depot_tools/docs/html/depot_tools_tutorial.html#_setting_up

安装vs2015社区版,注意必须是update3,设置好INCLUDE环境变量:

C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include;C:\Program Files (x86)\Windows Kits\10\Include\10.0.14393.0\um;C:\Program Files (x86)\Windows Kits\10\Include\10.0.14393.0\winrt;C:\Program

Files (x86)\Windows Kits\10\Include\10.0.14393.0\shared;C:\Program Files (x86)\Windows Kits\10\Include\10.0.14393.0\ucrt;C:\Program Files (x86)\Windows Kits\10\Include\10.0.14393.0
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include;C:\Program Files (x86)\Windows Kits\10\Include\10.0.14393.0\um;C:\Program Files (x86)\Windows Kits\10\Include\10.0.14393.0\winrt;C:\Program

Files (x86)\Windows Kits\10\Include\10.0.14393.0\shared;C:\Program Files (x86)\Windows Kits\10\Include\10.0.14393.0\ucrt
1
2
3
4
5
6
安装了别的版本vs的,建议完全卸载掉再安装此版本,否则后再编译链接的时候报错,甚至运行的时候出现异常。

cmd设置环境:
set GYP_GENERATORS=msvs-ninja,ninja<kdb>set GYP_GENERATORS=msvs-ninja,ninja
set GYP_DEFINES=component=shared_library
set GYP_MSVS_VERSION=2015
set DEPOT_TOOLS_WIN_TOOLCHAIN=0
set GYP_DEFINES=windows_sdk_path="C:\Program Files (x86)\Windows Kits\10" component=shared_library disable_nacl=1 enable_automation=0 enable_captive_portal_detection=0 enable_google_now=0 enable_hidpi=0

fastbuild=0 ffmpeg_branding=Chrome incremental_chrome_dll=0 proprietary_codecs=1 remoting=0
1
2
3
4
5
6
7
设置代理, 查看浏览器的代理设置,将其配置到cmd/git环境:
git config --global http.proxy http://127.0.0.1:1080
git config --global https.proxy https://127.0.0.1:1080
set HTTP_PROXY=http://127.0.0.1:1080
set HTTPS_PROXY=https://127.0.0.1:1080
netsh winhttp set proxy 127.0.0.1:1080
set NO_AUTH_BOTO_CONFIG=E:\tmp\chromium59\src\.boto
set BOTO_CONFIG=E:\tmp\chromium59\src\.boto
1
2
3
4
5
6
7
目录初始化 , 新建编译目录 例如:E:\tmp\chromium59, 把chromium-59.0.3071.104.tar.xz解压到该目录里作为src文件夹,再新建.gclient文件初始化项目(.gclient与src同级):
echo "" >.gclient, 修改.gclient文件内容:
{
"url": "https://github.com/chromium/chromium.git",
"managed": False,
"name": "src",
"deps_file": ".DEPS.git",
"custom_deps": {},
"safesync_url": "",
},
]
1
2
3
4
5
6
7
8
9
安装python2.7.9,这个版本才开始有pip支持,2.7.6没有,否则后面又是提示你安装。cmd中直接运行python和pip能成功
安装wget的windows版本,推荐把curl和gnuwin32 也安装了,过程不详述,cmd中直接运行wget和curl能成功。
验证步骤5代理是否成功: curl https://www.google.com 是否正确返回页面
修改
google的下载不能很好的在代理环境下工作(我尝试过NO_AUTH_BOTO_CONFIG 好像也不行),可以借助wget工具下载。
手动测试wget是否能FQ下载成功 https://storage.googleapis.com/syzygy-archive/builds/official/b8aa6a6d09dadd385a1afed5e71c3bb3514a4c0f/benchmark.zip
是否成功来检查环境是否安装正确。
再修改depot_tools下的download_from_google_storage.py文件 download_from_google_storage.py(已修改)下载
#增加一个方法,采用wget方式下载,注意cmd中的环境变量
#set HTTP_PROXY=http://127.0.0.1:1080
#set HTTPS_PROXY=https://127.0.0.1:1080

def download_url2(src, target):
cmd = "wget --tries=3 --timeout=60 --connect-timeout=30 --no-check-certificate --force-directories " + src + " --output-document=" + target
print "cmd:" + cmd
os.system(cmd)
1
2
3
4
5
6
7
8
把原来的下载流程注释掉,并用该方法:

download_url2(file_url, output_filename)

#code, _, err = gsutil.check_call(\'cp\', file_url, output_filename)
#if code != 0:
# out_q.put(\'%d> %s\' % (thread_num, err))
# ret_codes.put((code, err))
# continue </kbd>
1
2
3
4
5
6
7
把原来的文件检查流程也注释掉:

# Check if file exists.
file_url = \'%s/%s\' % (base_url, input_sha1_sum)
print \'Check if file exists. file_url:\' + file_url
#(code, _, err) = gsutil.check_call(\'ls\', file_url)
#if code != 0:
# if code == 404:
# out_q.put(\'%d> File %s for %s does not exist, skipping.\' % (
# thread_num, file_url, output_filename))
# ret_codes.put((1, \'File %s for %s does not exist.\' % (
# file_url, output_filename)))
# else:
# # Other error, probably auth related (bad ~/.boto, etc).
# out_q.put(\'%d> Failed to fetch file %s for %s, skipping. [Err: %s]\' % (
# thread_num, file_url, output_filename, err))
# ret_codes.put((1, \'Failed to fetch file %s for %s. [Err: %s]\' % (
# file_url, output_filename, err)))
# continue
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
再把gn://协议下载改成https://下载,具体参考我修改后的 download_from_google_storage.py 文件

修改 src/build/get_syzygy_binaries.py 文件:方法同上,增加download_url2方法,替换原来的
get_syzygy_binaries.py (已修改)下载
运行&编译
gclient runhooks
生成ninja 编译文件:
cd src
gn gen --ide=vs --filters=//chrome --args="enable_nacl=false" --no-deps out\Default
1
2
正式编译
ninja -C out\Default chrome
1
可能出现的问题及解决
在gclient runhooks这一步,如果报类似这样的错:
Error: Command \'download_from_google_storage --no_resume --no_auth -u --bucket v8-wasm-fuzzer -s src/v8/test/fuzzer/wasm.tar.gz.sha1\' returned non-zero exit status 1 in E:\tmp\chromium59
1
sha1文件找不到,直接在DEPS文件中搜索对应的,将其对应项去掉

{
\'action\': [
\'download_from_google_storage\',
\'--no_resume\',
\'--no_auth\',
\'-u\',
\'--bucket\',
\'v8-wasm-fuzzer\',
\'-s\',
\'src/v8/test/fuzzer/wasm.tar.gz.sha1\'
],
\'pattern\':
\'.\',
\'name\':
\'wasm_fuzzer\'
},
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
缺失.git目录导致的问题及解决:
Running hooks: 83% (46/55) apache_win32
________ running \'download_from_google_storage --no_resume --platform=win32 --directory --recursive --no_auth --num_threads=16 --bucket chromium-apache-win32 src/third_party/apache-win32\'
in \'E:\tmp\chromium59\'options.boto:nul
NOTICE: You have PROXY values set in your environment, but gsutil in depot_tools does not (yet) obey them.
Also, --no_auth prevents the normal BOTO_CONFIG environment variable from being used.
To use a proxy in this situation, please supply those settings in a .boto file pointed to by the NO_AUTH_BOTO_CONFIG environment var.
Running hooks: 89% (49/55) clang_format_merge_driver
________ running \'D:\Python27\python.exe src/tools/clang_format_merge_driver/install_git_hook.py\' in \'E:\tmp\chromium59\'
fatal: not in a git directory
Installing clang-format merge driver into .git/config...
Traceback (most recent call last):
File "src/tools/clang_format_merge_driver/install_git_hook.py", line 56, in <module>
File "src/tools/clang_format_merge_driver/install_git_hook.py", line 45, in main
File "D:\Python27\lib\subprocess.py", line 540, in check_call
raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command \'[\'git.bat\', \'config\', \'merge.clang-format.name\', \'clang-format merge driver\']\' returned non-zero exit status 128
Error: Command \'D:\\Python27\\python.exe src/tools/clang_format_merge_driver/install_git_hook.py\' returned non-zero exit status 1 in E:\tmp\chromium59
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
因为没有.git目录,在gclient runhooks过程中会提示如上错误,修复也简单:
修改install_git_hook.py加上’–global’选项 :


subprocess.check_call(
BuildGitCmd(\'config\', \'--global\', \'merge.clang-format.name\',
\'clang-format merge driver\'))
subprocess.check_call(
BuildGitCmd(\'config\', \'--global\', \'merge.clang-format.driver\',
\'clang_format_merge_driver %O %A %B %P\'))
subprocess.check_call(
BuildGitCmd(\'config\', \'--global\', \'merge.clang-format.recursive\', \'binary\'))
subprocess.check_call(
BuildGitCmd(\'config\', \'--global\', \'merge.clang-format.version\', str(_VERSION)))
————————————————
版权声明:本文为****博主「zweric」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.****.net/zweric/article/details/86351270