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