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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/tools/mojob.py
diff --git a/mojo/tools/mojob.py b/mojo/tools/mojob.py
index d0505b8fcc443099d8b65c9ed1b994335465e9d8..4ac1de5e1df1f0dcf5fc20498dfda28559636105 100755
--- a/mojo/tools/mojob.py
+++ b/mojo/tools/mojob.py
@@ -8,6 +8,7 @@
import argparse
import os
import platform
+import re
import subprocess
import sys
@@ -71,11 +72,13 @@ def gn(args):
def get_gn_arg_value(out_dir, arg):
- if platform.system() == 'Windows':
- return None # TODO(jam): implement
- command = (r'''grep -m 1 "^[[:space:]]*\<%s\>" "%s/args.gn" |
- sed -n 's/.* = "\?\([^"]*\)"\?$/\1/p' ''') % (arg, out_dir)
- return subprocess.check_output(command, shell=True).strip()
+ key_value_regex = re.compile(r'^%s = (.+)$' % arg)
+ with open(os.path.join(out_dir, "args.gn"), "r") as args_file:
+ for line in args_file.readlines():
+ m = key_value_regex.search(line)
+ if m:
+ return m.group(1).strip('"')
+ return ''
def build(args):
« 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