離線編譯chromium 59.0.3071.104,方法适合任意版本
離線編譯任意版本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
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
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
目錄初始化 , 建立編譯目錄 例如: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": "",
},
]
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)
把原來的下載下傳流程注釋掉,并用該方法:
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>
把原來的檔案檢查流程也注釋掉:
# 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
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
正式編譯
ninja -C out\Default chrome
在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
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'
},
缺失.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
因為沒有.git目錄,在gclient runhooks過程中會提示如上錯誤,修複也簡單:
修改install_git_hook.py加上’–global’選項 :
subprocess.check_call(
BuildGitCmd('config', '--global', 'merge.clang-format.name',
'clang-format merge driver'))
BuildGitCmd('config', '--global', 'merge.clang-format.driver',
'clang_format_merge_driver %O %A %B %P'))
BuildGitCmd('config', '--global', 'merge.clang-format.recursive', 'binary'))
BuildGitCmd('config', '--global', 'merge.clang-format.version', str(_VERSION)))