OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. | 2 # Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. |
3 # | 3 # |
4 # Use of this source code is governed by a BSD-style license | 4 # Use of this source code is governed by a BSD-style license |
5 # that can be found in the LICENSE file in the root of the source | 5 # that can be found in the LICENSE file in the root of the source |
6 # tree. An additional intellectual property rights grant can be found | 6 # tree. An additional intellectual property rights grant can be found |
7 # in the file PATENTS. All contributing project authors may | 7 # in the file PATENTS. All contributing project authors may |
8 # be found in the AUTHORS file in the root of the source tree. | 8 # be found in the AUTHORS file in the root of the source tree. |
9 | 9 |
10 """MB - the Meta-Build wrapper around GYP and GN | 10 """MB - the Meta-Build wrapper around GYP and GN |
(...skipping 15 matching lines...) Expand all Loading... |
26 import shutil | 26 import shutil |
27 import sys | 27 import sys |
28 import subprocess | 28 import subprocess |
29 import tempfile | 29 import tempfile |
30 import traceback | 30 import traceback |
31 import urllib2 | 31 import urllib2 |
32 | 32 |
33 from collections import OrderedDict | 33 from collections import OrderedDict |
34 | 34 |
35 SCRIPT_DIR = os.path.dirname(os.path.realpath(__file__)) | 35 SCRIPT_DIR = os.path.dirname(os.path.realpath(__file__)) |
36 CHROMIUM_SRC_DIR = os.path.dirname(os.path.dirname(SCRIPT_DIR)) | 36 SRC_DIR = os.path.dirname(os.path.dirname(SCRIPT_DIR)) |
37 sys.path = [os.path.join(CHROMIUM_SRC_DIR, 'build')] + sys.path | 37 sys.path = [os.path.join(SRC_DIR, 'build')] + sys.path |
38 | 38 |
39 import gn_helpers | 39 import gn_helpers |
40 | 40 |
41 | 41 |
42 def main(args): | 42 def main(args): |
43 mbw = MetaBuildWrapper() | 43 mbw = MetaBuildWrapper() |
44 return mbw.Main(args) | 44 return mbw.Main(args) |
45 | 45 |
46 | 46 |
47 class MetaBuildWrapper(object): | 47 class MetaBuildWrapper(object): |
48 def __init__(self): | 48 def __init__(self): |
49 self.chromium_src_dir = CHROMIUM_SRC_DIR | 49 self.src_dir = SRC_DIR |
50 self.default_config = os.path.join(SCRIPT_DIR, 'mb_config.pyl') | 50 self.default_config = os.path.join(SCRIPT_DIR, 'mb_config.pyl') |
51 self.default_isolate_map = os.path.join(SCRIPT_DIR, 'gn_isolate_map.pyl') | 51 self.default_isolate_map = os.path.join(SCRIPT_DIR, 'gn_isolate_map.pyl') |
52 self.executable = sys.executable | 52 self.executable = sys.executable |
53 self.platform = sys.platform | 53 self.platform = sys.platform |
54 self.sep = os.sep | 54 self.sep = os.sep |
55 self.args = argparse.Namespace() | 55 self.args = argparse.Namespace() |
56 self.configs = {} | 56 self.configs = {} |
57 self.masters = {} | 57 self.masters = {} |
58 self.mixins = {} | 58 self.mixins = {} |
59 | 59 |
(...skipping 552 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
612 if 'type' not in vals: | 612 if 'type' not in vals: |
613 vals['type'] = 'gn' | 613 vals['type'] = 'gn' |
614 assert vals['type'] in ('gn', 'gyp'), ( | 614 assert vals['type'] in ('gn', 'gyp'), ( |
615 'Unknown meta-build type "%s"' % vals['gn_args']) | 615 'Unknown meta-build type "%s"' % vals['gn_args']) |
616 | 616 |
617 return vals | 617 return vals |
618 | 618 |
619 def ReadIOSBotConfig(self): | 619 def ReadIOSBotConfig(self): |
620 if not self.args.master or not self.args.builder: | 620 if not self.args.master or not self.args.builder: |
621 return {} | 621 return {} |
622 path = self.PathJoin(self.chromium_src_dir, 'ios', 'build', 'bots', | 622 path = self.PathJoin(self.src_dir, 'tools-webrtc', 'ios', |
623 self.args.master, self.args.builder + '.json') | 623 self.args.master, |
| 624 self.args.builder.replace(' ', '_') + '.json') |
624 if not self.Exists(path): | 625 if not self.Exists(path): |
625 return {} | 626 return {} |
626 | 627 |
627 contents = json.loads(self.ReadFile(path)) | 628 contents = json.loads(self.ReadFile(path)) |
628 gyp_vals = contents.get('GYP_DEFINES', {}) | 629 gyp_vals = contents.get('GYP_DEFINES', {}) |
629 if isinstance(gyp_vals, dict): | 630 if isinstance(gyp_vals, dict): |
630 gyp_defines = ' '.join('%s=%s' % (k, v) for k, v in gyp_vals.items()) | 631 gyp_defines = ' '.join('%s=%s' % (k, v) for k, v in gyp_vals.items()) |
631 else: | 632 else: |
632 gyp_defines = ' '.join(gyp_vals) | 633 gyp_defines = ' '.join(gyp_vals) |
633 gn_args = ' '.join(contents.get('gn_args', [])) | 634 gn_args = ' '.join(contents.get('gn_args', [])) |
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
914 }) + '\n') | 915 }) + '\n') |
915 | 916 |
916 self.WriteJSON( | 917 self.WriteJSON( |
917 { | 918 { |
918 'args': [ | 919 'args': [ |
919 '--isolated', | 920 '--isolated', |
920 self.ToSrcRelPath('%s/%s.isolated' % (build_dir, target)), | 921 self.ToSrcRelPath('%s/%s.isolated' % (build_dir, target)), |
921 '--isolate', | 922 '--isolate', |
922 self.ToSrcRelPath('%s/%s.isolate' % (build_dir, target)), | 923 self.ToSrcRelPath('%s/%s.isolate' % (build_dir, target)), |
923 ], | 924 ], |
924 'dir': self.chromium_src_dir, | 925 'dir': self.src_dir, |
925 'version': 1, | 926 'version': 1, |
926 }, | 927 }, |
927 isolate_path + 'd.gen.json', | 928 isolate_path + 'd.gen.json', |
928 ) | 929 ) |
929 | 930 |
930 def MapTargetsToLabels(self, isolate_map, targets): | 931 def MapTargetsToLabels(self, isolate_map, targets): |
931 labels = [] | 932 labels = [] |
932 err = '' | 933 err = '' |
933 | 934 |
934 def StripTestSuffixes(target): | 935 def StripTestSuffixes(target): |
(...skipping 24 matching lines...) Expand all Loading... |
959 return err, labels | 960 return err, labels |
960 | 961 |
961 def GNCmd(self, subcommand, path, *args): | 962 def GNCmd(self, subcommand, path, *args): |
962 if self.platform == 'linux2': | 963 if self.platform == 'linux2': |
963 subdir, exe = 'linux64', 'gn' | 964 subdir, exe = 'linux64', 'gn' |
964 elif self.platform == 'darwin': | 965 elif self.platform == 'darwin': |
965 subdir, exe = 'mac', 'gn' | 966 subdir, exe = 'mac', 'gn' |
966 else: | 967 else: |
967 subdir, exe = 'win', 'gn.exe' | 968 subdir, exe = 'win', 'gn.exe' |
968 | 969 |
969 gn_path = self.PathJoin(self.chromium_src_dir, 'buildtools', subdir, exe) | 970 gn_path = self.PathJoin(self.src_dir, 'buildtools', subdir, exe) |
970 return [gn_path, subcommand, path] + list(args) | 971 return [gn_path, subcommand, path] + list(args) |
971 | 972 |
972 | 973 |
973 def GNArgs(self, vals): | 974 def GNArgs(self, vals): |
974 if vals['cros_passthrough']: | 975 if vals['cros_passthrough']: |
975 if not 'GN_ARGS' in os.environ: | 976 if not 'GN_ARGS' in os.environ: |
976 raise MBErr('MB is expecting GN_ARGS to be in the environment') | 977 raise MBErr('MB is expecting GN_ARGS to be in the environment') |
977 gn_args = os.environ['GN_ARGS'] | 978 gn_args = os.environ['GN_ARGS'] |
978 if not re.search('target_os.*=.*"chromeos"', gn_args): | 979 if not re.search('target_os.*=.*"chromeos"', gn_args): |
979 raise MBErr('GN_ARGS is missing target_os = "chromeos": (GN_ARGS=%s)' % | 980 raise MBErr('GN_ARGS is missing target_os = "chromeos": (GN_ARGS=%s)' % |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1130 executable, | 1131 executable, |
1131 '--', | 1132 '--', |
1132 '--asan=%d' % asan, | 1133 '--asan=%d' % asan, |
1133 '--msan=%d' % msan, | 1134 '--msan=%d' % msan, |
1134 '--tsan=%d' % tsan, | 1135 '--tsan=%d' % tsan, |
1135 ] | 1136 ] |
1136 | 1137 |
1137 return cmdline, extra_files | 1138 return cmdline, extra_files |
1138 | 1139 |
1139 def ToAbsPath(self, build_path, *comps): | 1140 def ToAbsPath(self, build_path, *comps): |
1140 return self.PathJoin(self.chromium_src_dir, | 1141 return self.PathJoin(self.src_dir, |
1141 self.ToSrcRelPath(build_path), | 1142 self.ToSrcRelPath(build_path), |
1142 *comps) | 1143 *comps) |
1143 | 1144 |
1144 def ToSrcRelPath(self, path): | 1145 def ToSrcRelPath(self, path): |
1145 """Returns a relative path from the top of the repo.""" | 1146 """Returns a relative path from the top of the repo.""" |
1146 if path.startswith('//'): | 1147 if path.startswith('//'): |
1147 return path[2:].replace('/', self.sep) | 1148 return path[2:].replace('/', self.sep) |
1148 return self.RelPath(path, self.chromium_src_dir) | 1149 return self.RelPath(path, self.src_dir) |
1149 | 1150 |
1150 def ParseGYPConfigPath(self, path): | 1151 def ParseGYPConfigPath(self, path): |
1151 rpath = self.ToSrcRelPath(path) | 1152 rpath = self.ToSrcRelPath(path) |
1152 output_dir, _, _ = rpath.rpartition(self.sep) | 1153 output_dir, _, _ = rpath.rpartition(self.sep) |
1153 return output_dir | 1154 return output_dir |
1154 | 1155 |
1155 def GYPCmd(self, output_dir, vals): | 1156 def GYPCmd(self, output_dir, vals): |
1156 if vals['cros_passthrough']: | 1157 if vals['cros_passthrough']: |
1157 if not 'GYP_DEFINES' in os.environ: | 1158 if not 'GYP_DEFINES' in os.environ: |
1158 raise MBErr('MB is expecting GYP_DEFINES to be in the environment') | 1159 raise MBErr('MB is expecting GYP_DEFINES to be in the environment') |
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1426 if ret: | 1427 if ret: |
1427 self.Print(' -> returned %d' % ret) | 1428 self.Print(' -> returned %d' % ret) |
1428 if out: | 1429 if out: |
1429 self.Print(out, end='') | 1430 self.Print(out, end='') |
1430 if err: | 1431 if err: |
1431 self.Print(err, end='', file=sys.stderr) | 1432 self.Print(err, end='', file=sys.stderr) |
1432 return ret, out, err | 1433 return ret, out, err |
1433 | 1434 |
1434 def Call(self, cmd, env=None, buffer_output=True): | 1435 def Call(self, cmd, env=None, buffer_output=True): |
1435 if buffer_output: | 1436 if buffer_output: |
1436 p = subprocess.Popen(cmd, shell=False, cwd=self.chromium_src_dir, | 1437 p = subprocess.Popen(cmd, shell=False, cwd=self.src_dir, |
1437 stdout=subprocess.PIPE, stderr=subprocess.PIPE, | 1438 stdout=subprocess.PIPE, stderr=subprocess.PIPE, |
1438 env=env) | 1439 env=env) |
1439 out, err = p.communicate() | 1440 out, err = p.communicate() |
1440 else: | 1441 else: |
1441 p = subprocess.Popen(cmd, shell=False, cwd=self.chromium_src_dir, | 1442 p = subprocess.Popen(cmd, shell=False, cwd=self.src_dir, |
1442 env=env) | 1443 env=env) |
1443 p.wait() | 1444 p.wait() |
1444 out = err = '' | 1445 out = err = '' |
1445 return p.returncode, out, err | 1446 return p.returncode, out, err |
1446 | 1447 |
1447 def ExpandUser(self, path): | 1448 def ExpandUser(self, path): |
1448 # This function largely exists so it can be overridden for testing. | 1449 # This function largely exists so it can be overridden for testing. |
1449 return os.path.expanduser(path) | 1450 return os.path.expanduser(path) |
1450 | 1451 |
1451 def Exists(self, path): | 1452 def Exists(self, path): |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1540 # Then check to see if the arg contains any metacharacters other than | 1541 # Then check to see if the arg contains any metacharacters other than |
1541 # double quotes; if it does, quote everything (including the double | 1542 # double quotes; if it does, quote everything (including the double |
1542 # quotes) for safety. | 1543 # quotes) for safety. |
1543 if any(a in UNSAFE_FOR_CMD for a in arg): | 1544 if any(a in UNSAFE_FOR_CMD for a in arg): |
1544 arg = ''.join('^' + a if a in ALL_META_CHARS else a for a in arg) | 1545 arg = ''.join('^' + a if a in ALL_META_CHARS else a for a in arg) |
1545 return arg | 1546 return arg |
1546 | 1547 |
1547 | 1548 |
1548 if __name__ == '__main__': | 1549 if __name__ == '__main__': |
1549 sys.exit(main(sys.argv[1:])) | 1550 sys.exit(main(sys.argv[1:])) |
OLD | NEW |