Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5)

Side by Side Diff: tools/mb/docs/user_guide.md

Issue 1370593003: Merge MB from trunk back to M45. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@branch_2454
Patch Set: Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « tools/mb/docs/design_spec.md ('k') | tools/mb/mb.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # The MB (Meta-Build wrapper) user guide 1 # The MB (Meta-Build wrapper) user guide
2 2
3 [TOC] 3 [TOC]
4 4
5 ## Introduction 5 ## Introduction
6 6
7 `mb` is a simple python wrapper around the GYP and GN meta-build tools to 7 `mb` is a simple python wrapper around the GYP and GN meta-build tools to
8 be used as part of the GYP->GN migration. 8 be used as part of the GYP->GN migration.
9 9
10 It is intended to be used by bots to make it easier to manage the configuration 10 It is intended to be used by bots to make it easier to manage the configuration
11 each bot builds (i.e., the configurations can be changed from chromium 11 each bot builds (i.e., the configurations can be changed from chromium
12 commits), and to consolidate the list of all of the various configurations 12 commits), and to consolidate the list of all of the various configurations
13 that Chromium is built in. 13 that Chromium is built in.
14 14
15 Ideally this tool will no longer be needed after the migration is complete. 15 Ideally this tool will no longer be needed after the migration is complete.
16 16
17 ## `mb gen` 17 For more discussion of MB, see also [the design spec](design_spec.md).
18 18
19 `mb gen` is responsible for generating the Ninja files by invoking either GYP 19 ## MB subcommands
20 or GN as appropriate. It takes arguments to specify a build config and
21 a directory, then runs GYP or GN as appropriate:
22 20
23 ``` 21 ### `mb analyze`
24 % mb gen -m tryserver.chromium.linux -b linux_rel //out/Release
25 % mb gen -c linux_rel_trybot //out/Release
26 ```
27
28 Either the `-c/--config` flag or the `-m/--master` and `-b/--builder` flags
29 must be specified so that `mb` can figure out which config to use.
30
31 The path must be a GN-style "source-absolute" path (as above).
32
33 If gen ends up using GYP, the path must have a valid GYP configuration as the
34 last component of the path (i.e., specify `//out/Release_x64`, not `//out`).
35
36 ## `mb analyze`
37 22
38 `mb analyze` is reponsible for determining what targets are affected by 23 `mb analyze` is reponsible for determining what targets are affected by
39 a list of files (e.g., the list of files in a patch on a trybot): 24 a list of files (e.g., the list of files in a patch on a trybot):
40 25
41 ``` 26 ```
42 mb analyze -c chromium_linux_rel //out/Release input.json output.json 27 mb analyze -c chromium_linux_rel //out/Release input.json output.json
43 ``` 28 ```
44 29
45 Either the `-c/--config` flag or the `-m/--master` and `-b/--builder` flags 30 Either the `-c/--config` flag or the `-m/--master` and `-b/--builder` flags
46 must be specified so that `mb` can figure out which config to use. 31 must be specified so that `mb` can figure out which config to use.
47 32
48
49 The first positional argument must be a GN-style "source-absolute" path 33 The first positional argument must be a GN-style "source-absolute" path
50 to the build directory. 34 to the build directory.
51 35
52 The second positional argument is a (normal) path to a JSON file containing 36 The second positional argument is a (normal) path to a JSON file containing
53 a single object with two fields: 37 a single object with two fields:
54 38
55 * `files`: an array of the modified filenames to check (as 39 * `files`: an array of the modified filenames to check (as
56 paths relative to the checkout root). 40 paths relative to the checkout root).
57 * `targets`: an array of the unqualified target names to check. 41 * `targets`: an array of the unqualified target names to check.
58 42
59 The third positional argument is a (normal) path to where mb will write 43 The third positional argument is a (normal) path to where mb will write
60 the result, also as a JSON object. This object may contain the following 44 the result, also as a JSON object. This object may contain the following
61 fields: 45 fields:
62 46
63 * `error`: this should only be present if something failed. 47 * `error`: this should only be present if something failed.
64 * `targets`: the subset of the input `targets` that depend on the 48 * `targets`: the subset of the input `targets` that depend on the
65 input `files`. 49 input `files`.
66 * `build_targets`: the minimal subset of targets needed to build all 50 * `build_targets`: the minimal subset of targets needed to build all
67 of `targets` that were affected. 51 of `targets` that were affected.
68 * `status`: one of three strings: 52 * `status`: one of three strings:
69 * `"Found dependency"` (build the `build_targets`) 53 * `"Found dependency"` (build the `build_targets`)
70 * `"No dependency"` (i.e., no build needed) 54 * `"No dependency"` (i.e., no build needed)
71 * `"Found dependency (all)"` (build everything, in which case 55 * `"Found dependency (all)"` (build everything, in which case
72 `targets` and `build_targets` are not returned). 56 `targets` and `build_targets` are not returned).
73 57
74 ## `mb help` 58 The `-b/--builder`, `-c/--config`, `-f/--config-file`, `-m/--master`,
59 `-q/--quiet`, and `-v/--verbose` flags work as documented for `mb gen`.
60
61
62 ### `mb gen`
63
64 `mb gen` is responsible for generating the Ninja files by invoking either GYP
65 or GN as appropriate. It takes arguments to specify a build config and
66 a directory, then runs GYP or GN as appropriate:
67
68 ```
69 % mb gen -m tryserver.chromium.linux -b linux_rel //out/Release
70 % mb gen -c linux_rel_trybot //out/Release
71 ```
72
73 Either the `-c/--config` flag or the `-m/--master` and `-b/--builder` flags
74 must be specified so that `mb` can figure out which config to use.
75
76 By default, MB will look in `//tools/mb/mb_config.pyl` to look up the config
77 information, but you can specify a custom config file using the
78 `-f/--config-file` flag.
79
80 The path must be a GN-style "source-absolute" path (as above).
81
82 You can pass the `-n/--dryrun` flag to mb gen to see what will happen without
83 actually writing anything.
84
85 You can pass the `-q/--quiet` flag to get mb to be silent unless there is an
86 error, and pass the `-v/--verbose` flag to get mb to log all of the files
87 that are read and written, and all the commands that are run.
88
89 If the build config will use the Goma distributed-build system, you can pass
90 the path to your Goma client in the `-g/--goma-dir` flag, and it will be
91 incorporated into the appropriate flags for GYP or GN as needed.
92
93 If gen ends up using GYP, the path must have a valid GYP configuration as the
94 last component of the path (i.e., specify `//out/Release_x64`, not `//out`).
95
96 ### `mb help`
75 97
76 Produces help output on the other subcommands 98 Produces help output on the other subcommands
77 99
78 ## `mb lookup` 100 ### `mb lookup`
79 101
80 Prints what command will be run by `mb gen` (like `mb gen -n` but does 102 Prints what command will be run by `mb gen` (like `mb gen -n` but does
81 not require you to specify a path). 103 not require you to specify a path).
82 104
83 ## `mb validate` 105 The `-b/--builder`, `-c/--config`, `-f/--config-file`, `-m/--master`,
106 `-q/--quiet`, and `-v/--verbose` flags work as documented for `mb gen`.
107
108 ### `mb validate`
84 109
85 Does internal checking to make sure the config file is syntactically 110 Does internal checking to make sure the config file is syntactically
86 valid and that all of the entries are used properly. It does not validate 111 valid and that all of the entries are used properly. It does not validate
87 that the flags make sense, or that the builder names are legal or 112 that the flags make sense, or that the builder names are legal or
88 comprehensive, but it does complain about configs and mixins that aren't 113 comprehensive, but it does complain about configs and mixins that aren't
89 used. 114 used.
90 115
116 The `-f/--config-file` and `-q/--quiet` flags work as documented for
117 `mb gen`.
118
91 This is mostly useful as a presubmit check and for verifying changes to 119 This is mostly useful as a presubmit check and for verifying changes to
92 the config file. 120 the config file.
93 121
94 ## mb_config.pyl 122 ## Isolates and Swarming
123
124 `mb gen` is also responsible for generating the `.isolate` and
125 `.isolated.gen.json` files needed to run test executables through swarming
126 in a GN build (in a GYP build, this is done as part of the compile step).
127
128 If you wish to generate the isolate files, pass `mb gen` the
129 `--swarming-targets-file` command line argument; that arg should be a path
130 to a file containing a list of ninja build targets to compute the runtime
131 dependencies for (on Windows, use the ninja target name, not the file, so
132 `base_unittests`, not `base_unittests.exe`).
133
134 MB will take this file, translate each build target to the matching GN
135 label (e.g., `base_unittests` -> `//base:base_unittests`, write that list
136 to a file called `runtime_deps` in the build directory, and pass that to
137 `gn gen $BUILD ... --runtime-deps-list-file=$BUILD/runtime_deps`.
138
139 Once GN has computed the lists of runtime dependencies, MB will then
140 look up the command line for each target (currently this is hard-coded
141 in [mb.py](https://code.google.com/p/chromium/codesearch?q=mb.py#chromium/src/to ols/mb/mb.py&q=mb.py%20GetIsolateCommand&sq=package:chromium&type=cs)), and writ e out the
142 matching `.isolate` and `.isolated.gen.json` files.
143
144 ## The `mb_config.pyl` config file
95 145
96 The `mb_config.pyl` config file is intended to enumerate all of the 146 The `mb_config.pyl` config file is intended to enumerate all of the
97 supported build configurations for Chromium. Generally speaking, you 147 supported build configurations for Chromium. Generally speaking, you
98 should never need to (or want to) build a configuration that isn't 148 should never need to (or want to) build a configuration that isn't
99 listed here, and so by using the configs in this file you can avoid 149 listed here, and so by using the configs in this file you can avoid
100 having to juggle long lists of GYP_DEFINES and gn args by hand. 150 having to juggle long lists of GYP_DEFINES and gn args by hand.
101 151
102 `mb_config.pyl` is structured as a file containing a single PYthon Literal 152 `mb_config.pyl` is structured as a file containing a single PYthon Literal
103 expression: a dictionary with three main keys, `masters`, `configs` and 153 expression: a dictionary with three main keys, `masters`, `configs` and
104 `mixins`. 154 `mixins`.
(...skipping 10 matching lines...) Expand all
115 configuration commonly used by develpers but that we may not have a bot 165 configuration commonly used by develpers but that we may not have a bot
116 for. 166 for.
117 167
118 The value of each key is a list of "mixins" that will define what that 168 The value of each key is a list of "mixins" that will define what that
119 build_config does. Each item in the list must be an entry in the dictionary 169 build_config does. Each item in the list must be an entry in the dictionary
120 value of the `mixins` key. 170 value of the `mixins` key.
121 171
122 Each mixin value is itself a dictionary that contains one or more of the 172 Each mixin value is itself a dictionary that contains one or more of the
123 following keys: 173 following keys:
124 174
125 * `gyp_configs`: a list of the configurations to build, e.g., 175 * `gyp_crosscompile`: a boolean; if true, GYP_CROSSCOMPILE=1 is set in
126 ['Release', 'Release_x64']. 176 the environment and passed to GYP.
127 * `gyp_defines`: a string containing a list of GYP_DEFINES. 177 * `gyp_defines`: a string containing a list of GYP_DEFINES.
128 * `gn_args`: a string containing a list of values passed to gn --args. 178 * `gn_args`: a string containing a list of values passed to gn --args.
129 * `mixins`: a list of other mixins that should be included. 179 * `mixins`: a list of other mixins that should be included.
130 * `type`: a string with either the value `gyp` or `gn`; 180 * `type`: a string with either the value `gyp` or `gn`;
131 setting this indicates which meta-build tool to use. 181 setting this indicates which meta-build tool to use.
132 182
133 When `mb gen` or `mb analyze` executes, it takes a config name, looks it 183 When `mb gen` or `mb analyze` executes, it takes a config name, looks it
134 up in the 'configs' dict, and then does a left-to-right expansion of the 184 up in the 'configs' dict, and then does a left-to-right expansion of the
135 mixins; gyp_defines and gn_args values are concatenated, and type and 185 mixins; gyp_defines and gn_args values are concatenated, and the type values
136 gyp_configs values override each other. 186 override each other.
137 187
138 For example, if you had: 188 For example, if you had:
139 189
140 ``` 190 ```
141 { 191 {
142 'configs`: { 192 'configs`: {
143 'linux_release_trybot': ['gyp_release', 'trybot'], 193 'linux_release_trybot': ['gyp_release', 'trybot'],
144 'gn_shared_debug': None, 194 'gn_shared_debug': None,
145 } 195 }
146 'mixins': { 196 'mixins': {
147 'bot': { 197 'bot': {
148 'gyp_defines': 'use_goma=1 dcheck_always_on=0', 198 'gyp_defines': 'use_goma=1 dcheck_always_on=0',
149 'gn_args': 'use_goma=true dcheck_always_on=false', 199 'gn_args': 'use_goma=true dcheck_always_on=false',
150 }, 200 },
151 'debug': { 201 'debug': {
152 'gn_args': 'is_debug=true', 202 'gn_args': 'is_debug=true',
153 }, 203 },
154 'gn': {'type': 'gn'}, 204 'gn': {'type': 'gn'},
155 'gyp_release': { 205 'gyp_release': {
156 'gyp_config': 'Release'
157 'mixins': ['release'], 206 'mixins': ['release'],
158 'type': 'gyp', 207 'type': 'gyp',
159 }, 208 },
160 'release': { 209 'release': {
161 'gn_args': 'is_debug=false', 210 'gn_args': 'is_debug=false',
162 } 211 }
163 'shared': { 212 'shared': {
164 'gn_args': 'is_component_build=true', 213 'gn_args': 'is_component_build=true',
165 'gyp_defines': 'component=shared_library', 214 'gyp_defines': 'component=shared_library',
166 }, 215 },
167 'trybot': { 216 'trybot': {
168 'gyp_defines': 'dcheck_always_on=1', 217 'gyp_defines': 'dcheck_always_on=1',
169 'gn_args': 'dcheck_always_on=true', 218 'gn_args': 'dcheck_always_on=true',
170 } 219 }
171 } 220 }
172 } 221 }
173 222
174 and you ran `mb gen -c linux_release_trybot //out/Release`, it would 223 and you ran `mb gen -c linux_release_trybot //out/Release`, it would
175 translate into a call to `gyp_chromium -G Release` with `GYP_DEFINES` set to 224 translate into a call to `gyp_chromium -G Release` with `GYP_DEFINES` set to
176 `"use_goma=true dcheck_always_on=false dcheck_always_on=true"`. 225 `"use_goma=true dcheck_always_on=false dcheck_always_on=true"`.
177 226
178 (From that you can see that mb is intentionally dumb and does not 227 (From that you can see that mb is intentionally dumb and does not
179 attempt to de-dup the flags, it lets gyp do that). 228 attempt to de-dup the flags, it lets gyp do that).
180 229
181 ## Debugging (-v/--verbose and -n/--dry-run) 230 ## Debugging MB
182 231
183 By design, MB should be simple enough that very little can go wrong. 232 By design, MB should be simple enough that very little can go wrong.
184 233
185 The most obvious issue is that you might see different commands being 234 The most obvious issue is that you might see different commands being
186 run than you expect; running `'mb -v'` will print what it's doing and 235 run than you expect; running `'mb -v'` will print what it's doing and
187 run the commands; `'mb -n'` will print what it will do but *not* run 236 run the commands; `'mb -n'` will print what it will do but *not* run
188 the commands. 237 the commands.
189 238
190 If you hit weirder things than that, add some print statements to the 239 If you hit weirder things than that, add some print statements to the
191 python script, send a question to gn-dev@chromium.org, or 240 python script, send a question to gn-dev@chromium.org, or
192 [file a bug](https://crbug.com/new) with the label 241 [file a bug](https://crbug.com/new) with the label
193 'mb' and cc: dpranke@chromium.org. 242 'mb' and cc: dpranke@chromium.org.
194 243
195 244
OLDNEW
« no previous file with comments | « tools/mb/docs/design_spec.md ('k') | tools/mb/mb.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698