OLD | NEW |
---|---|
(Empty) | |
1 # The MB (Meta-Build wrapper) design spec | |
2 | |
3 [TOC] | |
4 | |
5 ## Intro | |
6 | |
7 MB is intended to address two major aspects of the GYP -> GN transition | |
8 for Chromium: | |
9 | |
10 1. "bot toggling" - make it so that we can easily flip a given bot | |
11 back and forth between GN and GYP. | |
12 | |
13 2. "bot configuration" - provide a single source of truth for all of | |
14 the different configurations (os/arch/`gyp_define` combinations) of | |
15 Chromium that are supported. | |
16 | |
17 MB must handle at least the `gen` and `analyze` steps on the bots, i.e., | |
18 we need to wrap both the `gyp_chromium` invocation to generate the | |
19 Ninja files, and the `analyze` step that takes a list of modified files | |
20 and a list of targets to build and returns which targets are affected by | |
21 the files. | |
22 | |
23 ## Design | |
24 | |
25 MB is intended to be as simple as possible, and to defer as much work as | |
26 possible to GN or GYP. It should live as a very simple Python wrapper | |
27 that offers little in the way of surprises. | |
28 | |
29 ### Command line | |
30 | |
31 It is structured as a single binary that supports a list of subcommands: | |
32 | |
33 * `mb gen -c linux_rel_bot //out/Release` | |
34 * `mb analyze -m tryserver.chromium.linux -b linux_rel /tmp/input.json /tmp/outp ut.json` | |
35 | |
36 ### Configurations | |
37 | |
38 `mb` looks in the `//tools/mb/mb_config.pyl` config file to determine whether | |
39 to use GYP or GN for a particular build directory, and what set of flags | |
40 (`GYP_DEFINES` or `gn args`) to use. | |
41 | |
42 A config can either be specified directly (useful for testing) or by specifying | |
43 the master name and builder name (useful on the bots so that they do not need | |
44 to specify a config directly and can be hidden from the details). | |
45 | |
46 See the [user guide](user_guide.md#mb_config.pyl) for details. | |
47 | |
48 ### Handling the analyze step | |
49 | |
50 The interface to `mb analyze` is described in the | |
51 [user\_guide](user_guide.md#mb_analyze). | |
52 | |
53 Since the interface basically mirrors the way the "analyze" step on the bots | |
54 invokes gyp\_chromium today, when the config is found to be a gyp config, | |
55 the arguments are passed straight through. | |
56 | |
57 It implements the equivalent functionality in GN by calling `'gn refs | |
58 [list of files] --type=executable --all --as=output` and filtering the | |
59 output to match the list of targets. | |
60 | |
61 ## Detailed Design Requirements and Rationale | |
62 | |
63 This section is collection of semi-organized notes on why MB is the way | |
64 it is ... | |
65 | |
66 ### in-tree or out-of-tree | |
67 | |
68 The first issue is whether or not this should exist as a script in | |
69 Chromium at all; an alternative would be to simply change the bot | |
70 configurations to know whether to use GYP or GN, and which flags to | |
71 pass. | |
72 | |
73 That would certainly work, but experience over the past two years | |
74 suggests a few things: | |
75 | |
76 * we should push as much logic as we can into the source repositories | |
77 so that they can be versioned and changed atomically with changes to | |
78 the product code; having to coordinate changes between src/ and | |
79 build/ is at best annoying and can lead to weird errors. | |
80 * the infra team would really like to move to providing | |
81 product-independent services (i.e., not have to do one thing for | |
82 Chromium, another for NaCl, a third for V8, etc.). | |
83 * we found that during the SVN->GIT migration the ability to flip bot | |
84 configurations between the two via changes to a file in chromium | |
85 was very useful. | |
86 | |
87 All of this suggests that the interface between bots and Chromium should | |
88 be a simple one, hiding as much of the chromium logic as possible. | |
89 | |
90 ### Why not have MB be smarter about de-duping flags? | |
91 | |
92 This just adds complexity to the MB implementation, and duplicates logic | |
93 that GYP and GN already have to support anyway; in particular, it might | |
94 require MB to know how to parse GYP and GN values. The belief is that | |
95 if MB does *not* do this, it will lead to fewer surprises. | |
96 | |
97 It will not be hard to change this if need be. | |
98 | |
99 ### Integration w/ gclient runhooks | |
100 | |
101 On the bots, we will disable `gyp_chromium` as part of runhooks (using | |
102 `GYP_CHROMIUM_NO_ACTION=1`), so that mb shows up as a separate step. | |
103 | |
104 At the moment, we expect most developers to either continue to use | |
105 `gyp_chromium` in runhooks or to disable at as above if they have no | |
106 use for GYP at all. We may revisit how this works once we encourage more | |
107 people to use GN full-time (i.e., we might take `gyp_chromium` out of | |
108 runhooks altogether). | |
109 | |
110 ### Config per flag set or config per (os/arch/flag set)? | |
111 | |
112 Currently, mb_config.pyl does not specify the host_os, target_os, host_cpu, or | |
113 target_cpu values for every config that Chromium runs on, it only specifies | |
114 them for when the values need to be explicitly set on the command line. | |
115 | |
116 Instead, we have one config per unique combination of flags only. | |
117 | |
118 In other words, rather than having `linux_rel_bot`, `win_rel_bot`, and | |
119 `mac_rel_bot`, we just have `rel_bot`. | |
120 | |
121 This design allows us to determine easily all of the different sets | |
122 of flags that we need to support, but *not* which flags are used on which | |
123 host/target combinations. | |
124 | |
125 It may be that we should really track the latter. Doing so is just a | |
126 config file change, however. | |
127 | |
128 ### Non-goals | |
129 | |
130 * MB is not (yet?) intended to replace direct invocation of GN or GYP for | |
brettw
2015/04/06 20:03:05
I'd just remove "yet". I don't want people to thin
Dirk Pranke
2015/04/06 20:09:40
True. Will do.
| |
131 complicated build scenarios (aka ChromeOS), where multiple flags need | |
132 to be set to user-defined paths for specific toolchains (e.g., where | |
133 ChromeOS needs to specify specific board types and compilers). | |
134 | |
135 * MB is not intended at this time to be something developers use frequently, | |
136 or to add a lot of features to. We hope to be able to get rid of it once | |
137 the GYP->GN migration is done, and so we should not add things for | |
138 developers that can't easily be added to GN itself. | |
139 | |
140 * MB is not intended to replace the | |
141 [CR tool](https://code.google.com/p/chromium/wiki/CRUserManual). Not | |
142 only is it only intended to replace the gyp\_chromium part of `'gclient | |
143 runhooks'`, it is not really meant as a developer-facing tool. | |
144 | |
145 ### Open issues | |
146 | |
147 * Some common flags (goma\_dir being the obvious one) may need to be | |
148 specified via the user, and it's unclear how to integrate this with | |
149 the concept of build\_configs. | |
150 | |
151 Right now, MB has hard-coded support for a few flags (i.e., you can | |
152 pass the --goma-dir flag, and it will know to expand "${goma\_dir}" in | |
153 the string before calling out to the tool. We may want to generalize | |
154 this to a common key/value approach (perhaps then meeting the | |
155 ChromeOS non-goal, above), or we may want to keep this very strictly | |
156 limited for simplicity. | |
OLD | NEW |