diff options
author | skyostil <skyostil@chromium.org> | 2015-04-23 08:48:02 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-04-23 15:48:04 +0000 |
commit | b0ce8fb2c24588aa001ea8ff7fa84da404fbc266 (patch) | |
tree | 50ca734bdbfae49dd439d16426e715e8edbdbd78 /tools | |
parent | f6dd81c29b4cbc5b2da658ba3012db2156e26f2b (diff) | |
download | chromium_src-b0ce8fb2c24588aa001ea8ff7fa84da404fbc266.zip chromium_src-b0ce8fb2c24588aa001ea8ff7fa84da404fbc266.tar.gz chromium_src-b0ce8fb2c24588aa001ea8ff7fa84da404fbc266.tar.bz2 |
cr: Detect goma for gn
Review URL: https://codereview.chromium.org/1101863002
Cr-Commit-Position: refs/heads/master@{#326527}
Diffstat (limited to 'tools')
-rw-r--r-- | tools/cr/cr/actions/gn.py | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/tools/cr/cr/actions/gn.py b/tools/cr/cr/actions/gn.py index 1bbffbb..7c3ca3a 100644 --- a/tools/cr/cr/actions/gn.py +++ b/tools/cr/cr/actions/gn.py @@ -5,8 +5,8 @@ """A module to add gn support to cr.""" import cr -import shlex import os +import re GN_ARG_PREFIX = 'GN_ARG_' @@ -28,7 +28,7 @@ class GnPrepareOut(cr.PrepareOut): return not cr.AndroidPlatform.GetInstance().is_active def UpdateContext(self): - # Collapse GN_ARGS from all GN_ARG prefixes + # Collapse GN_ARGS from all GN_ARG prefixes. gn_args = cr.context.Find('GN_ARGS') or '' for key, value in cr.context.exported.items(): if key.startswith(GN_ARG_PREFIX): @@ -37,6 +37,16 @@ class GnPrepareOut(cr.PrepareOut): gn_args += (' is_debug=%s' % 'true' if cr.context['CR_BUILDTYPE'] == 'Debug' else 'false') + # Detect goma. + goma_binaries = cr.Host.SearchPath('gomacc', [ + '{GOMA_DIR}', + '/usr/local/google/code/goma', + os.path.expanduser('~/goma') + ]) + if goma_binaries: + gn_args += ' use_goma=true' + gn_args += ' goma_dir="%s"' % os.path.dirname(goma_binaries[0]) + cr.context['GN_ARGS'] = gn_args.strip() if cr.context.verbose >= 1: print cr.context.Substitute('GN_ARGS = {GN_ARGS}') @@ -49,7 +59,10 @@ class GnPrepareOut(cr.PrepareOut): cr.context['CR_OUT_FULL'], 'args.gn') args = {} - for arg in shlex.split(cr.context['GN_ARGS']): + # Split the argument list while preserving quotes, + # e.g., a="b c" becomes ('a', '"b c"'). + split_re = r'(?:[^\s,"]|"(?:\\.|[^"])*")+' + for arg in re.findall(split_re, cr.context['GN_ARGS']): key, value = arg.split('=', 1) args[key] = value |