| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright 2014 The Chromium Authors. All rights reserved. | 2 # Copyright 2014 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 # This a simple script to make building/testing Mojo components easier. | 6 # This a simple script to make building/testing Mojo components easier. |
| 7 | 7 |
| 8 import argparse | 8 import argparse |
| 9 import os | 9 import os |
| 10 import platform | 10 import platform |
| 11 import re |
| 11 import subprocess | 12 import subprocess |
| 12 import sys | 13 import sys |
| 13 | 14 |
| 14 import mopy.paths | 15 import mopy.paths |
| 15 | 16 |
| 16 | 17 |
| 17 def get_out_dir(args): | 18 def get_out_dir(args): |
| 18 out_dir = "out" | 19 out_dir = "out" |
| 19 prefix = '' | 20 prefix = '' |
| 20 if args.android: | 21 if args.android: |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 | 65 |
| 65 out_dir = get_out_dir(args) | 66 out_dir = get_out_dir(args) |
| 66 command.append(out_dir) | 67 command.append(out_dir) |
| 67 command.append('--args="%s"' % ' '.join(gn_args)) | 68 command.append('--args="%s"' % ' '.join(gn_args)) |
| 68 | 69 |
| 69 print 'Running %s ...' % ' '.join(command) | 70 print 'Running %s ...' % ' '.join(command) |
| 70 return subprocess.call(' '.join(command), shell=True) | 71 return subprocess.call(' '.join(command), shell=True) |
| 71 | 72 |
| 72 | 73 |
| 73 def get_gn_arg_value(out_dir, arg): | 74 def get_gn_arg_value(out_dir, arg): |
| 74 if platform.system() == 'Windows': | 75 key_value_regex = re.compile(r'^%s = (.+)$' % arg) |
| 75 return None # TODO(jam): implement | 76 with open(os.path.join(out_dir, "args.gn"), "r") as args_file: |
| 76 command = (r'''grep -m 1 "^[[:space:]]*\<%s\>" "%s/args.gn" | | 77 for line in args_file.readlines(): |
| 77 sed -n 's/.* = "\?\([^"]*\)"\?$/\1/p' ''') % (arg, out_dir) | 78 m = key_value_regex.search(line) |
| 78 return subprocess.check_output(command, shell=True).strip() | 79 if m: |
| 80 return m.group(1).strip('"') |
| 81 return '' |
| 79 | 82 |
| 80 | 83 |
| 81 def build(args): | 84 def build(args): |
| 82 out_dir = get_out_dir(args) | 85 out_dir = get_out_dir(args) |
| 83 print 'Building in %s ...' % out_dir | 86 print 'Building in %s ...' % out_dir |
| 84 if get_gn_arg_value(out_dir, 'use_goma') == 'true': | 87 if get_gn_arg_value(out_dir, 'use_goma') == 'true': |
| 85 # Use the configured goma directory. | 88 # Use the configured goma directory. |
| 86 local_goma_dir = get_gn_arg_value(out_dir, 'goma_dir') | 89 local_goma_dir = get_gn_arg_value(out_dir, 'goma_dir') |
| 87 print 'Ensuring goma (in %s) started ...' % local_goma_dir | 90 print 'Ensuring goma (in %s) started ...' % local_goma_dir |
| 88 command = [os.path.join(local_goma_dir, 'goma_ctl.py'), 'ensure_start'] | 91 command = [os.path.join(local_goma_dir, 'goma_ctl.py'), 'ensure_start'] |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 249 args.clang = False | 252 args.clang = False |
| 250 | 253 |
| 251 if platform.system() == 'Windows': | 254 if platform.system() == 'Windows': |
| 252 args.clang = False | 255 args.clang = False |
| 253 | 256 |
| 254 return args.func(args) | 257 return args.func(args) |
| 255 | 258 |
| 256 | 259 |
| 257 if __name__ == '__main__': | 260 if __name__ == '__main__': |
| 258 sys.exit(main()) | 261 sys.exit(main()) |
| OLD | NEW |