Chromium Code Reviews| 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 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 67 subp.add_argument('-b', '--builder', | 67 subp.add_argument('-b', '--builder', |
| 68 help='builder name to look up config from') | 68 help='builder name to look up config from') |
| 69 subp.add_argument('-m', '--master', | 69 subp.add_argument('-m', '--master', |
| 70 help='master name to look up config from') | 70 help='master name to look up config from') |
| 71 subp.add_argument('-c', '--config', | 71 subp.add_argument('-c', '--config', |
| 72 help='configuration to analyze') | 72 help='configuration to analyze') |
| 73 subp.add_argument('-f', '--config-file', metavar='PATH', | 73 subp.add_argument('-f', '--config-file', metavar='PATH', |
| 74 default=self.default_config, | 74 default=self.default_config, |
| 75 help='path to config file ' | 75 help='path to config file ' |
| 76 '(default is //tools/mb/mb_config.pyl)') | 76 '(default is //tools/mb/mb_config.pyl)') |
| 77 subp.add_argument('-g', '--goma-dir', default=self.ExpandUser('~/goma'), | 77 subp.add_argument('-g', '--goma-dir', |
| 78 help='path to goma directory (default is %(default)s).') | 78 help='path to goma directory') |
| 79 subp.add_argument('-n', '--dryrun', action='store_true', | 79 subp.add_argument('-n', '--dryrun', action='store_true', |
| 80 help='Do a dry run (i.e., do nothing, just print ' | 80 help='Do a dry run (i.e., do nothing, just print ' |
| 81 'the commands that will run)') | 81 'the commands that will run)') |
| 82 subp.add_argument('-v', '--verbose', action='store_true', | 82 subp.add_argument('-v', '--verbose', action='store_true', |
| 83 help='verbose logging') | 83 help='verbose logging') |
| 84 | 84 |
| 85 parser = argparse.ArgumentParser(prog='mb') | 85 parser = argparse.ArgumentParser(prog='mb') |
| 86 subps = parser.add_subparsers() | 86 subps = parser.add_subparsers() |
| 87 | 87 |
| 88 subp = subps.add_parser('analyze', | 88 subp = subps.add_parser('analyze', |
| (...skipping 755 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 844 def GNCmd(self, subcommand, path, gn_args='', extra_args=None): | 844 def GNCmd(self, subcommand, path, gn_args='', extra_args=None): |
| 845 if self.platform == 'linux2': | 845 if self.platform == 'linux2': |
| 846 subdir, exe = 'linux64', 'gn' | 846 subdir, exe = 'linux64', 'gn' |
| 847 elif self.platform == 'darwin': | 847 elif self.platform == 'darwin': |
| 848 subdir, exe = 'mac', 'gn' | 848 subdir, exe = 'mac', 'gn' |
| 849 else: | 849 else: |
| 850 subdir, exe = 'win', 'gn.exe' | 850 subdir, exe = 'win', 'gn.exe' |
| 851 gn_path = self.PathJoin(self.chromium_src_dir, 'buildtools', subdir, exe) | 851 gn_path = self.PathJoin(self.chromium_src_dir, 'buildtools', subdir, exe) |
| 852 | 852 |
| 853 cmd = [gn_path, subcommand, path] | 853 cmd = [gn_path, subcommand, path] |
| 854 gn_args = gn_args.replace("$(goma_dir)", self.args.goma_dir) | 854 if self.args.goma_dir: |
| 855 gn_args += ' goma_dir="%s"' % self.args.goma_dir | |
|
Dirk Pranke
2016/04/12 18:03:20
Ideally gn_args and gyp_defines would be lists of
| |
| 855 if gn_args: | 856 if gn_args: |
| 856 cmd.append('--args=%s' % gn_args) | 857 cmd.append('--args=%s' % gn_args) |
| 857 if extra_args: | 858 if extra_args: |
| 858 cmd.extend(extra_args) | 859 cmd.extend(extra_args) |
| 859 return cmd | 860 return cmd |
| 860 | 861 |
| 861 def RunGYPGen(self, vals): | 862 def RunGYPGen(self, vals): |
| 862 path = self.args.path[0] | 863 path = self.args.path[0] |
| 863 | 864 |
| 864 output_dir = self.ParseGYPConfigPath(path) | 865 output_dir = self.ParseGYPConfigPath(path) |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 997 output_dir, _, _ = rpath.rpartition(self.sep) | 998 output_dir, _, _ = rpath.rpartition(self.sep) |
| 998 return output_dir | 999 return output_dir |
| 999 | 1000 |
| 1000 def GYPCmd(self, output_dir, vals): | 1001 def GYPCmd(self, output_dir, vals): |
| 1001 gyp_defines = vals['gyp_defines'] | 1002 gyp_defines = vals['gyp_defines'] |
| 1002 goma_dir = self.args.goma_dir | 1003 goma_dir = self.args.goma_dir |
| 1003 | 1004 |
| 1004 # GYP uses shlex.split() to split the gyp defines into separate arguments, | 1005 # GYP uses shlex.split() to split the gyp defines into separate arguments, |
| 1005 # so we can support backslashes and and spaces in arguments by quoting | 1006 # so we can support backslashes and and spaces in arguments by quoting |
| 1006 # them, even on Windows, where this normally wouldn't work. | 1007 # them, even on Windows, where this normally wouldn't work. |
| 1007 if '\\' in goma_dir or ' ' in goma_dir: | 1008 if goma_dir and ('\\' in goma_dir or ' ' in goma_dir): |
| 1008 goma_dir = "'%s'" % goma_dir | 1009 goma_dir = "'%s'" % goma_dir |
| 1009 gyp_defines = gyp_defines.replace("$(goma_dir)", goma_dir) | 1010 |
| 1011 if goma_dir: | |
| 1012 gyp_defines += ' gomadir=%s' % goma_dir | |
| 1010 | 1013 |
| 1011 cmd = [ | 1014 cmd = [ |
| 1012 self.executable, | 1015 self.executable, |
| 1013 self.PathJoin('build', 'gyp_chromium'), | 1016 self.PathJoin('build', 'gyp_chromium'), |
| 1014 '-G', | 1017 '-G', |
| 1015 'output_dir=' + output_dir, | 1018 'output_dir=' + output_dir, |
| 1016 ] | 1019 ] |
| 1017 | 1020 |
| 1018 # Ensure that we have an environment that only contains | 1021 # Ensure that we have an environment that only contains |
| 1019 # the exact values of the GYP variables we need. | 1022 # the exact values of the GYP variables we need. |
| (...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1351 # Then check to see if the arg contains any metacharacters other than | 1354 # Then check to see if the arg contains any metacharacters other than |
| 1352 # double quotes; if it does, quote everything (including the double | 1355 # double quotes; if it does, quote everything (including the double |
| 1353 # quotes) for safety. | 1356 # quotes) for safety. |
| 1354 if any(a in UNSAFE_FOR_CMD for a in arg): | 1357 if any(a in UNSAFE_FOR_CMD for a in arg): |
| 1355 arg = ''.join('^' + a if a in ALL_META_CHARS else a for a in arg) | 1358 arg = ''.join('^' + a if a in ALL_META_CHARS else a for a in arg) |
| 1356 return arg | 1359 return arg |
| 1357 | 1360 |
| 1358 | 1361 |
| 1359 if __name__ == '__main__': | 1362 if __name__ == '__main__': |
| 1360 sys.exit(main(sys.argv[1:])) | 1363 sys.exit(main(sys.argv[1:])) |
| OLD | NEW |