Webrtc windows 编译

来源:互联网 发布:黄金储备数据 编辑:程序博客网 时间:2024/06/06 03:50

这里主要是将我看到的几篇文章综合放到这里。因为在具体应用中遇到一些问题所以要处理。

由于有些文章不便于转载,所以这里仅仅给出链接地址;


1:《 

WebRTC第一步

http://blog.csdn.net/cabbage2008/article/details/52791119


2:《WebRtc最新编译,最新版本2017》

(注释:下代码主要还是要翻墙,这里公司刚好用这个工具代理,Windows需要按照.NET库)

系统环境:win10

vs版本:vs2015


一:在客户端使用ShadowSocks作为代理!

我直接购买的ShadowSocks的服务器版本!10元人民币一个月左右。可以慢慢下!足够用了!


使用“全局模式”;


如果实在不想买,也可以自己搭建服务器,比较麻烦,容易出错。网上有教程!

二:depot_tools配置

下载地址:https://github.com/ipop-project/ipop-project.github.io/wiki/Building-the-WebRTC-lib-for-Windows

下载完后,自动更新。用管理员权限打开cmd,运行gclient,会自动进行更新,下载Git,svn等。


如果出现连接不上服务器的错误。可以设置一下git的本地代理!


解决方法:

set http_proxy=127.0.0.1:1080
set https_proxy=127.0.0.1:1080


没问题后,执行gclient不报错即可!


不要忘了将depot_tools的路径配置到系统环境变量里面;

计算机属性->高级系统设置->高级->环境变量->系统变量->打开Path,最前边增加 E:\depot_tools; 


三:环境准备

下面几项必须准备 

1.系统locale最好设置成English,就是控制面板里面的Region 
控制面板-> 时钟、语言和区域->更改位置->管理->更改系统区域设置 
选择英语美国 重启 




2.安装vs2015 update2以上版本,其他的版本不受支持。

3.操作系统必须是x64架构,x86架构不支持。

4.安装vs2015的时候同时要安装win10sdk(10.0.10586)。


查看C:\Program Files (x86)\Windows Kits\10 里面数据是否拥有 


四:下载webrtc代码:

1.设置 depot_tools代理 [推荐] 此步骤必须在depot_tools下载并glcient之后做 
为了解决 depot_tools自身更新问题,为depot_tools增加代理支持,修改E:\depot_tools\bootstarp\win\get_file.js文件: 
(1)改xml_http = new ActiveXObject(“MSXML2.ServerXMLHTTP”); 第10行 
为 xml_http = new ActiveXObject(“MSXML2.ServerXMLHTTP.5.0”); 
(2)xml_http.open(“GET”, url, false); 第17行 前增加 
xml_http.setProxy(2, “127.0.0.1:1080”); 



(3)在E:\depot_tools下新建http_proxy.boto,内容如下: 

[Boto] 
proxy= 127.0.0.1 
proxy_port= 1080 


2.webrtc代码下载 
创建D:\webrtc,管理员权限打开cmd 
cd D:\webrtc 
设置下载工具代理环境变量: 
set http_proxy=http://127.0.0.1:1080 
set https_proxy=http://127.0.0.1:1080 
设置下载工具git代理: 
git config –global http.proxy http://127.0.0.1:1080 
设置BOTO代理,解决download google storage失败问题: 
set NO_AUTH_BOTO_CONFIG=E:\depot_tools\http_proxy.boto 
设置不再次下载工具链: 
set DEPOT_TOOLS_WIN_TOOLCHAIN=0 
设置生成工程环境变量: 
set GYP_GENERATORS=msvs-ninja,ninja 
set GYP_MSVS_VERSION=2015 
首次下载输入下载命令: 
fetch webrtc 
官网上有–nohooks 命令,下载依赖项不生成编译文件 本例建议去掉这个命令 
会像下图所示: 



如果中途断网:gclient sync 
查看到底是否正在下载: 
资源管理器->性能->资源监视器 




会发现shadowsocks进程正在下载


五:编译:


windows 
1.生成VS项目文件 
set DEPOT_TOOLS_WIN_TOOLCHAIN=0 
set GYP_GENERATORS=msvs-ninja,ninja 
set GYP_MSVS_VERSION=2015 (这里是2013会出现问题,生成的文件缺失很多)

生成VS2013项目文件(推荐使用) 
gn gen out/Default –ide=vs2013 
生成VS2015项目文件 
gn gen out/Default –ide=vs2015 

2.编译调试 
以VS2013为例,用VS2013打开all.sln 
将webrtc项目下example下的peerconnection_client设为启动项 







《最新webrtc编译 2017》

(注释:这个人写的也不错,可以参考,如果可以进群要到代码,那就更好了)


webRTC被越来越广泛的使用,但是很多人都对其源码的下载及编译感到非常的头疼,总结下我们团队在下载编译过程中遇到的问题。
最新的webRTC需要安装VS2015,最好安装旗舰版,社区版的话在编译过程中会提示遇到缺少一些东西,又需要安装各种东西,很麻烦,另外还需要安装个git。
由于代码在googlesource上所以首先需要找个好点的梯子去下载,几个G的代码最好找个速度快点的VPN。
下载官方的工具depot_tools,这个工具会帮你安装一些必要的下载及编译工具。
下载好了后解压,右键全部解压(不要直接在压缩包里面运行脚本),解压到比如J:\depot-tools,将D:\depot-tools添加到windows环境变量里。
建立J:\webrtcsource目录,进入打开cmd命令行,运行以下命令

fetch --nohooks webrtc
gclient sync

Git checkout master

