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

Side by Side Diff: tools/mb/mb.py

Issue 2443643002: MB: Add --isolate-map-file flag for overriding default isolate map. (Closed)
Patch Set: Created 4 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 | « no previous file | tools/mb/mb_unittest.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 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright 2015 The Chromium Authors. All rights reserved. 2 # Copyright 2015 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 """MB - the Meta-Build wrapper around GYP and GN 6 """MB - the Meta-Build wrapper around GYP and GN
7 7
8 MB is a wrapper script for GYP and GN that can be used to generate build files 8 MB is a wrapper script for GYP and GN that can be used to generate build files
9 for sets of canned configurations and analyze them. 9 for sets of canned configurations and analyze them.
10 """ 10 """
(...skipping 27 matching lines...) Expand all
38 def main(args): 38 def main(args):
39 mbw = MetaBuildWrapper() 39 mbw = MetaBuildWrapper()
40 return mbw.Main(args) 40 return mbw.Main(args)
41 41
42 42
43 class MetaBuildWrapper(object): 43 class MetaBuildWrapper(object):
44 def __init__(self): 44 def __init__(self):
45 self.chromium_src_dir = CHROMIUM_SRC_DIR 45 self.chromium_src_dir = CHROMIUM_SRC_DIR
46 self.default_config = os.path.join(self.chromium_src_dir, 'tools', 'mb', 46 self.default_config = os.path.join(self.chromium_src_dir, 'tools', 'mb',
47 'mb_config.pyl') 47 'mb_config.pyl')
48 self.default_isolate_map = os.path.join(self.chromium_src_dir, 'testing',
49 'buildbot', 'gn_isolate_map.pyl')
48 self.executable = sys.executable 50 self.executable = sys.executable
49 self.platform = sys.platform 51 self.platform = sys.platform
50 self.sep = os.sep 52 self.sep = os.sep
51 self.args = argparse.Namespace() 53 self.args = argparse.Namespace()
52 self.configs = {} 54 self.configs = {}
53 self.masters = {} 55 self.masters = {}
54 self.mixins = {} 56 self.mixins = {}
55 57
56 def Main(self, args): 58 def Main(self, args):
57 self.ParseArgs(args) 59 self.ParseArgs(args)
(...skipping 20 matching lines...) Expand all
78 help='master name to look up config from') 80 help='master name to look up config from')
79 subp.add_argument('-c', '--config', 81 subp.add_argument('-c', '--config',
80 help='configuration to analyze') 82 help='configuration to analyze')
81 subp.add_argument('--phase', 83 subp.add_argument('--phase',
82 help='optional phase name (used when builders ' 84 help='optional phase name (used when builders '
83 'do multiple compiles with different ' 85 'do multiple compiles with different '
84 'arguments in a single build)') 86 'arguments in a single build)')
85 subp.add_argument('-f', '--config-file', metavar='PATH', 87 subp.add_argument('-f', '--config-file', metavar='PATH',
86 default=self.default_config, 88 default=self.default_config,
87 help='path to config file ' 89 help='path to config file '
88 '(default is //tools/mb/mb_config.pyl)') 90 '(default is %(default)s)')
91 subp.add_argument('-i', '--isolate-map-file', metavar='PATH',
92 default=self.default_isolate_map,
93 help='path to isolate map file '
94 '(default is %(default)s)')
89 subp.add_argument('-g', '--goma-dir', 95 subp.add_argument('-g', '--goma-dir',
90 help='path to goma directory') 96 help='path to goma directory')
91 subp.add_argument('--gyp-script', metavar='PATH', 97 subp.add_argument('--gyp-script', metavar='PATH',
92 default=self.PathJoin('build', 'gyp_chromium'), 98 default=self.PathJoin('build', 'gyp_chromium'),
93 help='path to gyp script relative to project root ' 99 help='path to gyp script relative to project root '
94 '(default is %(default)s)') 100 '(default is %(default)s)')
95 subp.add_argument('--android-version-code', 101 subp.add_argument('--android-version-code',
96 help='Sets GN arg android_default_version_code and ' 102 help='Sets GN arg android_default_version_code and '
97 'GYP_DEFINE app_manifest_version_code') 103 'GYP_DEFINE app_manifest_version_code')
98 subp.add_argument('--android-version-name', 104 subp.add_argument('--android-version-name',
(...skipping 20 matching lines...) Expand all
119 subp.add_argument('output_path', nargs=1, 125 subp.add_argument('output_path', nargs=1,
120 help='path to a file containing the output arguments ' 126 help='path to a file containing the output arguments '
121 'as a JSON object.') 127 'as a JSON object.')
122 subp.set_defaults(func=self.CmdAnalyze) 128 subp.set_defaults(func=self.CmdAnalyze)
123 129
124 subp = subps.add_parser('export', 130 subp = subps.add_parser('export',
125 help='print out the expanded configuration for' 131 help='print out the expanded configuration for'
126 'each builder as a JSON object') 132 'each builder as a JSON object')
127 subp.add_argument('-f', '--config-file', metavar='PATH', 133 subp.add_argument('-f', '--config-file', metavar='PATH',
128 default=self.default_config, 134 default=self.default_config,
129 help='path to config file ' 135 help='path to config file (default is %(default)s)')
130 '(default is //tools/mb/mb_config.pyl)')
131 subp.add_argument('-g', '--goma-dir', 136 subp.add_argument('-g', '--goma-dir',
132 help='path to goma directory') 137 help='path to goma directory')
133 subp.set_defaults(func=self.CmdExport) 138 subp.set_defaults(func=self.CmdExport)
134 139
135 subp = subps.add_parser('gen', 140 subp = subps.add_parser('gen',
136 help='generate a new set of build files') 141 help='generate a new set of build files')
137 AddCommonOptions(subp) 142 AddCommonOptions(subp)
138 subp.add_argument('--swarming-targets-file', 143 subp.add_argument('--swarming-targets-file',
139 help='save runtime dependencies for targets listed ' 144 help='save runtime dependencies for targets listed '
140 'in file.') 145 'in file.')
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 subp.add_argument('extra_args', nargs='*', 201 subp.add_argument('extra_args', nargs='*',
197 help=('extra args to pass to the isolate to run. Use ' 202 help=('extra args to pass to the isolate to run. Use '
198 '"--" as the first arg if you need to pass ' 203 '"--" as the first arg if you need to pass '
199 'switches')) 204 'switches'))
200 subp.set_defaults(func=self.CmdRun) 205 subp.set_defaults(func=self.CmdRun)
201 206
202 subp = subps.add_parser('validate', 207 subp = subps.add_parser('validate',
203 help='validate the config file') 208 help='validate the config file')
204 subp.add_argument('-f', '--config-file', metavar='PATH', 209 subp.add_argument('-f', '--config-file', metavar='PATH',
205 default=self.default_config, 210 default=self.default_config,
206 help='path to config file ' 211 help='path to config file (default is %(default)s)')
207 '(default is //tools/mb/mb_config.pyl)')
208 subp.set_defaults(func=self.CmdValidate) 212 subp.set_defaults(func=self.CmdValidate)
209 213
210 subp = subps.add_parser('audit', 214 subp = subps.add_parser('audit',
211 help='Audit the config file to track progress') 215 help='Audit the config file to track progress')
212 subp.add_argument('-f', '--config-file', metavar='PATH', 216 subp.add_argument('-f', '--config-file', metavar='PATH',
213 default=self.default_config, 217 default=self.default_config,
214 help='path to config file ' 218 help='path to config file (default is %(default)s)')
215 '(default is //tools/mb/mb_config.pyl)')
216 subp.add_argument('-i', '--internal', action='store_true', 219 subp.add_argument('-i', '--internal', action='store_true',
217 help='check internal masters also') 220 help='check internal masters also')
218 subp.add_argument('-m', '--master', action='append', 221 subp.add_argument('-m', '--master', action='append',
219 help='master to audit (default is all non-internal ' 222 help='master to audit (default is all non-internal '
220 'masters in file)') 223 'masters in file)')
221 subp.add_argument('-u', '--url-template', action='store', 224 subp.add_argument('-u', '--url-template', action='store',
222 default='https://build.chromium.org/p/' 225 default='https://build.chromium.org/p/'
223 '{master}/json/builders', 226 '{master}/json/builders',
224 help='URL scheme for JSON APIs to buildbot ' 227 help='URL scheme for JSON APIs to buildbot '
225 '(default: %(default)s) ') 228 '(default: %(default)s) ')
(...skipping 438 matching lines...) Expand 10 before | Expand all | Expand 10 after
664 contents = ast.literal_eval(self.ReadFile(self.args.config_file)) 667 contents = ast.literal_eval(self.ReadFile(self.args.config_file))
665 except SyntaxError as e: 668 except SyntaxError as e:
666 raise MBErr('Failed to parse config file "%s": %s' % 669 raise MBErr('Failed to parse config file "%s": %s' %
667 (self.args.config_file, e)) 670 (self.args.config_file, e))
668 671
669 self.configs = contents['configs'] 672 self.configs = contents['configs']
670 self.masters = contents['masters'] 673 self.masters = contents['masters']
671 self.mixins = contents['mixins'] 674 self.mixins = contents['mixins']
672 675
673 def ReadIsolateMap(self): 676 def ReadIsolateMap(self):
674 return ast.literal_eval(self.ReadFile(self.PathJoin( 677 if not self.Exists(self.args.isolate_map_file):
675 self.chromium_src_dir, 'testing', 'buildbot', 'gn_isolate_map.pyl'))) 678 raise MBErr('isolate map file not found at %s' %
679 self.args.isolate_map_file)
680 try:
681 return ast.literal_eval(self.ReadFile(self.args.isolate_map_file))
682 except SyntaxError as e:
683 raise MBErr('Failed to parse isolate map file "%s": %s' %
684 (self.args.isolate_map_file, e))
676 685
677 def ConfigFromArgs(self): 686 def ConfigFromArgs(self):
678 if self.args.config: 687 if self.args.config:
679 if self.args.master or self.args.builder: 688 if self.args.master or self.args.builder:
680 raise MBErr('Can not specific both -c/--config and -m/--master or ' 689 raise MBErr('Can not specific both -c/--config and -m/--master or '
681 '-b/--builder') 690 '-b/--builder')
682 691
683 return self.args.config 692 return self.args.config
684 693
685 if not self.args.master or not self.args.builder: 694 if not self.args.master or not self.args.builder:
(...skipping 867 matching lines...) Expand 10 before | Expand all | Expand 10 after
1553 # Then check to see if the arg contains any metacharacters other than 1562 # Then check to see if the arg contains any metacharacters other than
1554 # double quotes; if it does, quote everything (including the double 1563 # double quotes; if it does, quote everything (including the double
1555 # quotes) for safety. 1564 # quotes) for safety.
1556 if any(a in UNSAFE_FOR_CMD for a in arg): 1565 if any(a in UNSAFE_FOR_CMD for a in arg):
1557 arg = ''.join('^' + a if a in ALL_META_CHARS else a for a in arg) 1566 arg = ''.join('^' + a if a in ALL_META_CHARS else a for a in arg)
1558 return arg 1567 return arg
1559 1568
1560 1569
1561 if __name__ == '__main__': 1570 if __name__ == '__main__':
1562 sys.exit(main(sys.argv[1:])) 1571 sys.exit(main(sys.argv[1:]))
OLDNEW
« no previous file with comments | « no previous file | tools/mb/mb_unittest.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698