WebRTC源码环境搭建

获取depot_tools

WebRTC代码都是用depot_tools工具来管理,所以第一步就是要获取这个工具。在/chromium目录里面运行:

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

这样depot_tools工具就下载到了/webrtc/depot_tools目录里面,然后把它加到环境变量中:

export PATH=$PATH:/webrtc/depot_tools

配置gclient

运行

gclient config https://webrtc.googlesource.com/src.git —cache-dir=mnt/mirror/webrtc

这会在当面目录下面生成一个一下内容的.gclient文件:

solutions = [
  { "name"        : "src",
    "url"         : "https://webrtc.googlesource.com/src.git",
    "deps_file"   : "DEPS",
    "managed"     : True,
    "custom_deps" : {
    },
    "custom_vars": {},
  },
]
cache_dir = "/mnt/mirror/webrtc"

这个cache_dir就会存放WebRTC以及它所有依赖所有第三方代码的bare仓库。

运用depot_tools的cache-dir机制,有两个重要的优势:

  1. 获取代码比git快
  2. 可以生成所有代码的bare仓库

um代码镜像

动机

做Chromium浏览器开发有件比较蛋疼的事情是获取Chromium代码。Chromium代码仓库一是比较大,依赖的东西很多,二是它的服务器都在国外,国内往往连不上。因此我想利用一台能够直接访问chromium.googlesource.com的服务器做为googlesource的镜像,我直接通过镜像来同步代码。

配置镜像服务器

https://chromium.googlesource.com/chromium/src.git是Chromium代码的主仓库,它依赖70多个第三方仓库,最方便快捷的方式就是利用cache-dir机制来一次性获取所有代码仓库。

获取depot_tools

Chromium代码都是用depot_tools工具来管理,所以第一步就是要获取这个工具。在/chromium目录里面运行:git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git

这样depot_tools工具就下载到了/chromium/depot_tools目录里面,然后把它加到环境变量中:export PATH=$PATH:/chromium/depot_tools

配置gclient

运行 gclient config https://chromium.googlesource.com/chromium/src.git —cache-dir=/chromium/cache。

这会在当面目录下面生成一个一下内容的.gclient文件:

1

2

3

4

5

6

7

8

9

10

11

solutions = [

  { "name"        : "src",

    "url"         : "https://chromium.googlesource.com/chromium/src.git",

    "deps_file"   : "DEPS",

    "managed"     : True,

    "custom_deps" : {

    },

    "safesync_url": "",

  },

]

cache_dir = "/chromium/cache"

这个cache_dir就会存放chromium以及它所有依赖所有第三方代码的bare仓库。

运用depot_tools的cache-dir机制,有两个重要的优势:

  1. 获取代码比git快
  2. 可以生成所有代码的bare仓库

获取WebRTC代码

运行gclient sync –nohook –with_tags –ignore_lock命令获取WebRTC已经它依赖的第三方代码。

  • –nohook参数是获取完代码不运行hooks动作
  • –with_tags参数是获取所有tag
  • –ignore_lock。防止/chromium/cache的lock文件导致获取代码失败

其他问题

HTTP代理配置

Curl等的代理

export http_proxy=192.168.74.1:31210
export https_proxy=192.168.74.1:31210

Git的HTTP代理

git config --global http.proxy http://192.168.74.1:31210
git config --global https.proxy http://192.168.74.1:31210

Git配置保存在 ~/.gitconfig 中,可以随时手动修改

[http]
        proxy = http://192.168.74.1:31210
[https]
        proxy = http://192.168.74.1:31210

多环境搭建

默认获取的是当前环境(比如linux)的代码和依赖的第三方库。可以配置gclient同时获取多环境的源码和工具。

编辑.gclient 配置文件:

target_os = [
  "linux",
  "win",
  "mac",
  "ios",
  "android"
]

这样只要下载一份代码就可以同时构建多平台目标。当然需要通过文件共享(如samba)跨平台访问。

猜你喜欢

转载自blog.csdn.net/luansxx/article/details/89597525