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

Side by Side Diff: mojo/tools/mojob.py

Issue 698853003: Port get_gn_arg_value() to native Python code so that it works on Windows. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 6 years, 1 month 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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())
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698