代码下载完成后在master分支上,进入J:\webrtcsource\src目录,运行以下命令切换到一个release分支上并打上标签

gclient sync --with_branch_heads
git fetch origin
git checkout -b my_branch refs/remotes/branch-heads/58
查看如下图

如果编译过程中遇到如下错误

找不到gn.exe(Linux上找不到gn)
set DEPOT_TOOLS_WIN_TOOLCHAIN=0
set GYP_MSVS_VERSION=2015

gclient runhooks


IOError: [Errno 2] No such file or directory: 'C:\\Program Files (x86)\\Windows Kits\\10\\Debuggers\\x64\\cdb.exe'
请自己搜索安装windows standed SDK
下载后的目录结构如下

下载完成后进行编译啦,使用Ninja进行编译,首先需要生成Ninja工程:
进入到J:\webrtcsource\src目录下运行以下命令
gn gen out/Default
gn gen out/Default (编release版本)或者gn gen out/Default --args='is_debug=false' (编debug版本)
Ninja工程生成好后
ninja -C out/Default
编译完成后就可以在out/Default下看到生成的文件啦
用以下命令生成vs工程,直接用vs2015打开,方便看源码
gn --ide="vs2015" ----no-deps

对DLNA/Airplay/Miracast/Widi感兴趣的同学可进QQ群 582349005交流。
也可访问https://github.com/wirelessdisplay

需要webrtc源码的也可以进群索要^_^




《编译最新版webrtc源码和编译好的整个项目10多个G【分享】》

(注释:此文章作者上传源码到GitHub了,太好了!!其他文章可以不用看了)

https://github.com/JumpingYang001/webrtc





《Google官方编译chrome的方法,具体和编译webrtc差不多》

https://chromium.googlesource.com/chromium/src/+/master/docs/windows_build_instructions.md

Checking out and Building Chromium for Windows

There are instructions for other platforms linked from the get the code page.

Instructions for Google Employees

Are you a Google employee? See go/building-chrome-win instead.

Contents

  • Instructions for Google Employees
  • System requirements
  • Setting up Windows
    • Visual Studio
  • Install
  • Get the code
  • Setting up the build
    • Using the Visual Studio IDE
    • Faster builds
  • Build Chromium
  • Run Chromium
  • Running test targets
  • Update your checkout

System requirements

  • A 64-bit Intel machine with at least 8GB of RAM. More than 16GB is highly recommended.
  • At least 100GB of free disk space on an NTFS-formatted hard drive. FAT32 will not work, as some of the Git packfiles are larger than 4GB.
  • Visual Studio 2015 Update 3, see below (no other version is supported).
  • Windows 7 or newer.

Setting up Windows

Visual Studio

As of December 8, 2016 Chromium requires Visual Studio 2015, with the 14393 Windows SDK to build.

Install Visual Studio 2015 Update 3 or later - Community Edition should work if its license is appropriate for you. Use the Custom Install option and select:

  • Visual C++, which will select three sub-categories including MFC
  • Universal Windows Apps Development Tools > Tools (1.4.1) and Windows 10 SDK (10.0.14393)

You must have the 14393 Windows SDK installed - the 15063 SDK has errors and cannot be used to compile Chrome. It is okay to have multiple SDK versions installed as long as 14393 is one of them. The installer can be found in the Windows SDK archive.

When installing the 14393 Windows SDK choose Debugging Tools For Windows in order to get windbg and cdb. The latter is required for the build to succeed as some tests use it for symbolizing crash dumps.

Install depot_tools

Download the depot_tools bundle and extract it somewhere.

Warning: DO NOT use drag-n-drop or copy-n-paste extract from Explorer, this will not extract the hidden “.git” folder which is necessary for depot_tools to autoupdate itself. You can use “Extract all…” from the context menu though.

Add depot_tools to the start of your PATH (must be ahead of any installs of Python). Assuming you unzipped the bundle to C:\src\depot_tools, open:

Control Panel → System and Security → System → Advanced system settings

If you have Administrator access, Modify the PATH system variable and put C:\src\depot_tools at the front (or at least in front of any directory that might already have a copy of Python or Git).

If you don't have Administrator access, you can add a user-level PATH environment variable and put C:\src\depot_tools at the front, but if your system PATH has a Python in it, you will be out of luck.

Also, add a DEPOT_TOOLS_WIN_TOOLCHAIN system variable in the same way, and set it to 0. This tells depot_tools to use your locally installed version of Visual Studio (by default, depot_tools will try to use a google-internal version).

From a cmd.exe shell, run the command gclient (without arguments). On first run, gclient will install all the Windows-specific bits needed to work with the code, including msysgit and python.

  • If you run gclient from a non-cmd shell (e.g., cygwin, PowerShell), it may appear to run properly, but msysgit, python, and other tools may not get installed correctly.
  • If you see strange errors with the file system on the first run of gclient, you may want to disable Windows Indexing.

After running gclient open a command prompt and type where python and confirm that the depot_tools python.bat comes ahead of any copies of python.exe. Failing to ensure this can lead to overbuilding when using gn - see crbug.com/611087.

Get the code

Create a chromium directory for the checkout and change to it (you can call this whatever you like and put it wherever you like, as long as the full path has no spaces):

$ mkdir chromium && cd chromium

Run the fetch tool from depot_tools to check out the code and its dependencies.

$ fetch chromium

If you don't want the full repo history, you can save a lot of time by adding the --no-history flag to fetch.

Expect the command to take 30 minutes on even a fast connection, and many hours on slower ones.

