【WebRTC】起步:安装编译

来源:互联网 发布:电脑网络连接不上 编辑:程序博客网 时间:2024/06/06 09:00

经过相当折腾的一周,终于把WebRTC的代码和工程下载完成,特此记录下。

WebRTC(Web Real-Time Communication) ,是指通过所提供的简单的JavaScript API,就可以实现网页浏览器的实时通信(RTC)功能。主页是: http://www.webrtc.org/ 

 熟悉英文的童鞋可以参考: http://www.webrtc.org/reference/getting-started  所提供的指导,可以说是相当的完善的指导。

 以下记录我自己的过程:

1. 准备工作

目前WebRTC支持的目前支持的平台有 Windows, Mac OS X, Linux and Android。

预先安装必备软件:depottools

Google采用 depot_tools 脚本包来管理代码库和开发过程,它包含以下程序:

  • gclient: Meta-checkout tool managing both subversion and git checkouts. It is similar to repo tool except that it works on Linux, OS X, and Windows and supports both svn and git. On the other hand, gclient doesn't integrate any code review functionality.
  • gcl: Rietveld code review tool for subversion. The gcl tool runs presubmit scripts.
  • git-cl: Rietveld code review tool for git. The git-cl tool runs presubmit scripts.
  • hammer: (Obsolete) Wrapper script for building Chromium with the SCons software construction tool.
  • svn [Windows only]: subversion client for Chromium development. (Executable Subversion binaries are included in the depot_tools on Windows systems as a convenience, so that working with Chromium source code does not require a separate Subversion download.)
  • drover: Quickly revert svn commits.
  • cpplint.py: Checks for C++ style compliance.
  • pylint: Checks for Python style compliance.
  • presubmit_support.py: Runs PRESUBMIT.py presubmit checks.
  • repo: The repo tool.
  • trychange.py: Try server tool. It is wrapped by gcl try and git-try.
  • git-try: Try change tool for git users
  • wtf: Displays the active git branches in a chromium os checkout.
  • weekly: Displays the log of checkins for a particular developer since a particular date for git checkouts.
  • git-gs: Wrapper for git grep with relevant source types.
  • zsh-goodies: Completion for zsh users.

在Ubuntu12.04 64bit环境上已经安装好 Git ,所以只需执行:

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

就可以获取到该脚本,然后将depot_tools加入到环境变量PATH中:

$ export PATH="$PATH":`pwd`/depot_tools

(2) Ubuntu 环境下在 第一次 gclient sync 后,可以运行脚本: $ ./build/install-build-deps.sh  下载所需软件。
          当然也可以自行下载(sudo apt-get install...):
                g++ (>= 4.2)     
  python (>= 2.4)
  libnss3-dev >= 3.12
  libasound2-dev
  libpulse-dev
  libjpeg62-dev
  libxv-dev
  libgtk2.0-dev
  libexpat1-dev

2. 下载代码

(1) 创建工作目录,然后运行:  $ gclient config http://webrtc.googlecode.com/svn/trunk    创建 .gclient 文件

(2) 同步代码(下载时间很长,容易出现下载失败,最好将网络挂到VPN上,博主推荐下NydusVPN 注册之后可以免费使用一周大笑),
(I)除Android系统外,输入: $ gclient sync --force
       (II)若是Android系统,需要执行以下动作:
                            echo "target_os = ['android', 'unix']" >> .gclient
                    $ gclient sync --nohooks

           该步骤会下载 android ndk 和 sdk,时间较长,下载完成之后需要配置NDK和SDK目录到环境变量PATH中,博主之前已经配置好相应的SDK和JDK,所以只需再配置NDK即可:
export ANDROID_SDK_ROOT=xxxxxxx/SDK
export ANDROID_NDK_ROOT=xxxxxxx/NDK
export PATH="$PATH":$ANDROID_NDK_ROOT:$ANDROID_SDK_ROOT
(3) 同步生成的编译工程文件, $ gclient runhooks --force 

   3) 生成Demo文件
     
                默认情况下,采用 Ninja 作为全平台的编译工具;

               如果要生成示例,输入 : ninja -C out/Debug
               如果要生成Realse版本,输入:  ninja -C out/Release

            当然如果你觉得不习惯使用 Ninja 喜欢使用make 等工具,则可以修改GYP_GENERATORS 环境变量, 
如 export GYP_GENERATORS="make"
                make for Makefiles
                    msvs for Visual Studio
                    msvs-ninja for Visual Studio project building with ninja
                    xcode for Xcode

               如果只需要生成Android的WebRTCDemo,则需:
ninja -C out/Release WebRTCDemo






0 0
原创粉丝点击