当前位置:   article > 正文

Windows下编译Chromium_windows编译chromium

windows编译chromium

一、系统要求
1、Windows 7或更新的64位系统,至少有8GB内存,强烈推荐超过16GB;
2、源码必须存放在NTFS格式的驱动器上,至少有100GB的空闲磁盘空间;
3、安装合适版本的Visual Studio

二、配置Visual Studio
。截止到2017年9月(R503915),Chromium需要Visual Studio 2017 (15.7.2)编译。必须安装“桌面开发用C++”组件和“MFC和ATL支持”的子组件。

三、代理设置(如有需要)
1、Git代理设置;

  1. git config --global https.proxy socks5://localhost:1080
  2. git config --global core.proxy socks5://localhost:1080
  3. git config --global http.proxy socks5://localhost:1080
  4. git config --global http.sslVerify false

Git取消代理;

  1. git config --global --unset http.proxy
  2. git config --global --unset httpx.proxy
  3. git config --global --unset core.proxy

2、Python代理设置;

  1. set http_proxy=http://localhost:1080
  2. set https_proxy=https://localhost:1080

建议购置阿里云Windows香港服务器,同步好代码之后直接打包下载。
 

四、安装配置depot_tools

下载depot_tools压缩包https://src.chromium.org/svn/trunk/tools/depot_tools.zip解压, 把depot_tools设置为环境变量, 并且设置环境变量DEPOT_TOOLS_WIN_TOOLCHAIN的值为0;

 

五、源码下载

1、创建一个chromium目录存放源码(可以在任何地方,只要路径是英文且没空格就行);

mkdir chromium && cd chromium

2、运行depot_tools检查依赖项与检出源码;

fetch chromium

如果不需要历史记录可以添加参数--no-history

fetch chromium --no-history

当fetch完成,会在工作目录创建src目录与一个隐藏的文件.gclient。

六、编译

  1. set CEF_USE_GN=0
  2. set GYP_DEFINES=buildtype=Official proprietary_codecs=1 ffmpeg_branding=Chrome
  3. set GYP_GENERATORS=ninja,msvs-ninja
  4. set GYP_MSVS_VERSION=2015
  5. set CEF_ARCHIVE_FORMAT=tar.bz2
  6. set DEPOT_TOOLS_WIN_TOOLCHAIN=0
  7. cd src
  8. gn gen --ide=vs out\Default
  9. devenv out\Default\all.sln

 

7、问题

(1)使用代理的情况下,gclient runhooks下载gs://xxx出错,设置 .boto内容

  1. [Boto]
  2. proxy = 127.0.0.1
  3. proxy_port = 1080

执行命令

set NO_AUTH_BOTO_CONFIG=E:\Working\ChromiumSrc\.boto

 
(2)、直接使用国外Windows服务器情况下,gclient runhooks下载gs://xxx出错,

错误1:download_from_google_storage src\buildtools\win\gn.exe.sha1 returned non-zero exit

处理:

修改文件depot_tools\download_from_google_storage.py,增加

import urllib

增加函数

  1. def download_url(src, target):
  2. """ the contents of src, which may be a URL or local file, to the
  3. target directory. """
  4. if src[:4] == 'http':
  5. # Attempt to download a URL.
  6. opener = urllib.FancyURLopener({})
  7. response = opener.open(src)
  8. CHUNK = 16 * 1024
  9. with open(target, 'wb') as f:
  10. while True:
  11. chunk = response.read(CHUNK)
  12. if not chunk:
  13. break
  14. f.write(chunk)
  15. else:
  16. raise Exception('Path type is unsupported or does not exist: ' + src)

查找# Check if file exists,如下注释部分代码,如:

  1. # Check if file exists.
  2. file_url = '%s/%s' % (base_url, input_sha1_sum)
  3. #(code, _, err) = gsutil.check_call('ls', file_url)
  4. #if code != 0:
  5. # if code == 404:
  6. # out_q.put('%d> File %s for %s does not exist, skipping.' % (
  7. # thread_num, file_url, output_filename))
  8. # ret_codes.put((1, 'File %s for %s does not exist.' % (
  9. # file_url, output_filename)))
  10. # else:
  11. # # Other error, probably auth related (bad ~/.boto, etc).
  12. # out_q.put('%d> Failed to fetch file %s for %s, skipping. [Err: %s]' % (
  13. # thread_num, file_url, output_filename, err))
  14. # ret_codes.put((1, 'Failed to fetch file %s for %s. [Err: %s]' % (
  15. # file_url, output_filename, err)))
  16. # continue

查找# Fetch the file,如下注释部分代码,如:

  1. # Fetch the file.
  2. out_q.put('%d> Downloading %s...' % (thread_num, output_filename))
  3. try:
  4. if delete:
  5. os.remove(output_filename) # Delete the file if it exists already.
  6. except OSError:
  7. if os.path.exists(output_filename):
  8. out_q.put('%d> Warning: deleting %s failed.' % (
  9. thread_num, output_filename))
  10. #code, _, err = gsutil.check_call('cp', file_url, output_filename)
  11. #if code != 0:
  12. # out_q.put('%d> %s' % (thread_num, err))
  13. # ret_codes.put((code, err))
  14. # continue
  15. download_url(file_url, output_filename)


错误2:src\build\get_syzygy_binaries.py
处理:
修改文件chromium\src\build\get_syzygy_binaries.py,增加

import urllib

增加函数

  1. def download_url(src, target):
  2. """ the contents of src, which may be a URL or local file, to the
  3. target directory. """
  4. if src[:4] == 'http':
  5. # Attempt to download a URL.
  6. opener = urllib.FancyURLopener({})
  7. response = opener.open(src)
  8. CHUNK = 16 * 1024
  9. with open(target, 'wb') as f:
  10. while True:
  11. chunk = response.read(CHUNK)
  12. if not chunk:
  13. break
  14. f.write(chunk)
  15. else:
  16. raise Exception('Path type is unsupported or does not exist: ' + src)

将函数 _Download修改为

  1. def _Download(resource):
  2. """Downloads the given GS resource to a temporary file, returning its path."""
  3. tmp = tempfile.mkstemp(suffix='syzygy_archive')
  4. os.close(tmp[0])
  5. tmp_file = tmp[1]
  6. url = 'gs://syzygy-archive' + resource
  7. if sys.platform == 'cygwin':
  8. # Change temporary path to Windows path for gsutil
  9. def winpath(path):
  10. return subprocess.check_output(['cygpath', '-w', path]).strip()
  11. tmp_file = winpath(tmp_file)
  12. #_GsUtil('cp', url, tmp_file)
  13. url=url.replace("gs://","https://storage.googleapis.com/")
  14. download_url(url,tmp_file)
  15. return tmp[1]

参考:

https://www.jianshu.com/p/08aa03e8ce18

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/我家自动化/article/detail/882269
推荐阅读
相关标签
  

闽ICP备14008679号