OLD | NEW |
---|---|
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 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
255 self.ParseArgs([self.args.subcommand, '--help']) | 255 self.ParseArgs([self.args.subcommand, '--help']) |
256 else: | 256 else: |
257 self.ParseArgs(['--help']) | 257 self.ParseArgs(['--help']) |
258 | 258 |
259 def CmdIsolate(self): | 259 def CmdIsolate(self): |
260 vals = self.GetConfig() | 260 vals = self.GetConfig() |
261 if not vals: | 261 if not vals: |
262 return 1 | 262 return 1 |
263 | 263 |
264 if vals['type'] == 'gn': | 264 if vals['type'] == 'gn': |
265 return self.RunGNIsolate(vals) | 265 gn_isolate_map = self.ReadGnIsolateMap() |
266 return self.RunGNIsolate(vals, gn_isolate_map) | |
266 else: | 267 else: |
267 return self.Build('%s_run' % self.args.target[0]) | 268 return self.Build('%s_run' % self.args.target[0]) |
268 | 269 |
269 def CmdLookup(self): | 270 def CmdLookup(self): |
270 vals = self.Lookup() | 271 vals = self.Lookup() |
271 if vals['type'] == 'gn': | 272 if vals['type'] == 'gn': |
272 cmd = self.GNCmd('gen', '_path_') | 273 cmd = self.GNCmd('gen', '_path_') |
273 gn_args = self.GNArgs(vals) | 274 gn_args = self.GNArgs(vals) |
274 self.Print('\nWriting """\\\n%s""" to _path_/args.gn.\n' % gn_args) | 275 self.Print('\nWriting """\\\n%s""" to _path_/args.gn.\n' % gn_args) |
275 env = None | 276 env = None |
276 else: | 277 else: |
277 cmd, env = self.GYPCmd('_path_', vals) | 278 cmd, env = self.GYPCmd('_path_', vals) |
278 | 279 |
279 self.PrintCmd(cmd, env) | 280 self.PrintCmd(cmd, env) |
280 return 0 | 281 return 0 |
281 | 282 |
282 def CmdRun(self): | 283 def CmdRun(self): |
283 vals = self.GetConfig() | 284 vals = self.GetConfig() |
284 if not vals: | 285 if not vals: |
285 return 1 | 286 return 1 |
286 | 287 |
287 build_dir = self.args.path[0] | 288 build_dir = self.args.path[0] |
288 target = self.args.target[0] | 289 target = self.args.target[0] |
289 | 290 |
290 if vals['type'] == 'gn': | 291 if vals['type'] == 'gn': |
292 gn_isolate_map = self.ReadGnIsolateMap() | |
293 build_target = target | |
294 if gn_isolate_map[target]['type'] == 'android_instrumentation': | |
295 build_target = target + '_apk' | |
jbudorick
2016/04/28 03:11:57
:(
| |
291 if self.args.build: | 296 if self.args.build: |
292 ret = self.Build(target) | 297 ret = self.Build(build_target) |
293 if ret: | 298 if ret: |
294 return ret | 299 return ret |
295 ret = self.RunGNIsolate(vals) | 300 ret = self.RunGNIsolate(vals, gn_isolate_map) |
296 if ret: | 301 if ret: |
297 return ret | 302 return ret |
298 else: | 303 else: |
299 ret = self.Build('%s_run' % target) | 304 ret = self.Build('%s_run' % target) |
300 if ret: | 305 if ret: |
301 return ret | 306 return ret |
302 | 307 |
303 cmd = [ | 308 cmd = [ |
304 self.executable, | 309 self.executable, |
305 self.PathJoin('tools', 'swarming_client', 'isolate.py'), | 310 self.PathJoin('tools', 'swarming_client', 'isolate.py'), |
(...skipping 441 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
747 # We need GN to generate the list of runtime dependencies for | 752 # We need GN to generate the list of runtime dependencies for |
748 # the compile targets listed (one per line) in the file so | 753 # the compile targets listed (one per line) in the file so |
749 # we can run them via swarming. We use ninja_to_gn.pyl to convert | 754 # we can run them via swarming. We use ninja_to_gn.pyl to convert |
750 # the compile targets to the matching GN labels. | 755 # the compile targets to the matching GN labels. |
751 path = self.args.swarming_targets_file | 756 path = self.args.swarming_targets_file |
752 if not self.Exists(path): | 757 if not self.Exists(path): |
753 self.WriteFailureAndRaise('"%s" does not exist' % path, | 758 self.WriteFailureAndRaise('"%s" does not exist' % path, |
754 output_path=None) | 759 output_path=None) |
755 contents = self.ReadFile(path) | 760 contents = self.ReadFile(path) |
756 swarming_targets = set(contents.splitlines()) | 761 swarming_targets = set(contents.splitlines()) |
757 gn_isolate_map = ast.literal_eval(self.ReadFile(self.PathJoin( | 762 gn_isolate_map = self.ReadGnIsolateMap() |
758 self.chromium_src_dir, 'testing', 'buildbot', 'gn_isolate_map.pyl'))) | |
759 gn_labels = [] | 763 gn_labels = [] |
760 err = '' | 764 err = '' |
761 for target in swarming_targets: | 765 for target in swarming_targets: |
762 target_name = self.GNTargetName(target) | 766 target_name = self.GNTargetName(target) |
763 if not target_name in gn_isolate_map: | 767 if not target_name in gn_isolate_map: |
764 err += ('test target "%s" not found\n' % target_name) | 768 err += ('test target "%s" not found\n' % target_name) |
765 elif gn_isolate_map[target_name]['type'] == 'unknown': | 769 elif gn_isolate_map[target_name]['type'] == 'unknown': |
766 err += ('test target "%s" type is unknown\n' % target_name) | 770 err += ('test target "%s" type is unknown\n' % target_name) |
767 else: | 771 else: |
768 gn_labels.append(gn_isolate_map[target_name]['label']) | 772 gn_labels.append(gn_isolate_map[target_name]['label']) |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
821 command, extra_files = self.GetIsolateCommand(target, vals, | 825 command, extra_files = self.GetIsolateCommand(target, vals, |
822 gn_isolate_map) | 826 gn_isolate_map) |
823 | 827 |
824 runtime_deps = self.ReadFile(runtime_deps_path).splitlines() | 828 runtime_deps = self.ReadFile(runtime_deps_path).splitlines() |
825 | 829 |
826 self.WriteIsolateFiles(build_dir, command, target, runtime_deps, | 830 self.WriteIsolateFiles(build_dir, command, target, runtime_deps, |
827 extra_files) | 831 extra_files) |
828 | 832 |
829 return 0 | 833 return 0 |
830 | 834 |
831 def RunGNIsolate(self, vals): | 835 def ReadGnIsolateMap(self): |
832 gn_isolate_map = ast.literal_eval(self.ReadFile(self.PathJoin( | 836 return ast.literal_eval(self.ReadFile(self.PathJoin( |
833 self.chromium_src_dir, 'testing', 'buildbot', 'gn_isolate_map.pyl'))) | 837 self.chromium_src_dir, 'testing', 'buildbot', 'gn_isolate_map.pyl'))) |
834 | 838 |
839 def RunGNIsolate(self, vals, gn_isolate_map): | |
835 build_dir = self.args.path[0] | 840 build_dir = self.args.path[0] |
836 target = self.args.target[0] | 841 target = self.args.target[0] |
837 target_name = self.GNTargetName(target) | 842 target_name = self.GNTargetName(target) |
838 command, extra_files = self.GetIsolateCommand(target, vals, gn_isolate_map) | 843 command, extra_files = self.GetIsolateCommand(target, vals, gn_isolate_map) |
839 | 844 |
840 label = gn_isolate_map[target_name]['label'] | 845 label = gn_isolate_map[target_name]['label'] |
841 cmd = self.GNCmd('desc', build_dir, label, 'runtime_deps') | 846 cmd = self.GNCmd('desc', build_dir, label, 'runtime_deps') |
842 ret, out, _ = self.Call(cmd) | 847 ret, out, _ = self.Call(cmd) |
843 if ret: | 848 if ret: |
844 if out: | 849 if out: |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
983 executable = gn_isolate_map[target_name].get('executable', target_name) | 988 executable = gn_isolate_map[target_name].get('executable', target_name) |
984 executable_suffix = '.exe' if self.platform == 'win32' else '' | 989 executable_suffix = '.exe' if self.platform == 'win32' else '' |
985 | 990 |
986 cmdline = [] | 991 cmdline = [] |
987 extra_files = [] | 992 extra_files = [] |
988 | 993 |
989 if android: | 994 if android: |
990 # TODO(jbudorick): This won't work with instrumentation test targets. | 995 # TODO(jbudorick): This won't work with instrumentation test targets. |
991 # Revisit this logic when those are added to gn_isolate_map.pyl. | 996 # Revisit this logic when those are added to gn_isolate_map.pyl. |
992 cmdline = [self.PathJoin('bin', 'run_%s' % target_name)] | 997 cmdline = [self.PathJoin('bin', 'run_%s' % target_name)] |
998 if gn_isolate_map[target]['type'] == 'android_instrumentation': | |
999 cmdline[0] += '_apk' | |
993 elif use_x11 and test_type == 'windowed_test_launcher': | 1000 elif use_x11 and test_type == 'windowed_test_launcher': |
994 extra_files = [ | 1001 extra_files = [ |
995 'xdisplaycheck', | 1002 'xdisplaycheck', |
996 '../../testing/test_env.py', | 1003 '../../testing/test_env.py', |
997 '../../testing/xvfb.py', | 1004 '../../testing/xvfb.py', |
998 ] | 1005 ] |
999 cmdline = [ | 1006 cmdline = [ |
1000 '../../testing/xvfb.py', | 1007 '../../testing/xvfb.py', |
1001 '.', | 1008 '.', |
1002 './' + str(executable) + executable_suffix, | 1009 './' + str(executable) + executable_suffix, |
(...skipping 460 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1463 # Then check to see if the arg contains any metacharacters other than | 1470 # Then check to see if the arg contains any metacharacters other than |
1464 # double quotes; if it does, quote everything (including the double | 1471 # double quotes; if it does, quote everything (including the double |
1465 # quotes) for safety. | 1472 # quotes) for safety. |
1466 if any(a in UNSAFE_FOR_CMD for a in arg): | 1473 if any(a in UNSAFE_FOR_CMD for a in arg): |
1467 arg = ''.join('^' + a if a in ALL_META_CHARS else a for a in arg) | 1474 arg = ''.join('^' + a if a in ALL_META_CHARS else a for a in arg) |
1468 return arg | 1475 return arg |
1469 | 1476 |
1470 | 1477 |
1471 if __name__ == '__main__': | 1478 if __name__ == '__main__': |
1472 sys.exit(main(sys.argv[1:])) | 1479 sys.exit(main(sys.argv[1:])) |
OLD | NEW |