When fetch completes, it will have created a hidden .gclient file and a directory called src in the working directory. The remaining instructions assume you have switched to the src directory:

$ cd src

Optional: You can also install API keys if you want your build to talk to some Google services, but this is not necessary for most development and testing purposes.

Setting up the build

Chromium uses Ninja as its main build tool along with a tool called GN to generate .ninja files. You can create any number of build directorieswith different configurations. To create a build directory:

$ gn gen out/Default
  • You only have to run this once for each new build directory, Ninja will update the build files as needed.
  • You can replace Default with another name, but it should be a subdirectory of out.
  • For other build arguments, including release settings, see GN build configuration. The default will be a debug component build matching the current host operating system and CPU.
  • For more info on GN, run gn help on the command line or read the quick start guide.

Using the Visual Studio IDE

If you want to use the Visual Studio IDE, use the --ide command line argument to gn gen when you generate your output directory (as described on the get the code page):

$ gn gen --ide=vs out\Default$ devenv out\Default\all.sln

GN will produce a file all.sln in your build directory. It will internally use Ninja to compile while still allowing most IDE functions to work (there is no native Visual Studio compilation mode). If you manually run “gen” again you will need to resupply this argument, but normally GN will keep the build and IDE files up to date automatically when you build.

The generated solution will contain several thousand projects and will be very slow to load. Use the --filters argument to restrict generating project files for only the code you're interested in, although this will also limit what files appear in the project explorer. A minimal solution that will let you compile and run Chrome in the IDE but will not show any source files is:

$ gn gen --ide=vs --filters=//chrome out\Default

There are other options for controlling how the solution is generated, run gn help gen for the current documentation.

Faster builds

  • Reduce file system overhead by excluding build directories from antivirus and indexing software.
  • Store the build tree on a fast disk (preferably SSD).

Still, expect build times of 30 minutes to 2 hours when everything has to be recompiled.

Build Chromium

Build Chromium (the “chrome” target) with Ninja using the command:

$ ninja -C out\Default chrome

You can get a list of all of the other build targets from GN by running gn ls out/Default from the command line. To compile one, pass to Ninja the GN label with no preceding “//” (so for //chrome/test:unit_tests use ninja -C out/Default chrome/test:unit_tests`).

Run Chromium

Once it is built, you can simply run the browser:

$ out\Default\chrome.exe

(The “.exe” suffix in the command is actually optional).

Running test targets

You can run the tests in the same way. You can also limit which tests are run using the --gtest_filter arg, e.g.:

$ out\Default\unit_tests.exe --gtest_filter="PushClientTest.*"

You can find out more about GoogleTest at its GitHub page.

Update your checkout

To update an existing checkout, you can run

$ git rebase-update$ gclient sync

The first command updates the primary Chromium source repository and rebases any of your local branches on top of tip-of-tree (aka the Git branch origin/master). If you don't want to use this script, you can also just use git pull or other common Git commands to update the repo.

The second command syncs the subrepositories to the appropriate versions and re-runs the hooks as needed.



写在最后,注意几个问题:

1:自己下代码,用VPN,参考前面的文章严格执行,应该没有问题;

2:可以参考Google编译chrome的方法应用命令行,目前最新的默认就是vs2015(Update 3 );

      VS2017 也可以;  可以按照网上的命令方式,下载VS2017安装包;同时修改编译命令为2017;

3:代理下载,hosts下载,手动下载,综合下载;

4:别忘了src同级目录中的“.gclient“,“.gclient_entries”文件; “.gclient”文件中有保护一些配置信息,包括目标系统代码;

5:如果没有上面两个文件,那么gclient工具总是提示没有config;














Checking out and building Chromium on Linux

from:https://chromium.googlesource.com/chromium/src/+/master/docs/linux_build_instructions.md

There are instructions for other platforms linked from the get the code page.

Instructions for Google Employees

Are you a Google employee? See go/building-chrome instead.

Contents

  • Instructions for Google Employees
  • System requirements
  • Install
  • Get the code
    • Install additional build dependencies
    • Run the hooks
  • Setting up the build
    • Faster builds
  • Build Chromium
  • Run Chromium
  • Running test targets
  • Update your checkout
  • Tips, tricks, and troubleshooting
    • Linker Crashes
    • More links
  • Next Steps
  • Notes for other distros
    • Arch Linux
    • Debian
    • Fedora
    • Gentoo
    • Mandriva
    • OpenSUSE

System requirements

  • A 64-bit Intel machine with at least 8GB of RAM. More than 16GB is highly recommended.
  • At least 100GB of free disk space.
  • You must have Git and Python installed already.

Most development is done on Ubuntu (currently 14.04, Trusty Tahr). There are some instructions for other distros below, but they are mostly unsupported.

Install depot_tools

Clone the depot_tools repository:

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

Add depot_tools to the end of your PATH (you will probably want to put this in your ~/.bashrc or ~/.zshrc). Assuming you cloned depot_tools to /path/to/depot_tools:

$ export PATH="$PATH:/path/to/depot_tools"

Get the code

Create a chromium directory for the checkout and change to it (you can call this whatever you like and put it wherever you like, as long as the full path has no spaces):

$ mkdir ~/chromium && cd ~/chromium

Run the fetch tool from depot_tools to check out the code and its dependencies.

$ fetch --nohooks chromium

If you don't want the full repo history, you can save a lot of time by adding the --no-history flag to fetch.

Expect the command to take 30 minutes on even a fast connection, and many hours on slower ones.

If you've already installed the build dependencies on the machine (from another checkout, for example), you can omit the --nohooks flag and fetch will automatically execute gclient runhooks at the end.

