diff options
author | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-01-08 00:32:04 +0000 |
---|---|---|
committer | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-01-08 00:32:04 +0000 |
commit | 537987c53d294d25ed1c45140253bb60883b5e7c (patch) | |
tree | e8bc0aea14b91259f6872d67a0bf6fe13b3dee1b /build/gyp_chromium | |
parent | a30b21cd28c48c7bbfe09dcb40b991fff9b3150e (diff) | |
download | chromium_src-537987c53d294d25ed1c45140253bb60883b5e7c.zip chromium_src-537987c53d294d25ed1c45140253bb60883b5e7c.tar.gz chromium_src-537987c53d294d25ed1c45140253bb60883b5e7c.tar.bz2 |
GN Command line -D parsing, goma on Windows
This makes gyp_chromium pass defines defined via -D on the command line to GN.
Fixes double-escaping of strings from supplemental.gypi files.
Pass use_goma to the GN build.
Handle "use_goma" and "use_goma=1" (same for other boolean values). Previously values with no equals sign were getting converted to 'true', which doesn't match '1' which we look for.
Output goma wrappers in the GYP header for Windows toolchains.
R=scottmg@chromium.org
Review URL: https://codereview.chromium.org/123463005
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@243446 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'build/gyp_chromium')
-rwxr-xr-x | build/gyp_chromium | 49 |
1 files changed, 34 insertions, 15 deletions
diff --git a/build/gyp_chromium b/build/gyp_chromium index 4eafdd5..2fc59f7 100755 --- a/build/gyp_chromium +++ b/build/gyp_chromium @@ -78,10 +78,27 @@ def EscapeStringForGN(s): return '"' + s.replace('$', '\\$').replace('"', '\\"') + '"' +def ProcessGypDefinesItems(items): + """Converts a list of strings to a list of key-value pairs.""" + result = [] + for item in items: + tokens = item.split('=', 1) + # Some GYP variables have hyphens, which we don't support. + key = FormatKeyForGN(tokens[0]) + if len(tokens) == 2: + result += [(key, tokens[1])] + else: + # No value supplied, treat it as a boolean and set it. Note that we + # use the string '1' here so we have a consistent definition whether + # you do 'foo=1' or 'foo'. + result += [(key, '1')] + return result + def GetGypVarsForGN(supplemental_files): """Returns a dictionary of all GYP vars that we will be passing to GN.""" - vars_dict = {} + # GYP defines from the supplemental.gypi files. + supp_items = [] for supplement in supplemental_files: with open(supplement, 'r') as f: try: @@ -91,21 +108,21 @@ def GetGypVarsForGN(supplemental_files): raise variables = file_data.get('variables', []) for v in variables: - vars_dict[FormatKeyForGN(v)] = EscapeStringForGN(str(variables[v])) + supp_items += [(FormatKeyForGN(v), str(variables[v]))] - env_string = os.environ.get('GYP_DEFINES', '') - items = shlex.split(env_string) - for item in items: - tokens = item.split('=', 1) - # Some GYP variables have hyphens, which we don't support. - key = FormatKeyForGN(tokens[0]) - if len(tokens) == 2: - vars_dict[key] = tokens[1] - else: - # No value supplied, treat it as a boolean and set it. - vars_dict[key] = 'true' + # GYP defines from the environment. + env_items = ProcessGypDefinesItems( + shlex.split(os.environ.get('GYP_DEFINES', ''))) + + # GYP defines from the command line. We can't use optparse since we want + # to ignore all arguments other than "-D". + cmdline_input_items = [] + for i in range(len(sys.argv))[1:]: + if sys.argv[i] == '-D' and i + 1 < len(sys.argv): + cmdline_input_items += [sys.argv[i + 1]] + cmdline_items = ProcessGypDefinesItems(cmdline_input_items) - return vars_dict + return dict(supp_items + env_items + cmdline_items) def GetArgsStringForGN(supplemental_files): @@ -113,6 +130,7 @@ def GetArgsStringForGN(supplemental_files): Based on a subset of the GYP variables that have been rewritten a bit.""" vars_dict = GetGypVarsForGN(supplemental_files) + print vars_dict gn_args = '' # Note: These are the additional flags passed to various builds by builders @@ -136,7 +154,7 @@ def GetArgsStringForGN(supplemental_files): ('component', 'shared_library', 'is_component_build=true'), ('clang', '1', 'is_clang=true'), ('target_arch', 'ia32', 'cpu_arch="x86"'), - ('target_arch', 'x64', 'cpu_arch="x64"'), + ('target_arch', 'x64', 'cpu_arch="x64" force_win64=true'), ('target_arch', 'arm', 'cpu_arch="arm"'), ('target_arch', 'mipsel', 'cpu_arch="mipsel"'), ('fastbuild', '0', 'symbol_level=2'), @@ -146,6 +164,7 @@ def GetArgsStringForGN(supplemental_files): ('OS', 'android', 'os="android"'), ('chromeos', '1', 'os="chromeos"'), ('use_aura', '1', 'use_aura=true'), + ('use_goma', '1', 'use_goma=true'), ('asan', '1', 'is_asan=true'), ('lsan', '1', 'is_lsan=true'), ] |