Chromium

Checking out and building Chromium for iOS

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.
[TOC]

System requirements

  • A 64-bit Mac running 10.11+.
  • Xcode 8.0+.
  • The OS X 10.10 SDK. Run
    $ ls `xcode-select -p`/Platforms/MacOSX.platform/Developer/SDKs
    
    to check whether you have it. Building with the 10.11 SDK works too, but
    the releases currently use the 10.10 SDK.
  • The current version of the JDK (required for the Closure compiler).

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 ios

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

Since the iOS build is a bit more complicated than a desktop build, we provide
ios/build/tools/setup-gn.py, which will create four appropriately configured
build directories under out for Release and Debug device and simulator
builds, and generates an appropriate Xcode workspace
(out/build/all.xcworkspace) as well.
You can customize the build by editing the file $HOME/.setup-gn (create it if
it does not exist). Look at src/ios/build/tools/setup-gn.config for
available configuration options.
From this point, you can either build from Xcode or from the command line using
ninja. setup-gn.py creates sub-directories named
out/${configuration}-${platform}, so for a Debug build for simulator use:

$ ninja -C out/Debug-iphonesimulator gn_all

Note: you need to run setup-gn.py script every time one of the BUILD.gn
file is updated (either by you or after rebasing). If you forget to run it,
the list of targets and files in the Xcode solution may be stale.
You can also follow the manual instructions on the
Mac page, but make sure you set the
GN arg target_os="ios".

Building for device

To be able to build and run Chromium and the tests for devices, you need to
have an Apple developer account (a free one will work) and the appropriate
provisioning profiles, then configure the build to use them.

Code signing identity

Please refer to the Apple documentation on how to get a code signing identity
and certificates. You can check that you have a code signing identity correctly
installed by running the following command.

$ xcrun security find-identity -v -p codesigning
  1) 0123456789ABCDEF0123456789ABCDEF01234567 "iPhone Developer: someone@example.com (XXXXXXXXXX)"
     1 valid identities found

If the command output says you have zero valid identities, then you do not
have a code signing identity installed and need to get one from Apple. If
you have more than one identity, the build system may select the wrong one
automatically, and you can use the ios_code_signing_identity gn variable
to control which one to use by setting it to the identity hash, e.g. to
"0123456789ABCDEF0123456789ABCDEF01234567".

Mobile provisioning profiles

Once you have the code signing identity, you need to decide on a prefix
for the application bundle identifier. This is controlled by the gn variable
ios_app_bundle_id_prefix and usually corresponds to a reversed domain name
(the default value is "org.chromium").
You then need to request provisioning profiles from Apple for your devices
for the following bundle identifiers to build and run Chromium with these
application extensions:

  • ${prefix}.chrome.ios.herebedragons
  • ${prefix}.chrome.ios.herebedragons.ShareExtension
  • ${prefix}.chrome.ios.herebedragons.TodayExtension
  • ${prefix}.chrome.ios.herebedragons.SearchTodayExtension
    All these certificates need to have the "App Groups"
    (com.apple.security.application-groups) capability enabled for
    the following groups:
  • group.${prefix}.chrome
  • group.${prefix}.common
    The group.${prefix}.chrome is only shared by Chromium and its extensions
    to share files and configurations while the group.${prefix}.common is shared
    with Chromium and other applications from the same organisation and can be used
    to send commands to Chromium.

Mobile provisioning profiles for tests

In addition to that, you need provisioning profiles for the individual test
suites that you want to run. Their bundle identifier depends on whether the
gn variable ios_automatically_manage_certs is set to true (the default)
or false.
If set to true, then you just need a provisioning profile for the bundle
identifier ${prefix}.gtest.generic-unit-test but you can only have a
single test application installed on the device (all the test application
will share the same bundle identifier).
If set to false, then you need a different provisioning profile for each
test application. Those provisioning profile will have a bundle identifier
matching the following pattern ${prefix}.gtest.${test-suite-name} where
${test-suite-name} is the name of the test suite with underscores changed
to dashes (e.g. base_unittests app will use ${prefix}.gest.base-unittests
as bundle identifier).
To be able to run the EarlGrey tests on a device, you'll need two provisioning
profiles for EarlGrey and OCHamcrest frameworks:

  • ${prefix}.test.OCHamcrest
  • ${prefix}.test.EarlGrey
    In addition to that, then you'll need one additional provisioning profile for
    the XCTest module too. This module bundle identifier depends on whether the
    gn variable ios_automatically_manage_certs is set to true or false. If set
    to true, then ${prefix}.test.gtest.generic-unit-test.generic-unit-test-module
    will be used, otherwise it will match the following pattern:
    ${prefix}.test.${test-suite-name}.${test-suite-name}-module.

