OLD | NEW |
1 The Chromium build system is a complicated beast of a system, and it is not very
well documented beyond the basics of getting the source and building the Chromi
um product. This page has more advanced information about the build system. | 1 # Common Build Tasks |
2 | 2 |
3 If you're new to Chromium development, read the [getting started guides](http://
dev.chromium.org/developers/how-tos/get-the-code). | 3 The Chromium build system is a complicated beast of a system, and it is not very |
| 4 well documented beyond the basics of getting the source and building the |
| 5 Chromium product. This page has more advanced information about the build |
| 6 system. |
4 | 7 |
| 8 If you're new to Chromium development, read the |
| 9 [getting started guides](http://dev.chromium.org/developers/how-tos/get-the-code
). |
5 | 10 |
| 11 [TOC] |
6 | 12 |
7 # Faster Builds | 13 ## Faster Builds |
8 | 14 |
9 ## Components Build | 15 ### Components Build |
10 | 16 |
11 A non-standard build configuration is to use dynamic linking instead of static l
inking for the various modules in the Chromium codebase. This results in signifi
cantly faster link times, but is a divergence from what is shipped and primarily
tested. To enable the [component build](http://www.chromium.org/developers/how-
tos/component-build): | 17 A non-standard build configuration is to use dynamic linking instead of static |
| 18 linking for the various modules in the Chromium codebase. This results in |
| 19 significantly faster link times, but is a divergence from what is shipped and |
| 20 primarily tested. To enable the |
| 21 [component build](http://www.chromium.org/developers/how-tos/component-build): |
12 | 22 |
13 ``` | 23 $ GYP_DEFINES="component=shared_library" gclient runhooks |
14 $ GYP_DEFINES="component=shared_library" gclient runhooks | |
15 ``` | |
16 | 24 |
17 or | 25 or |
18 | 26 |
19 ``` | 27 ``` |
20 C:\...\src>set GYP_DEFINES=component=shared_library | 28 C:\...\src>set GYP_DEFINES=component=shared_library |
21 C:\...\src>gclient runhooks | 29 C:\...\src>gclient runhooks |
22 ``` | 30 ``` |
23 | 31 |
| 32 ### Windows: Debug Builds Link Faster |
24 | 33 |
25 ## Windows: Debug Builds Link Faster | 34 On Windows if using the components build, building in debug mode will generally |
| 35 link faster. This is because in debug mode, the linker works incrementally. In |
| 36 release mode, a full link is performed each time. |
26 | 37 |
27 On Windows if using the components build, building in debug mode will generally
link faster. This is because in debug mode, the linker works incrementally. In r
elease mode, a full link is performed each time. | 38 ### Mac: Disable Release Mode Stripping |
28 | 39 |
29 ## Mac: Disable Release Mode Stripping | 40 On Mac, if building in release mode, one of the final build steps will be to |
| 41 strip the build products and create dSYM files. This process can slow down your |
| 42 incremental builds, but it can be disabled with the following define: |
30 | 43 |
31 On Mac, if building in release mode, one of the final build steps will be to str
ip the build products and create dSYM files. This process can slow down your inc
remental builds, but it can be disabled with the following define: | 44 $ GYP_DEFINES="mac_strip_release=0" gclient runhooks |
32 | 45 |
33 ``` | 46 ### Mac: DCHECKs in Release Mode |
34 $ GYP_DEFINES="mac_strip_release=0" gclient runhooks | |
35 ``` | |
36 | 47 |
37 ## Mac: DCHECKs in Release Mode | 48 DCHECKs are only designed to be run in debug builds. But building in release |
| 49 mode on Mac is significantly faster. You can have your cake and eat it too by |
| 50 building release mode with DCHECKs enabled using the following define: |
38 | 51 |
39 DCHECKs are only designed to be run in debug builds. But building in release mod
e on Mac is significantly faster. You can have your cake and eat it too by build
ing release mode with DCHECKs enabled using the following define: | 52 $ GYP_DEFINES="dcheck_always_on=1" gclient runhooks |
40 | 53 |
41 ``` | 54 ### Linux |
42 $ GYP_DEFINES="dcheck_always_on=1" gclient runhooks | |
43 ``` | |
44 | 55 |
45 ## Linux | 56 Linux has its own page on [making the build faster](linux_faster_builds.md). |
46 | 57 |
47 Linux has its own page on [making the build faster](https://code.google.com/p/ch
romium/wiki/LinuxFasterBuilds). | 58 ## Configuring the Build |
48 | 59 |
49 # Configuring the Build | 60 ### Environment Variables |
50 | 61 |
51 ## Environment Variables | 62 There are various environment variables that can be passed to the metabuild |
| 63 system GYP when generating project files. This is a summary of them: |
52 | 64 |
53 There are various environment variables that can be passed to the metabuild syst
em GYP when generating project files. This is a summary of them: | 65 TODO(andybons): Convert to list. |
54 | 66 |
55 | GYP\_DEFINES | A set of key=value pairs separated by space that will set defau
lt values of variables used in .gyp and .gypi files | | 67 | GYP\_DEFINES | A set of key=value pairs separated by space that will set defau
lt values of variables used in .gyp and .gypi files | |
56 |:-------------|:---------------------------------------------------------------
----------------------------------------------------| | 68 |:-------------|:---------------------------------------------------------------
----------------------------------------------------| |
57 | GYP\_GENERATORS | The specific generator that creates build-system specific fi
les | | 69 | GYP\_GENERATORS | The specific generator that creates build-system specific fi
les | |
58 | GYP\_GENERATOR\_FLAGS | Flags that are passed down to the tool that generates
the build-system specific files | | 70 | GYP\_GENERATOR\_FLAGS | Flags that are passed down to the tool that generates
the build-system specific files | |
59 | GYP\_GENERATOR\_OUTPUT | The directory that the top-level build output directo
ry is relative to | | 71 | GYP\_GENERATOR\_OUTPUT | The directory that the top-level build output directo
ry is relative to | |
60 | 72 |
61 Note also that GYP uses CPPFLAGS, CFLAGS, and CXXFLAGS when generating ninja fil
es (the values at build time = ninja run time are _not_ used); see [gyp/generato
r/ninja.py](https://code.google.com/p/chromium/codesearch#chromium/src/tools/gyp
/pylib/gyp/generator/ninja.py&q=cxxflags). | 73 Note also that GYP uses CPPFLAGS, CFLAGS, and CXXFLAGS when generating ninja |
| 74 files (the values at build time = ninja run time are _not_ used); see |
| 75 [gyp/generator/ninja.py](https://code.google.com/p/chromium/codesearch#chromium/
src/tools/gyp/pylib/gyp/generator/ninja.py&q=cxxflags). |
62 | 76 |
63 ## Variable Files | 77 ### Variable Files |
64 | 78 |
65 If you want to keep a set of variables established, there are a couple of magic
files that GYP reads: | 79 If you want to keep a set of variables established, there are a couple of magic |
| 80 files that GYP reads: |
66 | 81 |
67 ### chromium.gyp\_env | 82 #### chromium.gyp\_env |
68 | 83 |
69 Next to your top-level `/src/` directory, create a file called `chromium.gyp_env
`. This holds a JSON dictionary, with the keys being any of the above environmen
t variables. For the full list of supported keys, see [/src/build/gyp\_helper.py
](https://code.google.com/p/chromium/codesearch#chromium/src/build/gyp_helper.py
&sq=package:chromium&type=cs&q=file:gyp_helper.py%5Cb). | 84 Next to your top-level `/src/` directory, create a file called |
| 85 `chromium.gyp_env`. This holds a JSON dictionary, with the keys being any of the |
| 86 above environment variables. For the full list of supported keys, see |
| 87 [/src/build/gyp_helper.py](/build/gyp_helper.py). |
70 | 88 |
71 ``` | 89 ``` { |
72 { | |
73 'variables': { | 90 'variables': { |
74 'mac_strip_release': 0, | 91 'mac_strip_release': 0, |
75 }, | 92 }, 'GYP_DEFINES': |
76 'GYP_DEFINES': | 93 'clang=1 ' 'component=shared_library ' 'dcheck_always_on=1 ' |
77 'clang=1 ' | 94 } ``` |
78 'component=shared_library ' | |
79 'dcheck_always_on=1 ' | |
80 } | |
81 ``` | |
82 | 95 |
83 | 96 #### include.gyp |
84 ### include.gyp | |
85 | 97 |
86 Or globally in your home directory, create a file `~/.gyp/include.gypi`. | 98 Or globally in your home directory, create a file `~/.gyp/include.gypi`. |
87 | 99 |
88 ### supplement.gypi | 100 #### supplement.gypi |
89 | 101 |
90 The build system will also include any files named `/src/*/supplement.gypi`, whi
ch should be in the same format as include.gyp above. | 102 The build system will also include any files named `/src/*/supplement.gypi`, |
| 103 which should be in the same format as include.gyp above. |
91 | 104 |
92 ## Change the Build System | 105 ### Change the Build System |
93 | 106 |
94 Most platforms support multiple build systems (Windows: different Visual Studios
versions and ninja, Mac: Xcode and ninja, etc.). A sensible default is selected
, but it can be overridden: | 107 Most platforms support multiple build systems (Windows: different Visual Studios |
| 108 versions and ninja, Mac: Xcode and ninja, etc.). A sensible default is selected, |
| 109 but it can be overridden: |
95 | 110 |
96 ``` | 111 $ GYP_GENERATORS=ninja gclient runhooks |
97 $ GYP_GENERATORS=ninja gclient runhooks | |
98 ``` | |
99 | 112 |
100 [Ninja](https://code.google.com/p/chromium/wiki/NinjaBuild) is generally the fas
test way to build anything on any platform. | 113 [Ninja](ninja_build.md) is generally the fastest way to build anything on any |
| 114 platform. |
101 | 115 |
102 ## Change Build Output Directory | 116 ### Change Build Output Directory |
103 | 117 |
104 If you need to change a compile-time flag and do not want to touch your current
build output, you can re-run GYP and place output into a new directory, like so,
assuming you are using ninja: | 118 If you need to change a compile-time flag and do not want to touch your current |
| 119 build output, you can re-run GYP and place output into a new directory, like so, |
| 120 assuming you are using ninja: |
105 | 121 |
106 ``` | 122 ```shell |
107 $ GYP_GENERATOR_FLAGS="output_dir=out_other_ninja" gclient runhooks | 123 $ GYP_GENERATOR_FLAGS="output_dir=out_other_ninja" gclient runhooks |
108 $ ninja -C out_other_ninja/Release chrome | 124 $ ninja -C out_other_ninja/Release chrome |
109 ``` | 125 ``` |
110 | 126 |
111 Alternatively, you can do the following, which should work with all GYP generato
rs, but the out directory is nested as `out_other/out/`. | 127 Alternatively, you can do the following, which should work with all GYP |
| 128 generators, but the out directory is nested as `out_other/out/`. |
112 | 129 |
113 ``` | 130 ```shell |
114 $ GYP_GENERATOR_OUTPUT="out_other" gclient runhooks | 131 $ GYP_GENERATOR_OUTPUT="out_other" gclient runhooks |
115 $ ninja -C out_other/out/Release chrome | 132 $ ninja -C out_other/out/Release chrome |
116 ``` | 133 ``` |
117 | 134 |
118 **Note:** If you wish to run the WebKit layout tests, make sure you specify the
new directory using `--build-directory=out_other_ninja` (don't include the `Rele
ase` part). | 135 **Note:** If you wish to run the WebKit layout tests, make sure you specify the |
| 136 new directory using `--build-directory=out_other_ninja` (don't include the |
| 137 `Release` part). |
119 | 138 |
120 ## Building Google Chrome | 139 ### Building Google Chrome |
121 | 140 |
122 To build Chrome, you need to be a Google employee and have access to the [src-in
ternal](http://go.ext.google.com/src-internal) repository. Once your checkout is
set up, you can run gclient like so: | 141 To build Chrome, you need to be a Google employee and have access to the |
| 142 [src-internal](https://goto.google.com/src-internal) repository. Once your |
| 143 checkout is set up, you can run gclient like so: |
123 | 144 |
124 ``` | 145 $ GYP_DEFINES="branding=Chrome buildtype=Official" gclient runhooks |
125 $ GYP_DEFINES="branding=Chrome buildtype=Official" gclient runhooks | |
126 ``` | |
127 | 146 |
128 Then building the `chrome` target will produce the official build. This tip can
be used in conjunction with changing the output directory, since changing these
defines will rebuild the world. | 147 Then building the `chrome` target will produce the official build. This tip can |
| 148 be used in conjunction with changing the output directory, since changing these |
| 149 defines will rebuild the world. |
129 | 150 |
130 Also note that some GYP\_DEFINES flags are incompatible with the official build.
If you get an error when you try to build, try removing all your flags and star
t with just the above ones. | 151 Also note that some GYP\_DEFINES flags are incompatible with the official build. |
| 152 If you get an error when you try to build, try removing all your flags and start |
| 153 with just the above ones. |
OLD | NEW |