Ubuntu下Chromium代码下载和环境配置

2018-01-10  本文已影响0人  风轻云淡宇
1.下载配置depot_tools

通过以下链接

$ git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git

下载depot_tools压缩包,解压,并将其目录添加到环境变量中,比如我的将depot_tools解压在 ~/chromium_linux文件下,在 ~/.bashrc文件最后添加了:

export:PATH=$PATH:~/chromium_linux/depot_tools

配置好后记得重启终端,或者执行下面命令加载~/.bashrc中环境变量:

$source ~/.bashrc

2.代理配置

export http_proxy=ip:port
export https_proxy=ip:port

比如我的是:

export http_proxy=192.168.0.149:10808
export https_proxy=192.168.0.149:10808

也可添加到配置文件中,但记得设置代理的ip和端口号,不然会出现类似如下错误:

fatal: unable to access 'https://chromium.googlesource.com/chromium/src.git/': Failed to connect to chromium.googlesource.com port 443: Connection timed out

3.代码下载

我的代码准备放在~/chromium_linux目录下,所以现在终端进入chromium_linux目录

$cd ~/chromium_linux

然后运行命令:

$fetch --nohook chromium

显示如下效果:

B85M-D3H:~/chromium_linux$ fetch --nohooks chromium
Running: gclient root
Running: gclient config --spec 'solutions = [
  {
    "url": "https://chromium.googlesource.com/chromium/src.git",
    "managed": False,
    "name": "src",
    "deps_file": ".DEPS.git",
    "custom_deps": {},
  },
]
'
Running: gclient sync --nohooks

这里会创建一个.gclient文件,并自动开始下载代码,如果中断,可运行命令:

$gclient sync --force

继续下载,下载过程时间较长,我的下了3个多小时。

4.切换到特定分支

可参考以下链接:
http://blog.csdn.net/bbmjja0000/article/details/45870891

git fetch --tags

# 根据63.0.3239.132版本建立一个你自己的分支
git checkout -b your_release_branch     63.0.3239.132

// 同步所有相关工程代码
gclient sync --with_branch_heads --jobs 16

如果出现如下错误:

$ gn gen out/Default
ERROR at //third_party/angle/BUILD.gn:674:13: Script returned non-zero exit code.
util_gypi = exec_script("//build/gypi_to_gn.py",
            ^----------
Current dir: /home/android/chromium_linux/src/out/Default/
Command: python -- /home/android/chromium_linux/src/build/gypi_to_gn.py /home/android/chromium_linux/src/third_party/angle/util/util.gyp
Returned 1 and printed out:

Attempting to recursively print a dictionary.

See //BUILD.gn:666:7: which caused the file to be included.
      "//third_party/angle:libANGLE",
      ^-----------------------------

记得要执行:

gclient sync --with_branch_heads --jobs 16

不然gclient runhook也会报错。

5.Install additional build dependencies

进入src目录,执行

$ build/install-build-deps.sh

6.然后执行gclient runhook从Google上下载一些东西

过程有遇到:

Running hooks:   7% ( 4/53) nacltools
________ running 'vpython src/build/download_nacl_toolchains.py --mode nacl_core_sdk sync --extract' in '/home/test/chromium_linux'
INFO: --Syncing nacl_arm_glibc to revision 053185d68ed3b96640f15c4ae457b1ff373c6cac--
INFO: Downloading package archive: binutils_arm_x86_64_linux.tgz (1/6)
package_version: Could not download URL (https://storage.googleapis.com/nativeclient-once/object/binutils_arm_x86_64_linux_475b45f35de7eb128a94a1ff45c84700ce39498b.tgz): <urlopen error unknown url type: https>
Error: Command 'vpython src/build/download_nacl_toolchains.py --mode nacl_core_sdk sync --extract' returned non-zero exit status 1 in /home/test/chromium_linux

这个应该是depot_tools中vpython工具不支持代理,现解决方案时将上述代码无法执行的命令用系统默认的python执行:

python src/build/download_nacl_toolchains.py --mode nacl_core_sdk sync --extract

即可正常下载。

如果遇到以下错误

Running hooks:  15% ( 8/53) binutils     
________ running '/home/huangyuzhu/bin/python src/third_party/binutils/download.py' in '/home/huangyuzhu/chromium_linux'
Failed to fetch file gs://chromium-binutils/5230f6066998df2f4d61d5fa586152ab20cca300 for /home/huangyuzhu/chromium_linux/src/third_party/binutils/Linux_x64/binutils.tar.bz2. [Err: Traceback (most recent call last):
  File "/home/huangyuzhu/chromium_linux/depot_tools/gsutil.py", line 182, in <module>
    sys.exit(main())

可参考
http://blog.csdn.net/m0_37826678/article/details/73862929

如遇到下面错误:

Running hooks:   7% ( 5/64) sysroot  
________ running '/home/test/bin/python src/build/linux/sysroot_scripts/install-sysroot.py --running-as-hook' in '/home/huangyuzhu/chromium_linux'
Installing Debian Jessie amd64 root image: /home/test/chromium_linux/src/build/linux/debian_jessie_amd64-sysroot
Downloading [https://commondatastorage.googleapis.com/chrome-linux-sysroot/toolchain/823bd3badb80d935f8029a06218d88dcf380ca82/debian_jessie_amd64_sysroot.tar.xz](https://commondatastorage.googleapis.com/chrome-linux-sysroot/toolchain/823bd3badb80d935f8029a06218d88dcf380ca82/debian_jessie_amd64_sysroot.tar.xz)
Failed to download [https://commondatastorage.googleapis.com/chrome-linux-sysroot/toolchain/823bd3badb80d935f8029a06218d88dcf380ca82/debian_jessie_amd64_sysroot.tar.xz](https://commondatastorage.googleapis.com/chrome-linux-sysroot/toolchain/823bd3badb80d935f8029a06218d88dcf380ca82/debian_jessie_amd64_sysroot.tar.xz)
Error: Command '/home/test/bin/python src/build/linux/sysroot_scripts/install-sysroot.py --running-as-hook' returned non-zero exit status 1 in /home/huangyuzhu/chromium_linux

请在install-sysroot.py文件InstallSysroot函数中的"“中手动添加如下代码:

sys.stderr.flush()
# added test {
subprocess.check_call(['curl', '-x', '192.168.0.149:10808', '--fail', '--retry', '3', '-L', url, '-o', tarball])
#}
for _ in range(3):

如果遇到以下错误:

Running hooks:  37% (24/64) msan_chained_origins
________ running '/usr/bin/python src/third_party/depot_tools/download_from_google_storage.py --no_resume --no_auth --bucket chromium-instrumented-libraries -s src/third_party/instrumented_libraries/binaries/msan-chained-origins-trusty.tgz.sha1' in '/home/android/chromium_linux'
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.

可以新建一个.boto文件,内容为:

proxy=http://http.you_proxy.com
proxy_port=you_proxy_port

正常除代理的环境变量没设好导致的连接失败问题外,不应该出现上述错误的,出现了基本都是gclient sync 后面未加参数导致,如果出错就得修改depots_tool中的py脚本,那真够喝几壶的了。

7、接着切换到代码目录src中,执行命令:

$ gn gen out/Default

生成.ninja文件。

也可用

$gn args out/Default

配置参数。

8、编译

$ninja -C out/Default chrome

9、运行

直接在终端执行:

$out/Default/chrome

上一篇下一篇

猜你喜欢

热点阅读