Other applications

Other applications like ios_web_shell usually will require mobile provisioning
profiles with bundle identifiers that may usually match the following pattern
${prefix}.${application-name} and may require specific capabilities.
Generally, if the mobile provisioning profile is missing then the code signing
step will fail and will print the bundle identifier of the bundle that could not
be signed on the command line, e.g.:

$ ninja -C out/Debug-iphoneos ios_web_shell
ninja: Entering directory `out/Debug-iphoneos'
FAILED: ios_web_shell.app/ios_web_shell ios_web_shell.app/_CodeSignature/CodeResources ios_web_shell.app/embedded.mobileprovision
python ../../build/config/ios/codesign.py code-sign-bundle -t=iphoneos -i=0123456789ABCDEF0123456789ABCDEF01234567 -e=../../build/config/ios/entitlements.plist -b=obj/ios/web/shell/ios_web_shell ios_web_shell.app
Error: no mobile provisioning profile found for "org.chromium.ios-web-shell".
ninja: build stopped: subcommand failed.

Here, the build is failing because there are no mobile provisioning profiles
installed that could sign the ios_web_shell.app bundle with the identity
0123456789ABCDEF0123456789ABCDEF01234567. To fix the build, you'll need to
request such a mobile provisioning profile from Apple.
You can inspect the file passed via the -e flag to the codesign.py script
to check which capabilites are required for the mobile provisioning profile
(e.g. src/build/config/ios/entitlements.plist for the above build error,
remember that the paths are relative to the build directory, not to the source
directory).
If the required capabilities are not enabled on the mobile provisioning profile,
then it will be impossible to install the application on a device (Xcode will
display an error stating that "The application was signed with invalid
entitlements").

Running apps from the commandline

Any target that is built and runs on the bots (see below)
should run successfully in a local build. To run in the simulator from the
command line, you can use iossim. For example, to run a debug build of
Chromium:

$ out/Debug-iphonesimulator/iossim out/Debug-iphonesimulator/Chromium.app

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

If you have problems building, join us in #chromium on irc.freenode.net and
ask there. As mentioned above, be sure that the
waterfall is green and the tree
is open before checking out. This will increase your chances of success.

Improving performance of git status

Increase the vnode cache size

git status is used frequently to determine the status of your checkout. Due
to the large number of files in Chromium's checkout, git status performance
can be quite variable. Increasing the system's vnode cache appears to help.
By default, this command:

$ sysctl -a | egrep kern\..*vnodes

Outputs kern.maxvnodes: 263168 (263168 is 257 * 1024). To increase this
setting:

$ sudo sysctl kern.maxvnodes=$((512*1024))

Higher values may be appropriate if you routinely move between different
Chromium checkouts. This setting will reset on reboot, the startup setting can
be set in /etc/sysctl.conf:

$ echo kern.maxvnodes=$((512*1024)) | sudo tee -a /etc/sysctl.conf

Or edit the file directly.

Configure git to use an untracked cache

If git --version reports 2.8 or higher, try running

$ git update-index --test-untracked-cache

If the output ends with OK, then the following may also improve performance of
git status:

$ git config core.untrackedCache true

If git --version reports 2.6 or higher, but below 2.8, you can instead run

$ git update-index --untracked-cache

Xcode license agreement

If you're getting the error

Agreeing to the Xcode/iOS license requires admin privileges, please re-run as
root via sudo.
the Xcode license hasn't been accepted yet which (contrary to the message) any
user can do by running:

$ xcodebuild -license

Only accepting for all users of the machine requires root:

$ sudo xcodebuild -license
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 204,684评论 6 478
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 87,143评论 2 381
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 151,214评论 0 337
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 54,788评论 1 277
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 63,796评论 5 368
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 48,665评论 1 281
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 38,027评论 3 399
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 36,679评论 0 258
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 41,346评论 1 299
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 35,664评论 2 321
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 37,766评论 1 331
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 33,412评论 4 321
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 39,015评论 3 307
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 29,974评论 0 19
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 31,203评论 1 260
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 45,073评论 2 350
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 42,501评论 2 343

推荐阅读更多精彩内容