When fetch completes, it will have created a hidden .gclient file and a directory called src in the working directory. The remaining instructions assume you have switched to the src directory:

$ cd src

Install additional build dependencies

Once you have checked out the code, and assuming you're using Ubuntu, run build/install-build-deps.sh

You may need to adjust the build dependencies for other distros. There are some notes at the end of this document, but we make no guarantees for their accuracy.

Run the hooks

Once you've run install-build-deps at least once, you can now run the Chromium-specific hooks, which will download additional binaries and other things you might need:

$ gclient runhooks

Optional: You can also install API keys if you want your build to talk to some Google services, but this is not necessary for most development and testing purposes.

Setting up the build

Chromium uses Ninja as its main build tool along with a tool called GN to generate .ninja files. You can create any number of build directories with different configurations. To create a build directory, run:

$ gn gen out/Default
  • You only have to run this once for each new build directory, Ninja will update the build files as needed.
  • You can replace Default with another name, but it should be a subdirectory of out.
  • For other build arguments, including release settings, see GN build configuration. The default will be a debug component build matching the current host operating system and CPU.
  • For more info on GN, run gn help on the command line or read the quick start guide.

Faster builds

This section contains some things you can change to speed up your builds, sorted so that the things that make the biggest difference are first.

Jumbo/Unity builds

Jumbo builds merge many translation units (“source files”) and compile them together. Since a large portion of Chromium's code is in shared header files, this dramatically reduces the total amount of work needed. Check out the Jumbo / Unity builds for more information.

Enable jumbo builds by setting the GN arg use_jumbo_build=true.

Disable NaCl

By default, the build includes support for Native Client (NaCl), but most of the time you won‘t need it. You can set the GN argument enable_nacl=false and it won’t be built.

Include fewer debug symbols

By default GN produces a build with all of the debug assertions enabled (is_debug=true) and including full debug info (symbol_level=2). Setting symbol_level=1 will produce enough information for stack traces, but not line-by-line debugging. Setting symbol_level=0 will include no debug symbols at all. Either will speed up the build compared to full symbols.

Disable debug symbols for Blink

Due to its extensive use of templates, the Blink code produces about half of our debug symbols. If you don't ever need to debug Blink, you can set the GN arg remove_webcore_debug_symbols=true.

Use Icecc

Icecc is the distributed compiler with a central scheduler to share build load. Currently, many external contributors use it. e.g. Intel, Opera, Samsung (Googlers use an internal system called Goma).

In order to use icecc, set the following GN args:

linux_use_bundled_binutils=falseuse_debug_fission=falseis_clang=false

See these links for more on the bundled_binutils limitation, the debug fission limitation.

Using the system linker may also be necessary when using glibc 2.21 or newer. See related bug.

ccache

