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

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

Issue 1062613004: Implement mb - a meta-build wrapper for bots to use in the GYP->GN migration. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: bug fixes and tests, reorganize mb_config.pyl Created 5 years, 8 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 » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 # The MB (Meta-Build wrapper) user guide
2
3 [TOC]
4
5 ## Introduction
6
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.
9
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
12 commits), and to consolidate the list of all of the various configurations
13 that Chromium is built in.
14
15 Ideally this tool will no longer be needed after the migration is complete.
16
17 ## `mb gen`
18
19 `mb gen` is responsible for generating the Ninja files by invoking either GYP
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
23 ```
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 path relative to the checkout root (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
38 `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):
40
41 ```
42 mb analyze -c chromium_linux_rel //out/Release input.json output.json
43 ```
44
45 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.
47
48
49 The first positional argument is the path to the build directory.
50
51 The second positional argument is a path to a JSON file containing a single
52 object with two fields:
53
54 * `files`: an array of the modified filenames to check (as
55 paths relative to the checkout root).
56 * `targets`: an array of the unqualified target names to check.
57
58 The third positional argument is a path where the mb will write the result,
59 also as a JSON object. This object may contain the following fields:
60
61 * `error`: this should only be present if something failed.
62 * `targets`: the subset of the input `targets` that depend on the
63 input `files`.
64 * `build_targets`: the minimal subset of targets needed to build all
65 of `targets` that were affected.
66 * `status`: one of three strings:
67 * `"Found dependency"` (build the `build_targets`)
68 * `"No dependency"` (i.e., no build needed)
69 * `"Found dependency (all)"` (build everything, in which case
70 `targets` and `build_targets` are not returned).
71
72 ## `mb help`
73
74 Produces help output on the other subcommands
75
76 ## `mb lookup`
77
78 Prints what command will be run by `mb gen` (like `mb gen -n` but does
79 not require you to specify a path).
80
81 ## `mb validate`
82
83 Does internal checking to make sure the config file is syntactically
84 valid and that all of the entries are used properly. It does not validate
85 that the flags make sense, or that the builder names are legal or
86 comprehensive, but it does complain about configs and mixins that aren't
87 used.
88
89 This is mostly useful as a presubmit check and for verifying changes to
90 the config file.
91
92 ## mb_config.pyl
93
94 The `mb_config.pyl` config file is intended to enumerate all of the
95 supported build configurations for Chromium. Generally speaking, you
96 should never need to (or want to) build a configuration that isn't
97 listed here, and so by using the configs in this file you can avoid
98 having to juggle long lists of GYP_DEFINES and gn args by hand.
99
100 `mb_config.pyl` is structured as a file containing a single PYthon Literal
101 expression: a dictionary with three main keys, `masters`, `configs` and
102 `mixins`.
103
104 The `masters` key contains a nested series of dicts containing mappings
105 of master -> builder -> config . This allows us to isolate the buildbot
106 recipes from the actual details of the configs.
107
108 The `configs` key points to a dictionary of named build
109 configurations.
110
111 There should be an key in this dict for every supported configuration
112 of Chromium, meaning every configuration we have a bot for, and every
113 configuration commonly used by develpers but that we may not have a bot
114 for.
115
116 The value of each key is a list of "mixins" that will define what that
117 build_config does. Each item in the list must be an entry in the dictionary
118 value of the `mixins` key.
119
120 Each mixin value is itself a dictionary that contains one or more of the
121 following keys:
122
123 * `gyp_configs`: a list of the configurations to build, e.g.,
124 ['Release', 'Release_x64'].
125 * `gyp_defines`: a string containing a list of GYP_DEFINES.
126 * `gn_args`: a string containing a list of values passed to gn --args.
127 * `mixins`: a list of other mixins that should be included.
128 * `type`: a string with either the value `gyp` or `gn`;
129 setting this indicates which meta-build tool to use.
130
131 When `mb gen` or `mb analyze` executes, it takes a config name, looks it
132 up in the 'configs' dict, and then does a left-to-right expansion of the
133 mixins; gyp_defines and gn_args values are concatenated, and type and
134 gyp_configs values override each other.
135
136 For example, if you had:
137
138 ```
139 {
140 'configs`: {
141 'linux_release_trybot': ['gyp_release', 'trybot'],
142 'gn_shared_debug': None,
143 }
144 'mixins': {
145 'bot': {
146 'gyp_defines': 'use_goma=1 dcheck_always_on=0',
147 'gn_args': 'use_goma=true dcheck_always_on=false',
148 },
149 'debug': {
150 'gn_args': 'is_debug=true',
151 },
152 'gn': {'type': 'gn'},
153 'gyp_release': {
154 'gyp_config': 'Release'
155 'mixins': ['release'],
156 'type': 'gyp',
157 },
158 'release': {
159 'gn_args': 'is_debug=false',
160 }
161 'shared': {
162 'gn_args': 'is_component_build=true',
163 'gyp_defines': 'component=shared_library',
164 },
165 'trybot': {
166 'gyp_defines': 'dcheck_always_on=1',
167 'gn_args': 'dcheck_always_on=true',
168 }
169 }
170 }
171
172 and you ran `mb gen -c linux_release_trybot //out/Release`, it would
173 translate into a call to `gyp_chromium -G Release` with `GYP_DEFINES` set to
174 `"use_goma=true dcheck_always_on=false dcheck_always_on=true"`.
175
176 (From that you can see that mb is intentionally dumb and does not
177 attempt to de-dup the flags, it lets gyp do that).
178
179 ## Debugging (-v/--verbose and -n/--dry-run)
180
181 By design, MB should be simple enough that very little can go wrong.
182
183 The most obvious issue is that you might see different commands being
184 run than you expect; running `'mb -v'` will print what it's doing and
185 run the commands; `'mb -n'` will print what it will do but *not* run
186 the commands.
187
188 If you hit weirder things than that, add some print statements to the
189 python script, send a question to gn-dev@chromium.org, or
190 [file a bug](https://crbug.com/new) with the label
191 'mb' and cc: dpranke@chromium.org.
192
193
OLDNEW
« no previous file with comments | « tools/mb/docs/design_spec.md ('k') | tools/mb/mb » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698