OLD | NEW |
1 # Prerequisites | 1 # Mac Build Instructions |
2 | 2 |
3 * A Mac running 10.8+. | 3 [TOC] |
4 * http://developer.apple.com/tools/xcode/XCode, 5+ | |
5 * Install [gclient](http://dev.chromium.org/developers/how-tos/install-depot-t
ools), part of the [depot\_tools](http://dev.chromium.org/developers/how-tos/dep
ottools) package ([download](http://dev.chromium.org/developers/how-tos/install-
depot-tools)). gclient is a wrapper around svn that we use to manage our working
copies. | |
6 * Install [git](http://code.google.com/p/git-osx-installer/) on OSX 10.8. The
system git shipping with OS X 10.9 / Xcode 5 works well too. | |
7 * (optional -- required if you don't have some commands such as svn natively)
Install Xcode's "Command Line Tools" via Xcode menu -> Preferences -> Downloads | |
8 | 4 |
9 # Getting the code | 5 ## Prerequisites |
10 | 6 |
11 [Check out the source code](http://dev.chromium.org/developers/how-tos/get-the-c
ode) using Git. If you're new to the project, you can skip all the information a
bout git-svn, since you will not be committing directly to the repository. | 7 * A Mac running 10.8+. |
| 8 * http://developer.apple.com/tools/xcode/XCode, 5+ |
| 9 * Install |
| 10 [gclient](http://dev.chromium.org/developers/how-tos/install-depot-tools), |
| 11 part of the |
| 12 [depot_tools](http://dev.chromium.org/developers/how-tos/depottools) package |
| 13 ([download](http://dev.chromium.org/developers/how-tos/install-depot-tools))
. |
| 14 gclient is a wrapper around svn that we use to manage our working copies. |
| 15 * Install [git](http://code.google.com/p/git-osx-installer/) on OSX 10.8. The |
| 16 system git shipping with OS X 10.9 / Xcode 5 works well too. |
| 17 * (optional -- required if you don't have some commands such as svn natively) |
| 18 Install Xcode's "Command Line Tools" via Xcode menu -> Preferences -> |
| 19 Downloads |
12 | 20 |
13 Before checking out, go to the [waterfall](http://build.chromium.org/buildbot/wa
terfall/) and check that the source tree is open (to avoid pulling a broken tree
). | 21 ## Getting the code |
14 | 22 |
15 The path to the build directory should not contain spaces (e.g. not "~/Mac OS X/
chromium"), as this will cause the build to fail. This includes your drive name
, the default "Macintosh HD2" for a second drive has a space. | 23 [Check out the source code](http://dev.chromium.org/developers/how-tos/get-the-c
ode) |
| 24 using Git. If you're new to the project, you can skip all the information about |
| 25 git-svn, since you will not be committing directly to the repository. |
16 | 26 |
17 # Building | 27 Before checking out, go to the |
| 28 [waterfall](http://build.chromium.org/buildbot/waterfall/) and check that the |
| 29 source tree is open (to avoid pulling a broken tree). |
18 | 30 |
19 Chromium on OS X can only be built using the [Ninja](NinjaBuild.md) tool and the
[Clang](Clang.md) compiler. See both of those pages for further details on how
to tune the build. | 31 The path to the build directory should not contain spaces (e.g. not |
| 32 `~/Mac OS X/chromium`), as this will cause the build to fail. This includes your |
| 33 drive name, the default "Macintosh HD2" for a second drive has a space. |
20 | 34 |
21 Before you build, you may want to [install API keys](https://sites.google.com/a/
chromium.org/dev/developers/how-tos/api-keys) so that Chrome-integrated Google s
ervices work. This step is optional if you aren't testing those features. | 35 ## Building |
22 | 36 |
23 ## Raising system-wide and per-user process limits | 37 Chromium on OS X can only be built using the [Ninja](ninja_build.md) tool and |
| 38 the [Clang](clang.md) compiler. See both of those pages for further details on |
| 39 how to tune the build. |
| 40 |
| 41 Before you build, you may want to |
| 42 [install API keys](https://sites.google.com/a/chromium.org/dev/developers/how-to
s/api-keys) |
| 43 so that Chrome-integrated Google services work. This step is optional if you |
| 44 aren't testing those features. |
| 45 |
| 46 ### Raising system-wide and per-user process limits |
24 | 47 |
25 If you see errors like the following: | 48 If you see errors like the following: |
26 | 49 |
27 ``` | 50 ``` |
28 clang: error: unable to execute command: posix_spawn failed: Resource temporaril
y unavailable | 51 clang: error: unable to execute command: posix_spawn failed: Resource temporaril
y unavailable |
29 clang: error: clang frontend command failed due to signal (use -v to see invocat
ion) | 52 clang: error: clang frontend command failed due to signal (use -v to see invocat
ion) |
30 ``` | 53 ``` |
31 | 54 |
32 you may be running into too-low limits on the number of concurrent processes all
owed on the machine. Check: | 55 you may be running into too-low limits on the number of concurrent processes |
| 56 allowed on the machine. Check: |
33 | 57 |
34 ``` | 58 sysctl kern.maxproc |
35 sysctl kern.maxproc | 59 sysctl kern.maxprocperuid |
36 sysctl kern.maxprocperuid | |
37 ``` | |
38 | 60 |
39 You can increase them with e.g.: | 61 You can increase them with e.g.: |
40 | 62 |
41 ``` | 63 sudo sysctl -w kern.maxproc=2500 |
42 sudo sysctl -w kern.maxproc=2500 | 64 sudo sysctl -w kern.maxprocperuid=2500 |
43 sudo sysctl -w kern.maxprocperuid=2500 | |
44 ``` | |
45 | 65 |
46 But normally this shouldn't be necessary if you're building on 10.7 or higher. I
f you see this, check if some rogue program spawned hundreds of processes and ki
ll them first. | 66 But normally this shouldn't be necessary if you're building on 10.7 or higher. |
| 67 If you see this, check if some rogue program spawned hundreds of processes and |
| 68 kill them first. |
47 | 69 |
48 # Faster builds | 70 ## Faster builds |
49 | 71 |
50 Full rebuilds are about the same speed in Debug and Release, but linking is a lo
t faster in Release builds. | 72 Full rebuilds are about the same speed in Debug and Release, but linking is a |
| 73 lot faster in Release builds. |
51 | 74 |
52 Run | 75 Run |
53 ``` | |
54 GYP_DEFINES=fastbuild=1 build/gyp_chromium | |
55 ``` | |
56 to disable debug symbols altogether, this makes both full rebuilds and linking f
aster (at the cost of not getting symbolized backtraces in gdb). | |
57 | 76 |
58 You might also want to [install ccache](CCacheMac.md) to speed up the build. | 77 GYP_DEFINES=fastbuild=1 build/gyp_chromium |
59 | 78 |
60 # Running | 79 to disable debug symbols altogether, this makes both full rebuilds and linking |
| 80 faster (at the cost of not getting symbolized backtraces in gdb). |
61 | 81 |
62 All build output is located in the `out` directory (in the example above, `~/chr
omium/src/out`). You can find the applications at `{Debug|Release}/ContentShell
.app` and `{Debug|Release}/Chromium.app`, depending on the selected configuratio
n. | 82 You might also want to [install ccache](ccache_cac.md) to speed up the build. |
63 | 83 |
64 # Unit Tests | 84 ## Running |
65 | 85 |
66 We have several unit test targets that build, and tests that run and pass. A sma
ll subset of these is: | 86 All build output is located in the `out` directory (in the example above, |
| 87 `~/chromium/src/out`). You can find the applications at |
| 88 `{Debug|Release}/ContentShell.app` and `{Debug|Release}/Chromium.app`, depending |
| 89 on the selected configuration. |
67 | 90 |
68 * `unit_tests` from `chrome/chrome.gyp` | 91 ## Unit Tests |
69 * `base_unittests` from `base/base.gyp` | |
70 * `net_unittests` from `net/net.gyp` | |
71 * `url_unittests` from `url/url.gyp` | |
72 | 92 |
73 When these tests are built, you will find them in the `out/{Debug|Release}` dire
ctory. You can run them from the command line: | 93 We have several unit test targets that build, and tests that run and pass. A |
74 ``` | 94 small subset of these is: |
75 ~/chromium/src/out/Release/unit_tests | |
76 ``` | |
77 | 95 |
78 # Coding | 96 * `unit_tests` from `chrome/chrome.gyp` |
| 97 * `base_unittests` from `base/base.gyp` |
| 98 * `net_unittests` from `net/net.gyp` |
| 99 * `url_unittests` from `url/url.gyp` |
79 | 100 |
80 According to the [Chromium style guide](http://dev.chromium.org/developers/codin
g-style) code is [not allowed to have whitespace on the ends of lines](http://go
ogle-styleguide.googlecode.com/svn/trunk/cppguide.xml#Horizontal_Whitespace). If
you edit in Xcode, know that it loves adding whitespace to the ends of lines wh
ich can make editing in Xcode more painful than it should be. The [GTM Xcode Plu
gin](http://code.google.com/p/google-toolbox-for-mac/downloads/list) adds a pref
erence panel to Xcode that allows you to strip whitespace off of the ends of lin
es on save. Documentation on how to install it is [here](http://code.google.com/
p/google-toolbox-for-mac/wiki/GTMXcodePlugin). | 101 When these tests are built, you will find them in the `out/{Debug|Release}` |
| 102 directory. You can run them from the command line: |
81 | 103 |
82 # Debugging | 104 ~/chromium/src/out/Release/unit_tests |
83 | 105 |
84 Good debugging tips can be found [here](http://dev.chromium.org/developers/how-t
os/debugging-on-os-x). If you would like to debug in a graphical environment, ra
ther than using `lldb` at the command line, that is possible without building in
Xcode. See [Debugging in Xcode](http://www.chromium.org/developers/debugging-on
-os-x/building-with-ninja-debugging-with-xcode) for information on how. | |
85 | 106 |
86 # Contributing | 107 ## Coding |
87 | 108 |
88 Once you’re comfortable with building Chromium, check out [Contributing Code](ht
tp://dev.chromium.org/developers/contributing-code) for information about writin
g code for Chromium and contributing it. | 109 According to the |
| 110 [Chromium style guide](http://dev.chromium.org/developers/coding-style) code is |
| 111 [not allowed to have whitespace on the ends of lines](http://google-styleguide.g
ooglecode.com/svn/trunk/cppguide.xml#Horizontal_Whitespace). |
| 112 If you edit in Xcode, know that it loves adding whitespace to the ends of lines |
| 113 which can make editing in Xcode more painful than it should be. The |
| 114 [GTM Xcode Plugin](http://code.google.com/p/google-toolbox-for-mac/downloads/lis
t) |
| 115 adds a preference panel to Xcode that allows you to strip whitespace off of the |
| 116 ends of lines on save. Documentation on how to install it is |
| 117 [here](http://code.google.com/p/google-toolbox-for-mac/wiki/GTMXcodePlugin). |
89 | 118 |
90 # Using Xcode-Ninja Hybrid | 119 ## Debugging |
91 | 120 |
92 While using Xcode is unsupported, GYP supports a hybrid approach of using ninja
for building, but Xcode for editing and driving compliation. Xcode can still be
slow, but it runs fairly well even **with indexing enabled**. | 121 Good debugging tips can be found |
| 122 [here](http://dev.chromium.org/developers/how-tos/debugging-on-os-x). If you |
| 123 would like to debug in a graphical environment, rather than using `lldb` at the |
| 124 command line, that is possible without building in Xcode. See |
| 125 [Debugging in Xcode](http://www.chromium.org/developers/debugging-on-os-x/buildi
ng-with-ninja-debugging-with-xcode) |
| 126 for information on how. |
93 | 127 |
94 With hybrid builds, compilation is still handled by ninja, and can be run by the
command line (e.g. ninja -C out/Debug chrome) or by choosing the chrome target
in the hybrid workspace and choosing build. | 128 ## Contributing |
| 129 |
| 130 Once you’re comfortable with building Chromium, check out |
| 131 [Contributing Code](http://dev.chromium.org/developers/contributing-code) for |
| 132 information about writing code for Chromium and contributing it. |
| 133 |
| 134 ## Using Xcode-Ninja Hybrid |
| 135 |
| 136 While using Xcode is unsupported, GYP supports a hybrid approach of using ninja |
| 137 for building, but Xcode for editing and driving compliation. Xcode can still be |
| 138 slow, but it runs fairly well even **with indexing enabled**. |
| 139 |
| 140 With hybrid builds, compilation is still handled by ninja, and can be run by the |
| 141 command line (e.g. ninja -C out/Debug chrome) or by choosing the chrome target |
| 142 in the hybrid workspace and choosing build. |
95 | 143 |
96 To use Xcode-Ninja Hybrid, set `GYP_GENERATORS=ninja,xcode-ninja`. | 144 To use Xcode-Ninja Hybrid, set `GYP_GENERATORS=ninja,xcode-ninja`. |
97 | 145 |
98 Due to the way Xcode parses ninja output paths, it's also necessary to change th
e main gyp location to anything two directories deep. Otherwise Xcode build out
put will not be clickable. Adding `xcode_ninja_main_gyp=src/build/ninja/all.nin
ja.gyp` to your GYP\_GENERATOR\_FLAGS will fix this. | 146 Due to the way Xcode parses ninja output paths, it's also necessary to change |
| 147 the main gyp location to anything two directories deep. Otherwise Xcode build |
| 148 output will not be clickable. Adding |
| 149 `xcode_ninja_main_gyp=src/build/ninja/all.ninja.gyp` to your |
| 150 `GYP_GENERATOR_FLAGS` will fix this. |
99 | 151 |
100 After generating the project files with gclient runhooks, open `src/build/ninja/
all.ninja.xcworkspace`. | 152 After generating the project files with gclient runhooks, open |
| 153 `src/build/ninja/all.ninja.xcworkspace`. |
101 | 154 |
102 You may run into a problem where http://YES is opened as a new tab every time yo
u launch Chrome. To fix this, open the scheme editor for the Run scheme, choose
the Options tab, and uncheck "Allow debugging when using document Versions Brows
er". When this option is checked, Xcode adds --NSDocumentRevisionsDebugMode YES
to the launch arguments, and the YES gets interpreted as a URL to open. | 155 You may run into a problem where http://YES is opened as a new tab every time |
| 156 you launch Chrome. To fix this, open the scheme editor for the Run scheme, |
| 157 choose the Options tab, and uncheck "Allow debugging when using document |
| 158 Versions Browser". When this option is checked, Xcode adds |
| 159 `--NSDocumentRevisionsDebugMode YES` to the launch arguments, and the `YES` gets |
| 160 interpreted as a URL to open. |
103 | 161 |
104 If you want to limit the number of targets visible, which is known to improve Xc
ode performance, add `xcode_ninja_executable_target_pattern=%target%` where %tar
get% is a regular expression matching executable targets you'd like to include. | 162 If you want to limit the number of targets visible, which is known to improve |
| 163 Xcode performance, add `xcode_ninja_executable_target_pattern=%target%` where |
| 164 `%target%` is a regular expression matching executable targets you'd like to |
| 165 include. |
105 | 166 |
106 To include non-executable targets, use `xcode_ninja_target_pattern=All_iOS`. | 167 To include non-executable targets, use `xcode_ninja_target_pattern=All_iOS`. |
107 | 168 |
108 If you have problems building, join us in `#chromium` on `irc.freenode.net` and
ask there. As mentioned above, be sure that the [waterfall](http://build.chromiu
m.org/buildbot/waterfall/) is green and the tree is open before checking out. Th
is will increase your chances of success. | 169 If you have problems building, join us in `#chromium` on `irc.freenode.net` and |
| 170 ask there. As mentioned above, be sure that the |
| 171 [waterfall](http://build.chromium.org/buildbot/waterfall/) is green and the tree |
| 172 is open before checking out. This will increase your chances of success. |
109 | 173 |
110 There is also a dedicated [Xcode tips](Xcode4Tips.md) page that you may want to
read. | 174 ## Using Emacs as `EDITOR` for `git commit` |
111 | 175 |
112 | 176 Using the [Cocoa version of Emacs](http://emacsformacosx.com/) as the `EDITOR` |
113 # Using Emacs as EDITOR for "git commit" | 177 environment variable on Mac OS will cause `git commit` to open the message in a |
114 | 178 window underneath all the others. To fix this, create a shell script somewhere |
115 Using the [Cocoa version of Emacs](http://emacsformacosx.com/) as the EDITOR env
ironment variable on Mac OS will cause "git commit" to open the message in a win
dow underneath all the others. To fix this, create a shell script somewhere (cal
l it $HOME/bin/[EmacsEditor](EmacsEditor.md) in this example) containing the fol
lowing: | 179 (call it `$HOME/bin/EmacsEditor` in this example) containing the following: |
116 | 180 |
117 ``` | 181 ``` |
118 #!/bin/sh | 182 #!/bin/sh |
119 | 183 |
120 # All of these hacks are needed to get "git commit" to launch a new | 184 # All of these hacks are needed to get "git commit" to launch a new |
121 # instance of Emacs on top of everything else, properly pointing to | 185 # instance of Emacs on top of everything else, properly pointing to |
122 # the COMMIT_EDITMSG. | 186 # the COMMIT_EDITMSG. |
123 | 187 |
124 realpath() { | 188 realpath() { |
125 [[ $1 = /* ]] && echo "$1" || echo "$PWD/${1#./}" | 189 [[ $1 = /* ]] && echo "$1" || echo "$PWD/${1#./}" |
126 } | 190 } |
127 | 191 |
128 i=0 | 192 i=0 |
129 full_paths=() | 193 full_paths=() |
130 for arg in "$@" | 194 for arg in "$@" |
131 do | 195 do |
132 full_paths[$i]=$(realpath $arg) | 196 full_paths[$i]=$(realpath $arg) |
133 ((++i)) | 197 ((++i)) |
134 done | 198 done |
135 | 199 |
136 open -nWa /Applications/Emacs.app/Contents/MacOS/Emacs --args --no-desktop "${fu
ll_paths[@]}" | 200 open -nWa /Applications/Emacs.app/Contents/MacOS/Emacs --args --no-desktop \ |
| 201 "${full_paths[@]}" |
137 ``` | 202 ``` |
138 | 203 |
139 and in your .bashrc or similar, | 204 and in your `.bashrc` or similar, |
140 | 205 |
141 ``` | 206 export EDITOR=$HOME/bin/EmacsEditor |
142 export EDITOR=$HOME/bin/EmacsEditor | |
143 ``` | |
OLD | NEW |