You can use ccache to speed up local builds (again, this is not useful if you're a Googler using Goma).

Increase your ccache hit rate by setting CCACHE_BASEDIR to a parent directory that the working directories all have in common (e.g., /home/yourusername/development). Consider using CCACHE_SLOPPINESS=include_file_mtime (since if you are using multiple working directories, header times in svn sync'ed portions of your trees will be different - see the ccache troubleshooting section for additional information). If you use symbolic links from your home directory to get to the local physical disk directory where you keep those working development directories, consider putting

alias cd="cd -P"

in your .bashrc so that $PWD or cwd always refers to a physical, not logical directory (and make sure CCACHE_BASEDIR also refers to a physical parent).

If you tune ccache correctly, a second working directory that uses a branch tracking trunk and is up to date with trunk and was gclient sync'ed at about the same time should build chrome in about 1/3 the time, and the cache misses as reported by ccache -s should barely increase.

This is especially useful if you use git-new-workdir and keep multiple local working directories going at once.

Using tmpfs

You can use tmpfs for the build output to reduce the amount of disk writes required. I.e. mount tmpfs to the output directory where the build output goes:

As root:

mount -t tmpfs -o size=20G,nr_inodes=40k,mode=1777 tmpfs /path/to/out
Caveat: You need to have enough RAM + swap to back the tmpfs. For a full debug build, you will need about 20 GB. Less for just building the chrome target or for a release build.

Quick and dirty benchmark numbers on a HP Z600 (Intel core i7, 16 cores hyperthreaded, 12 GB RAM)

  • With tmpfs:
    • 12m:20s
  • Without tmpfs
    • 15m:40s

Build Chromium

Build Chromium (the “chrome” target) with Ninja using the command:

$ ninja -C out/Default chrome

You can get a list of all of the other build targets from GN by running gn ls out/Default from the command line. To compile one, pass the GN label to Ninja with no preceding “//” (so, for //chrome/test:unit_tests use ninja -C out/Default chrome/test:unit_tests).

Run Chromium

Once it is built, you can simply run the browser:

$ out/Default/chrome

Running test targets

You can run the tests in the same way. You can also limit which tests are run using the --gtest_filter arg, e.g.:

$ out/Default/unit_tests --gtest_filter="PushClientTest.*"

You can find out more about GoogleTest at its GitHub page.

Update your checkout

To update an existing checkout, you can run

$ git rebase-update$ gclient sync

The first command updates the primary Chromium source repository and rebases any of your local branches on top of tip-of-tree (aka the Git branch origin/master). If you don't want to use this script, you can also just use git pull or other common Git commands to update the repo.

The second command syncs dependencies to the appropriate versions and re-runs hooks as needed.

Tips, tricks, and troubleshooting

Linker Crashes

If, during the final link stage:

LINK out/Debug/chrome

You get an error like:

collect2: ld terminated with signal 6 Aborted terminate called after throwing an instance of 'std::bad_alloc'collect2: ld terminated with signal 11 [Segmentation fault], core dumped

you are probably running out of memory when linking. You must use a 64-bit system to build. Try the following build settings (see GN build configuration for other settings):

  • Build in release mode (debugging symbols require more memory): is_debug = false
  • Turn off symbols: symbol_level = 0
  • Build in component mode (this is for development only, it will be slower and may have broken functionality): is_component_build = true

More links

  • Information about building with Clang.
  • You may want to use a chroot to isolate yourself from versioning or packaging conflicts.
  • Cross-compiling for ARM? See LinuxChromiumArm.
  • Want to use Eclipse as your IDE? See LinuxEclipseDev.
  • Want to use your built version as your default browser? See LinuxDevBuildAsDefaultBrowser.

Next Steps

If you want to contribute to the effort toward a Chromium-based browser for Linux, please check out the Linux Development page for more information.

Notes for other distros

Arch Linux

Instead of running install-build-deps.sh to install build dependencies, run:

$ sudo pacman -S --needed python perl gcc gcc-libs bison flex gperf pkgconfig \nss alsa-lib gconf glib2 gtk2 nspr ttf-ms-fonts freetype2 cairo dbus \libgnome-keyring

For the optional packages on Arch Linux:

  • php-cgi is provided with pacman
  • wdiff is not in the main repository but dwdiff is. You can get wdiff in AUR/yaourt
  • sun-java6-fonts do not seem to be in main repository or AUR.

Debian

Some tests require the ttf-mscorefonts-installer package from the contrib component. contrib packages may have dependencies on non-free software.

If you need to run tests requiring MS TTF fonts, you can edit your apt sources.list by adding contrib to the end of each line beginning with deb. You might end up with something like this:

deb http://ftp.us.debian.org/debian/ jessie main contribdeb-src http://ftp.us.debian.org/debian/ jessie main contribdeb http://security.debian.org/ jessie/updates main contribdeb-src http://security.debian.org/ jessie/updates main contrib# jessie-updates, previously known as 'volatile'deb http://ftp.us.debian.org/debian/ jessie-updates main contribdeb-src http://ftp.us.debian.org/debian/ jessie-updates main contrib

Next, run:

$ sudo apt-get update$ sudo apt-get install ttf-mscorefonts-installer

If you already have the contrib component enabled, install-build-deps.sh will install ttf-mscorefonts-installer for you.

Fedora

Instead of running build/install-build-deps.sh, run:

su -c 'yum install git python bzip2 tar pkgconfig atk-devel alsa-lib-devel \bison binutils brlapi-devel bluez-libs-devel bzip2-devel cairo-devel \cups-devel dbus-devel dbus-glib-devel expat-devel fontconfig-devel \freetype-devel gcc-c++ GConf2-devel glib2-devel glibc.i686 gperf \glib2-devel gtk2-devel gtk3-devel java-1.*.0-openjdk-devel libatomic \libcap-devel libffi-devel libgcc.i686 libgnome-keyring-devel libjpeg-devel \libstdc++.i686 libX11-devel libXScrnSaver-devel libXtst-devel \libxkbcommon-x11-devel ncurses-compat-libs nspr-devel nss-devel pam-devel \pango-devel pciutils-devel pulseaudio-libs-devel zlib.i686 httpd mod_ssl \php php-cli python-psutil wdiff xorg-x11-server-Xvfb'

The fonts needed by Blink's LayoutTests can be obtained by following these instructions. For the optional packages:

  • php-cgi is provided by the php-cli package.
  • sun-java6-fonts is covered by the instructions linked above.

Gentoo

You can just run emerge www-client/chromium.

Mandriva

Instead of running build/install-build-deps.sh, run:

urpmi lib64fontconfig-devel lib64alsa2-devel lib64dbus-1-devel \lib64GConf2-devel lib64freetype6-devel lib64atk1.0-devel lib64gtk+2.0_0-devel \lib64pango1.0-devel lib64cairo-devel lib64nss-devel lib64nspr-devel g++ python \perl bison flex subversion gperf
  • msttcorefonts are not available, you will need to build your own (see instructions, not hard to do, see mandriva_msttcorefonts.md) or use drakfont to import the fonts from a Windows installation.

OpenSUSE

Use zypper command to install dependencies:

(openSUSE 11.1 and higher)

sudo zypper in subversion pkg-config python perl \     bison flex gperf mozilla-nss-devel glib2-devel gtk-devel \     wdiff lighttpd gcc gcc-c++ gconf2-devel mozilla-nspr \     mozilla-nspr-devel php5-fastcgi alsa-devel libexpat-devel \     libjpeg-devel libbz2-devel

For 11.0, use libnspr4-0d and libnspr4-dev instead of mozilla-nspr and mozilla-nspr-devel, and use php5-cgi instead of php5-fastcgi. And need gtk2-devel.

(openSUSE 11.0)

sudo zypper in subversion pkg-config python perl \     bison flex gperf mozilla-nss-devel glib2-devel gtk-devel \     libnspr4-0d libnspr4-dev wdiff lighttpd gcc gcc-c++ libexpat-devel \     php5-cgi gconf2-devel alsa-devel gtk2-devel jpeg-devel

The Ubuntu package sun-java6-fonts contains a subset of Java of the fonts used. Since this package requires Java as a prerequisite anyway, we can do the same thing by just installing the equivalent openSUSE Sun Java package:

sudo zypper in java-1_6_0-sun

WebKit is currently hard-linked to the Microsoft fonts. To install these using zypper

sudo zypper in fetchmsttfonts pullin-msttf-fonts

To make the fonts installed above work, as the paths are hardcoded for Ubuntu, create symlinks to the appropriate locations:

sudo mkdir -p /usr/share/fonts/truetype/msttcorefontssudo ln -s /usr/share/fonts/truetype/arial.ttf /usr/share/fonts/truetype/msttcorefonts/Arial.ttfsudo ln -s /usr/share/fonts/truetype/arialbd.ttf /usr/share/fonts/truetype/msttcorefonts/Arial_Bold.ttfsudo ln -s /usr/share/fonts/truetype/arialbi.ttf /usr/share/fonts/truetype/msttcorefonts/Arial_Bold_Italic.ttfsudo ln -s /usr/share/fonts/truetype/ariali.ttf /usr/share/fonts/truetype/msttcorefonts/Arial_Italic.ttfsudo ln -s /usr/share/fonts/truetype/comic.ttf /usr/share/fonts/truetype/msttcorefonts/Comic_Sans_MS.ttfsudo ln -s /usr/share/fonts/truetype/comicbd.ttf /usr/share/fonts/truetype/msttcorefonts/Comic_Sans_MS_Bold.ttfsudo ln -s /usr/share/fonts/truetype/cour.ttf /usr/share/fonts/truetype/msttcorefonts/Courier_New.ttfsudo ln -s /usr/share/fonts/truetype/courbd.ttf /usr/share/fonts/truetype/msttcorefonts/Courier_New_Bold.ttfsudo ln -s /usr/share/fonts/truetype/courbi.ttf /usr/share/fonts/truetype/msttcorefonts/Courier_New_Bold_Italic.ttfsudo ln -s /usr/share/fonts/truetype/couri.ttf /usr/share/fonts/truetype/msttcorefonts/Courier_New_Italic.ttfsudo ln -s /usr/share/fonts/truetype/impact.ttf /usr/share/fonts/truetype/msttcorefonts/Impact.ttfsudo ln -s /usr/share/fonts/truetype/times.ttf /usr/share/fonts/truetype/msttcorefonts/Times_New_Roman.ttfsudo ln -s /usr/share/fonts/truetype/timesbd.ttf /usr/share/fonts/truetype/msttcorefonts/Times_New_Roman_Bold.ttfsudo ln -s /usr/share/fonts/truetype/timesbi.ttf /usr/share/fonts/truetype/msttcorefonts/Times_New_Roman_Bold_Italic.ttfsudo ln -s /usr/share/fonts/truetype/timesi.ttf /usr/share/fonts/truetype/msttcorefonts/Times_New_Roman_Italic.ttfsudo ln -s /usr/share/fonts/truetype/verdana.ttf /usr/share/fonts/truetype/msttcorefonts/Verdana.ttfsudo ln -s /usr/share/fonts/truetype/verdanab.ttf /usr/share/fonts/truetype/msttcorefonts/Verdana_Bold.ttfsudo ln -s /usr/share/fonts/truetype/verdanai.ttf /usr/share/fonts/truetype/msttcorefonts/Verdana_Italic.ttfsudo ln -s /usr/share/fonts/truetype/verdanaz.ttf /usr/share/fonts/truetype/msttcorefonts/Verdana_Bold_Italic.ttf

The Ubuntu package sun-java6-fonts contains a subset of Java of the fonts used. Since this package requires Java as a prerequisite anyway, we can do the same thing by just installing the equivalent openSUSE Sun Java package:

sudo zypper in java-1_6_0-sun

WebKit is currently hard-linked to the Microsoft fonts. To install these using zypper

sudo zypper in fetchmsttfonts pullin-msttf-fonts

To make the fonts installed above work, as the paths are hardcoded for Ubuntu, create symlinks to the appropriate locations:

sudo mkdir -p /usr/share/fonts/truetype/msttcorefontssudo ln -s /usr/share/fonts/truetype/arial.ttf /usr/share/fonts/truetype/msttcorefonts/Arial.ttfsudo ln -s /usr/share/fonts/truetype/arialbd.ttf /usr/share/fonts/truetype/msttcorefonts/Arial_Bold.ttfsudo ln -s /usr/share/fonts/truetype/arialbi.ttf /usr/share/fonts/truetype/msttcorefonts/Arial_Bold_Italic.ttfsudo ln -s /usr/share/fonts/truetype/ariali.ttf /usr/share/fonts/truetype/msttcorefonts/Arial_Italic.ttfsudo ln -s /usr/share/fonts/truetype/comic.ttf /usr/share/fonts/truetype/msttcorefonts/Comic_Sans_MS.ttfsudo ln -s /usr/share/fonts/truetype/comicbd.ttf /usr/share/fonts/truetype/msttcorefonts/Comic_Sans_MS_Bold.ttfsudo ln -s /usr/share/fonts/truetype/cour.ttf /usr/share/fonts/truetype/msttcorefonts/Courier_New.ttfsudo ln -s /usr/share/fonts/truetype/courbd.ttf /usr/share/fonts/truetype/msttcorefonts/Courier_New_Bold.ttfsudo ln -s /usr/share/fonts/truetype/courbi.ttf /usr/share/fonts/truetype/msttcorefonts/Courier_New_Bold_Italic.ttfsudo ln -s /usr/share/fonts/truetype/couri.ttf /usr/share/fonts/truetype/msttcorefonts/Courier_New_Italic.ttfsudo ln -s /usr/share/fonts/truetype/impact.ttf /usr/share/fonts/truetype/msttcorefonts/Impact.ttfsudo ln -s /usr/share/fonts/truetype/times.ttf /usr/share/fonts/truetype/msttcorefonts/Times_New_Roman.ttfsudo ln -s /usr/share/fonts/truetype/timesbd.ttf /usr/share/fonts/truetype/msttcorefonts/Times_New_Roman_Bold.ttfsudo ln -s /usr/share/fonts/truetype/timesbi.ttf /usr/share/fonts/truetype/msttcorefonts/Times_New_Roman_Bold_Italic.ttfsudo ln -s /usr/share/fonts/truetype/timesi.ttf /usr/share/fonts/truetype/msttcorefonts/Times_New_Roman_Italic.ttfsudo ln -s /usr/share/fonts/truetype/verdana.ttf /usr/share/fonts/truetype/msttcorefonts/Verdana.ttfsudo ln -s /usr/share/fonts/truetype/verdanab.ttf /usr/share/fonts/truetype/msttcorefonts/Verdana_Bold.ttfsudo ln -s /usr/share/fonts/truetype/verdanai.ttf /usr/share/fonts/truetype/msttcorefonts/Verdana_Italic.ttfsudo ln -s /usr/share/fonts/truetype/verdanaz.ttf /usr/share/fonts/truetype/msttcorefonts/Verdana_Bold_Italic.ttf

And then for the Java fonts:

sudo mkdir -p /usr/share/fonts/truetype/ttf-lucidasudo find /usr/lib*/jvm/java-1.6.*-sun-*/jre/lib -iname '*.ttf' -print \     -exec ln -s {} /usr/share/fonts/truetype/ttf-lucida \;












Checking out and building Chromium for Android

https://chromium.googlesource.com/chromium/src/+/master/docs/android_build_instructions.md

There are instructions for other platforms linked from the get the code page.

Instructions for Google Employees

Are you a Google employee? See go/building-chrome instead.

Contents

  • Instructions for Google Employees
  • System requirements
  • Install
  • Get the code
    • Converting an existing Linux checkout
    • Install additional build dependencies
    • Run the hooks
  • Setting up the build
  • Build Chromium
    • Multiple Chrome APK Targets
  • Installing and Running Chromium on a device
    • Plug in your Android device
    • Build the full browser
    • Build Content shell
    • Build WebView
    • Running
    • Logging and debugging
    • Testing
    • Faster Edit/Deploy
  • Tips, tricks, and troubleshooting
    • Rebuilding libchrome.so for a particular release

System requirements

  • A 64-bit Intel machine running Linux with at least 8GB of RAM. More than 16GB is highly recommended.
  • At least 100GB of free disk space.
  • You must have Git and Python installed already.

Most development is done on Ubuntu. Other distros may or may not work; see the Linux instructions for some suggestions.

Building the Android client on Windows or Mac is not supported and doesn't work.

Install depot_tools

Clone the depot_tools repository:

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

Add depot_tools to the end of your PATH (you will probably want to put this in your ~/.bashrc or ~/.zshrc). Assuming you cloned depot_tools to /path/to/depot_tools:

export PATH="$PATH:/path/to/depot_tools"

Get the code

Create a chromium directory for the checkout and change to it (you can call this whatever you like and put it wherever you like, as long as the full path has no spaces):

mkdir ~/chromium && cd ~/chromiumfetch --nohooks android

If you don't want the full repo history, you can save a lot of time by adding the --no-history flag to fetch.

Expect the command to take 30 minutes on even a fast connection, and many hours on slower ones.

If you've already installed the build dependencies on the machine (from another checkout, for example), you can omit the --nohooks flag and fetch will automatically execute gclient runhooks at the end.

When fetch completes, it will have created a hidden .gclient file and a directory called src in the working directory. The remaining instructions assume you have switched to the src directory:

cd src

Converting an existing Linux checkout

If you have an existing Linux checkout, you can add Android support by appending target_os = ['android'] to your .gclient file (in the directory above src):

echo "target_os = [ 'android' ]" >> ../.gclient

Then run gclient sync to pull the new Android dependencies:

gclient sync

(This is the only difference between fetch android and fetch chromium.)

Install additional build dependencies

Once you have checked out the code, run

build/install-build-deps-android.sh

to get all of the dependencies you need to build on Linux, plus all of the Android-specific dependencies (you need some of the regular Linux dependencies because an Android build includes a bunch of the Linux tools and utilities).

Run the hooks

Once you've run install-build-deps at least once, you can now run the Chromium-specific hooks, which will download additional binaries and other things you might need:

gclient runhooks

Optional: You can also install API keys if you want your build to talk to some Google services, but this is not necessary for most development and testing purposes.

Setting up the build

Chromium uses Ninja as its main build tool along with a tool called GN to generate .ninja files. You can create any number of build directories with different configurations. To create a build directory which builds Chrome for Android, run:

gn gen --args='target_os="android"' out/Default
  • You only have to run this once for each new build directory, Ninja will update the build files as needed.
  • You can replace Default with another name, but it should be a subdirectory of out.
  • For other build arguments, including release settings, see GN build configuration. The default will be a debug component build matching the current host operating system and CPU.
  • For more info on GN, run gn help on the command line or read the quick start guide.

Also be aware that some scripts (e.g. tombstones.pyadb_gdb.py) require you to set CHROMIUM_OUTPUT_DIR=out/Default.

Build Chromium

Build Chromium with Ninja using the command:

ninja -C out/Default chrome_public_apk

You can get a list of all of the other build targets from GN by running gn ls out/Default from the command line. To compile one, pass the GN label to Ninja with no preceding “//” (so, for //chrome/test:unit_tests use ninja -C out/Default chrome/test:unit_tests).

Multiple Chrome APK Targets

The Google Play Store allows apps to send customized .apk files depending on the version of Android running on a device. Chrome uses this feature to target 3 different versions using 3 different ninja targets:

  1. chrome_public_apk (ChromePublic.apk)
    • minSdkVersion=16 (Jelly Bean).
    • Stores libchrome.so compressed within the APK.
    • Uses Crazy Linker.
    • Shipped only for Android < 21, but still works fine on Android >= 21.
  2. chrome_modern_public_apk (ChromeModernPublic.apk)
    • minSdkVersion=21 (Lollipop).
    • Uses Crazy Linker.
    • Stores libchrome.so uncompressed within the APK.
      • This APK is bigger, but the installation size is smaller since there is no need to extract the .so file.
  3. monochrome_public_apk (MonochromePublic.apk)
    • minSdkVersion=24 (Nougat).
    • Contains both WebView and Chrome within the same APK.
      • This APK is even bigger, but much smaller than SystemWebView.apk + ChromePublic.apk.
    • Stores libchrome.so uncompressed within the APK.
    • Does not use Crazy Linker (WebView requires system linker).
      • But system linker supports crazy linker features now anyways.

Note: These instructions use chrome_public_apk, but either of the other two targets can be substituted.

Note: These targets are actually the open-source equivalents to the closed-source targets that get shipped to the Play Store.

Installing and Running Chromium on a device

Plug in your Android device

Make sure your Android device is plugged in via USB, and USB Debugging is enabled.

To enable USB Debugging:

  • Navigate to Settings > About Phone > Build number
  • Click ‘Build number’ 7 times
  • Now navigate back to Settings > Developer Options
  • Enable ‘USB Debugging’ and follow the prompts

You may also be prompted to allow access to your PC once your device is plugged in.

You can check if the device is connected by running:

third_party/android_tools/sdk/platform-tools/adb devices

Which prints a list of connected devices. If not connected, try unplugging and reattaching your device.

Build the full browser

ninja -C out/Default chrome_public_apk

And deploy it to your Android device:

out/Default/bin/chrome_public_apk install

The app will appear on the device as “Chromium”.

Build Content shell

Wraps the content module (but not the /chrome embedder). See https://www.chromium.org/developers/content-module for details on the content module and content shell.

ninja -C out/Default content_shell_apkout/Default/bin/content_shell_apk install

this will build and install an Android apk under out/Default/apks/ContentShell.apk.

Build WebView

Android WebView is a system framework component. Since Android KitKat, it is implemented using Chromium code (based off the content module).

If you want to build the complete Android WebView framework component and test the effect of your chromium changes in Android apps using WebView, you should follow the Android AOSP + chromium WebView instructions

Running

For Content shell:

out/Default/bin/content_shell_apk launch [--args='--foo --bar'] http://example.com

For Chrome public:

out/Default/bin/chrome_public_apk launch [--args='--foo --bar'] http://example.com

Logging and debugging

Logging is often the easiest way to understand code flow. In C++ you can print log statements using the LOG macro. In Java, refer to android_logging.md.

You can see these log via adb logcat, or:

out/Default/bin/chrome_public_apk logcat

To debug C++ code, use one of the following commands:

out/Default/bin/content_shell_apk gdbout/Default/bin/chrome_public_apk gdb

See Android Debugging Instructions for more on debugging, including how to debug Java code.

Testing

For information on running tests, see Android Test Instructions.

Faster Edit/Deploy

“Incremental install” uses reflection and side-loading to speed up the edit & deploy cycle (normally < 10 seconds). The initial launch of the apk will be a little slower since updated dex files are installed manually.

  • Make sure to setis_component_build = truein your GN args
  • All apk targets have *_incremental targets defined (e.g. chrome_public_apk_incremental) except for Webview and Monochrome

Here's an example:

ninja -C out/Default chrome_public_apk_incrementalout/Default/bin/chrome_public_apk install --incremental --verbose

For gunit tests (note that run_*_incremental automatically add --fast-local-dev when calling test_runner.py):

ninja -C out/Default base_unittests_incrementalout/Default/bin/run_base_unittests_incremental

For instrumentation tests:

ninja -C out/Default chrome_public_test_apk_incrementalout/Default/bin/run_chrome_public_test_apk_incremental

To uninstall:

out/Default/bin/chrome_public_apk uninstall

To avoid typing _incremental when building targets, you can use the GN arg:

incremental_apk_by_default = true

This will make chrome_public_apk build in incremental mode.

Tips, tricks, and troubleshooting

Rebuilding libchrome.so for a particular release

These instructions are only necessary for Chrome 51 and earlier.

In the case where you want to modify the native code for an existing release of Chrome for Android (v25+) you can do the following steps. Note that in order to get your changes into the official release, you'll need to send your change for a codereview using the regular process for committing code to chromium.

  1. Open Chrome on your Android device and visit chrome://version
  2. Copy down the id listed next to “Build ID:”
  3. Go to http://storage.googleapis.com/chrome-browser-components/BUILD_ID_FROM_STEP_2/index.html
  4. Download the listed files and follow the steps in the README.








Android端和Linux端用的是一套源代码;

Android端的编译

可以直接参考这里:https://webrtc.org/native-code/android/

比较简单:

gn gen out/Debug --args='target_os="android" target_cpu="arm"'
ninja -C out/Debug

Linux上的编译(Ubuntu16.04)


gn gen out/Debug --args='target_os="Linux" target_cpu="x64"'
ninja -C out/Debug








0 0