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

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

Issue 2688103002: iOS: Use JSON for GN configuration instead of MB + remove symbols (Closed)
Patch Set: Enabling code signing on simulators Created 3 years, 10 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
OLDNEW
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
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
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, self.args.builder + '.json')
624 if not self.Exists(path): 624 if not self.Exists(path):
625 return {} 625 return {}
626 626
627 contents = json.loads(self.ReadFile(path)) 627 contents = json.loads(self.ReadFile(path))
628 gyp_vals = contents.get('GYP_DEFINES', {}) 628 gyp_vals = contents.get('GYP_DEFINES', {})
629 if isinstance(gyp_vals, dict): 629 if isinstance(gyp_vals, dict):
630 gyp_defines = ' '.join('%s=%s' % (k, v) for k, v in gyp_vals.items()) 630 gyp_defines = ' '.join('%s=%s' % (k, v) for k, v in gyp_vals.items())
631 else: 631 else:
632 gyp_defines = ' '.join(gyp_vals) 632 gyp_defines = ' '.join(gyp_vals)
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after
914 }) + '\n') 914 }) + '\n')
915 915
916 self.WriteJSON( 916 self.WriteJSON(
917 { 917 {
918 'args': [ 918 'args': [
919 '--isolated', 919 '--isolated',
920 self.ToSrcRelPath('%s/%s.isolated' % (build_dir, target)), 920 self.ToSrcRelPath('%s/%s.isolated' % (build_dir, target)),
921 '--isolate', 921 '--isolate',
922 self.ToSrcRelPath('%s/%s.isolate' % (build_dir, target)), 922 self.ToSrcRelPath('%s/%s.isolate' % (build_dir, target)),
923 ], 923 ],
924 'dir': self.chromium_src_dir, 924 'dir': self.src_dir,
925 'version': 1, 925 'version': 1,
926 }, 926 },
927 isolate_path + 'd.gen.json', 927 isolate_path + 'd.gen.json',
928 ) 928 )
929 929
930 def MapTargetsToLabels(self, isolate_map, targets): 930 def MapTargetsToLabels(self, isolate_map, targets):
931 labels = [] 931 labels = []
932 err = '' 932 err = ''
933 933
934 def StripTestSuffixes(target): 934 def StripTestSuffixes(target):
(...skipping 24 matching lines...) Expand all
959 return err, labels 959 return err, labels
960 960
961 def GNCmd(self, subcommand, path, *args): 961 def GNCmd(self, subcommand, path, *args):
962 if self.platform == 'linux2': 962 if self.platform == 'linux2':
963 subdir, exe = 'linux64', 'gn' 963 subdir, exe = 'linux64', 'gn'
964 elif self.platform == 'darwin': 964 elif self.platform == 'darwin':
965 subdir, exe = 'mac', 'gn' 965 subdir, exe = 'mac', 'gn'
966 else: 966 else:
967 subdir, exe = 'win', 'gn.exe' 967 subdir, exe = 'win', 'gn.exe'
968 968
969 gn_path = self.PathJoin(self.chromium_src_dir, 'buildtools', subdir, exe) 969 gn_path = self.PathJoin(self.src_dir, 'buildtools', subdir, exe)
970 return [gn_path, subcommand, path] + list(args) 970 return [gn_path, subcommand, path] + list(args)
971 971
972 972
973 def GNArgs(self, vals): 973 def GNArgs(self, vals):
974 if vals['cros_passthrough']: 974 if vals['cros_passthrough']:
975 if not 'GN_ARGS' in os.environ: 975 if not 'GN_ARGS' in os.environ:
976 raise MBErr('MB is expecting GN_ARGS to be in the environment') 976 raise MBErr('MB is expecting GN_ARGS to be in the environment')
977 gn_args = os.environ['GN_ARGS'] 977 gn_args = os.environ['GN_ARGS']
978 if not re.search('target_os.*=.*"chromeos"', gn_args): 978 if not re.search('target_os.*=.*"chromeos"', gn_args):
979 raise MBErr('GN_ARGS is missing target_os = "chromeos": (GN_ARGS=%s)' % 979 raise MBErr('GN_ARGS is missing target_os = "chromeos": (GN_ARGS=%s)' %
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
1127 executable, 1127 executable,
1128 '--', 1128 '--',
1129 '--asan=%d' % asan, 1129 '--asan=%d' % asan,
1130 '--msan=%d' % msan, 1130 '--msan=%d' % msan,
1131 '--tsan=%d' % tsan, 1131 '--tsan=%d' % tsan,
1132 ] 1132 ]
1133 1133
1134 return cmdline, extra_files 1134 return cmdline, extra_files
1135 1135
1136 def ToAbsPath(self, build_path, *comps): 1136 def ToAbsPath(self, build_path, *comps):
1137 return self.PathJoin(self.chromium_src_dir, 1137 return self.PathJoin(self.src_dir,
1138 self.ToSrcRelPath(build_path), 1138 self.ToSrcRelPath(build_path),
1139 *comps) 1139 *comps)
1140 1140
1141 def ToSrcRelPath(self, path): 1141 def ToSrcRelPath(self, path):
1142 """Returns a relative path from the top of the repo.""" 1142 """Returns a relative path from the top of the repo."""
1143 if path.startswith('//'): 1143 if path.startswith('//'):
1144 return path[2:].replace('/', self.sep) 1144 return path[2:].replace('/', self.sep)
1145 return self.RelPath(path, self.chromium_src_dir) 1145 return self.RelPath(path, self.src_dir)
1146 1146
1147 def ParseGYPConfigPath(self, path): 1147 def ParseGYPConfigPath(self, path):
1148 rpath = self.ToSrcRelPath(path) 1148 rpath = self.ToSrcRelPath(path)
1149 output_dir, _, _ = rpath.rpartition(self.sep) 1149 output_dir, _, _ = rpath.rpartition(self.sep)
1150 return output_dir 1150 return output_dir
1151 1151
1152 def GYPCmd(self, output_dir, vals): 1152 def GYPCmd(self, output_dir, vals):
1153 if vals['cros_passthrough']: 1153 if vals['cros_passthrough']:
1154 if not 'GYP_DEFINES' in os.environ: 1154 if not 'GYP_DEFINES' in os.environ:
1155 raise MBErr('MB is expecting GYP_DEFINES to be in the environment') 1155 raise MBErr('MB is expecting GYP_DEFINES to be in the environment')
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after
1423 if ret: 1423 if ret:
1424 self.Print(' -> returned %d' % ret) 1424 self.Print(' -> returned %d' % ret)
1425 if out: 1425 if out:
1426 self.Print(out, end='') 1426 self.Print(out, end='')
1427 if err: 1427 if err:
1428 self.Print(err, end='', file=sys.stderr) 1428 self.Print(err, end='', file=sys.stderr)
1429 return ret, out, err 1429 return ret, out, err
1430 1430
1431 def Call(self, cmd, env=None, buffer_output=True): 1431 def Call(self, cmd, env=None, buffer_output=True):
1432 if buffer_output: 1432 if buffer_output:
1433 p = subprocess.Popen(cmd, shell=False, cwd=self.chromium_src_dir, 1433 p = subprocess.Popen(cmd, shell=False, cwd=self.src_dir,
1434 stdout=subprocess.PIPE, stderr=subprocess.PIPE, 1434 stdout=subprocess.PIPE, stderr=subprocess.PIPE,
1435 env=env) 1435 env=env)
1436 out, err = p.communicate() 1436 out, err = p.communicate()
1437 else: 1437 else:
1438 p = subprocess.Popen(cmd, shell=False, cwd=self.chromium_src_dir, 1438 p = subprocess.Popen(cmd, shell=False, cwd=self.src_dir,
1439 env=env) 1439 env=env)
1440 p.wait() 1440 p.wait()
1441 out = err = '' 1441 out = err = ''
1442 return p.returncode, out, err 1442 return p.returncode, out, err
1443 1443
1444 def ExpandUser(self, path): 1444 def ExpandUser(self, path):
1445 # This function largely exists so it can be overridden for testing. 1445 # This function largely exists so it can be overridden for testing.
1446 return os.path.expanduser(path) 1446 return os.path.expanduser(path)
1447 1447
1448 def Exists(self, path): 1448 def Exists(self, path):
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
1537 # Then check to see if the arg contains any metacharacters other than 1537 # Then check to see if the arg contains any metacharacters other than
1538 # double quotes; if it does, quote everything (including the double 1538 # double quotes; if it does, quote everything (including the double
1539 # quotes) for safety. 1539 # quotes) for safety.
1540 if any(a in UNSAFE_FOR_CMD for a in arg): 1540 if any(a in UNSAFE_FOR_CMD for a in arg):
1541 arg = ''.join('^' + a if a in ALL_META_CHARS else a for a in arg) 1541 arg = ''.join('^' + a if a in ALL_META_CHARS else a for a in arg)
1542 return arg 1542 return arg
1543 1543
1544 1544
1545 if __name__ == '__main__': 1545 if __name__ == '__main__':
1546 sys.exit(main(sys.argv[1:])) 1546 sys.exit(main(sys.argv[1:]))
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698