没错, **离线 **且 **任意版本 ** 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,直接下载很稳定,或者直接下载 源码离线包
下载最新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
安装了别的版本vs的,建议完全卸载掉再安装此版本,否则后再编译链接的时候报错,甚至运行的时候出现异常。
set GYP_GENERATORS=msvs-ninja,ninjaset 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
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
echo "" >.gclient
, 修改.gclient文件内容:{
"url": "https://github.com/chromium/chromium.git",
"managed": False,
"name": "src",
"deps_file": ".DEPS.git",
"custom_deps": {},
"safesync_url": "",
},
]
#增加一个方法,采用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)
把原来的下载流程注释掉,并用该方法:
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
把原来的文件检查流程也注释掉:
# 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
再把gn://协议下载改成https://下载,具体参考我修改后的 download_from_google_storage.py 文件
cd src
gn gen --ide=vs --filters=//chrome --args="enable_nacl=false" --no-deps out\Default
ninja -C out\Default chrome
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
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'
},
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
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
因为没有.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)))