Webrtc代码下载
墙、墙、墙,就因为这个坑爹的墙和Webrtc
用到了Chromium
的toolchain
的原因,获取代码和搭建环境变得异常复杂。所以,准备一个稳定的、速度快的VPN
或者VPS
是一件很重要的事情。
工具安装
Webrtc
复用了很多Chromiun
项目的工具,首先需要的就是depot_tools
。安装方式如下:
git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git # 备份地址,上一个不可用时尝试这个 git clone https://git.chromium.org/git/chromium/tools/depot_tools.git ## Add depot_tools to your PATH
设置工具的路径,打开/etc/profile
文件,添加如下内容:
export PATH="/opt/depot_tools/:$PATH"
然后执行如下命令使配置生效:
$ source /etc/profile
获取代码
gclient
在更新代码时,会读取trunk
下的DEPS
文件,根据文件中配置的路径和版本号更新代码。trunk
下的DEPS
文件在查找某些库时,依赖chromium_deps
目录下的DEPS
文件来获取路径。gclient
会先执行sync
,再执行hooks
,这两个阶段都需要联网下载相关资源。所以仅仅是sync
完成,不一定下载完了所有工具链,gyp
生成工程文件后,也有可能缺少编译、运行需要的资源,只有在运行起来后才能保证相关平台的代码和工具链都下载完了。
官方推荐步骤:
$ gclient config http://webrtc.googlecode.com/svn/trunk $ gclient sync --force
但是由于墙的存在,这种方法几乎无法成功。可以尝试VPN
、git
、修改依赖库地址、多次尝试下载等各种方法,然后祈祷代码可以下载完整。
执行了gclient config http://webrtc.googlecode.com/svn/trunk
后,.gclient
的内容变成如下:
$ cat .gclient solutions = [ { "name" : "trunk", "url" : "http://webrtc.googlecode.com/svn/trunk", "deps_file" : "DEPS", "managed" : True, "custom_deps" : { }, "safesync_url": "", }, ] cache_dir = None
更改成通过git
的方式获取,使用如下命令:
$ gclient config --name trunk 'https://git.chromium.org/git/external/webrtc.git' $ gclient sync --force
.gclient
内容如下:
$ cat .gclient solutions = [ { "name" : "trunk", "url" : "https://git.chromium.org/git/external/webrtc.git", "deps_file" : "DEPS", "managed" : True, "custom_deps" : { }, }, ] cache_dir = None
错误集锦
无法下载库
下载过程中,很有可能因为墙的原因或其它一些诡异的未知问题导致某一个库下载不下来。例如以下的一个错误:
[0:01:17] error: RPC failed; result=56, HTTP code = 200 [0:01:17] fatal: The remote end hung up unexpectedly [0:01:17] fatal: early EOF [0:01:17] fatal: index-pack failed Traceback (most recent call last): File "/opt/depot_tools/gclient_scm.py", line 881, in _Clone self._Run(clone_cmd, options, cwd=self._root_dir, retry=True) File "/opt/depot_tools/gclient_scm.py", line 1166, in _Run gclient_utils.CheckCallAndFilterAndHeader(cmd, env=env, **kwargs) File "/opt/depot_tools/gclient_utils.py", line 292, in CheckCallAndFilterAndHeader return CheckCallAndFilter(args, **kwargs) File "/opt/depot_tools/gclient_utils.py", line 538, in CheckCallAndFilter rv, args, kwargs.get('cwd', None), None, None) CalledProcessError: Command 'git -c core.deltaBaseCacheLimit=2g clone --no-checkout --progress https://chromium.googlesource.com/chromium/src/third_party /srv/example/webrtc/src/_gclient_third_party_1reibo' returned non-zero exit status 128 in /srv/example/webrtc ---------------------------------------- Traceback (most recent call last): File "/opt/depot_tools/gclient.py", line 2128, in <module> sys.exit(main(sys.argv[1:])) File "/opt/depot_tools/gclient.py", line 2114, in main return dispatcher.execute(OptionParser(), argv) File "/opt/depot_tools/subcommand.py", line 252, in execute return command(parser, args[1:]) File "/opt/depot_tools/gclient.py", line 1876, in CMDsync ret = client.RunOnDeps('update', args) File "/opt/depot_tools/gclient.py", line 1363, in RunOnDeps work_queue.flush(revision_overrides, command, args, options=self._options) File "/opt/depot_tools/gclient_utils.py", line 1037, in run self.item.run(*self.args, **self.kwargs) File "/opt/depot_tools/gclient.py", line 772, in run file_list) File "/opt/depot_tools/gclient_scm.py", line 156, in RunCommand return getattr(self, command)(options, args, file_list) File "/opt/depot_tools/gclient_scm.py", line 417, in update self._Clone(revision, url, options) File "/opt/depot_tools/gclient_scm.py", line 889, in _Clone if os.listdir(tmp_dir): OSError: [Errno 2] No such file or directory: '/srv/example/webrtc/src/_gclient_third_party_1reibo'
遇到以上错误时,直接使用命令方式下载:
$ git -c core.deltaBaseCacheLimit=2g clone --no-checkout --progress https://chromium.googlesource.com/chromium/src/third_party
无法下载android_tools
一直提示如下的信息:
[0:03:02] Still working on: [0:03:02] src/third_party/android_tools [0:03:12] Still working on: [0:03:12] src/third_party/android_tools [0:03:22] Still working on: [0:03:22] src/third_party/android_tools [0:03:32] Still working on: [0:03:32] src/third_party/android_tools [0:03:42] Still working on: [0:03:42] src/third_party/android_tools
使用如下命令下载:
$ git clone https://git.chromium.org/git/android_tools.git
然后将下载好的库拷贝到trunk/third_party/android_tools
目录下。
参考文章
Webrtc Getting Started
Ubuntu 14.04编译WebRTC For Android代码
webrtc在ubuntu14.04上的编译过程(千辛万苦啊)-2015.01.22