summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorthakis@chromium.org <thakis@chromium.org@78cadc50-ecff-11dd-a971-7dbc132099af>2013-07-08 18:18:12 +0000
committerthakis@chromium.org <thakis@chromium.org@78cadc50-ecff-11dd-a971-7dbc132099af>2013-07-08 18:18:12 +0000
commitad617c17daad58cf225fc030081a2d663552b096 (patch)
tree9cd9586ea35792ec369a0d521596c8ab4f673ef0
parent9609d38a9099677e2daaf4fff77ef42d33b41803 (diff)
downloadgyp-ad617c17daad58cf225fc030081a2d663552b096.tar.gz
ninja: Only write ar_host, cc_host, cxx_host, ld_host in multi-toolset builds.
No intended functionality change: They are only used for targets with a toolset of 'host', which only happens only if generator_supports_multiple_toolsets is true. Saves a whopping 4 lines (out of ~148000) in ninja files (but it's within the first 8 lines of build.ninja, so it's at least somewhat visible 4 lines?) R=fischman@chromium.org, michaelbai@chromium.org Review URL: https://codereview.chromium.org/18236003 git-svn-id: http://gyp.googlecode.com/svn/trunk@1665 78cadc50-ecff-11dd-a971-7dbc132099af
-rw-r--r--pylib/gyp/generator/ninja.py51
-rwxr-xr-xtest/compiler-override/gyptest-compiler-global-settings.py10
-rw-r--r--test/make_global_settings/env-wrapper/gyptest-wrapper.py4
-rw-r--r--test/make_global_settings/wrapper/gyptest-wrapper.py4
4 files changed, 44 insertions, 25 deletions
diff --git a/pylib/gyp/generator/ninja.py b/pylib/gyp/generator/ninja.py
index 4344c0d6..86975e21 100644
--- a/pylib/gyp/generator/ninja.py
+++ b/pylib/gyp/generator/ninja.py
@@ -1565,11 +1565,6 @@ def GenerateOutputForConfig(target_list, target_dicts, data, params,
master_ninja.variable('cxx', CommandWithWrapper('CXX', wrappers, cxx))
ld = GetEnvironFallback(['LD_target', 'LD'], ld)
- if not cc_host:
- cc_host = cc
- if not cxx_host:
- cxx_host = cxx
-
if flavor == 'win':
master_ninja.variable('ld', ld)
master_ninja.variable('idl', 'midl.exe')
@@ -1581,26 +1576,32 @@ def GenerateOutputForConfig(target_list, target_dicts, data, params,
master_ninja.variable('ld', CommandWithWrapper('LINK', wrappers, ld))
master_ninja.variable('ar', GetEnvironFallback(['AR_target', 'AR'], 'ar'))
- master_ninja.variable('ar_host', GetEnvironFallback(['AR_host'], 'ar'))
- cc_host = GetEnvironFallback(['CC_host'], cc_host)
- cxx_host = GetEnvironFallback(['CXX_host'], cxx_host)
- ld_host = GetEnvironFallback(['LD_host'], ld_host)
-
- # The environment variable could be used in 'make_global_settings', like
- # ['CC.host', '$(CC)'] or ['CXX.host', '$(CXX)'], transform them here.
- if '$(CC)' in cc_host and cc_host_global_setting:
- cc_host = cc_host_global_setting.replace('$(CC)', cc)
- if '$(CXX)' in cxx_host and cxx_host_global_setting:
- cxx_host = cxx_host_global_setting.replace('$(CXX)', cxx)
- master_ninja.variable('cc_host',
- CommandWithWrapper('CC.host', wrappers, cc_host))
- master_ninja.variable('cxx_host',
- CommandWithWrapper('CXX.host', wrappers, cxx_host))
- if flavor == 'win':
- master_ninja.variable('ld_host', ld_host)
- else:
- master_ninja.variable('ld_host', CommandWithWrapper(
- 'LINK', wrappers, ld_host))
+ if generator_supports_multiple_toolsets:
+ if not cc_host:
+ cc_host = cc
+ if not cxx_host:
+ cxx_host = cxx
+
+ master_ninja.variable('ar_host', GetEnvironFallback(['AR_host'], 'ar'))
+ cc_host = GetEnvironFallback(['CC_host'], cc_host)
+ cxx_host = GetEnvironFallback(['CXX_host'], cxx_host)
+ ld_host = GetEnvironFallback(['LD_host'], ld_host)
+
+ # The environment variable could be used in 'make_global_settings', like
+ # ['CC.host', '$(CC)'] or ['CXX.host', '$(CXX)'], transform them here.
+ if '$(CC)' in cc_host and cc_host_global_setting:
+ cc_host = cc_host_global_setting.replace('$(CC)', cc)
+ if '$(CXX)' in cxx_host and cxx_host_global_setting:
+ cxx_host = cxx_host_global_setting.replace('$(CXX)', cxx)
+ master_ninja.variable('cc_host',
+ CommandWithWrapper('CC.host', wrappers, cc_host))
+ master_ninja.variable('cxx_host',
+ CommandWithWrapper('CXX.host', wrappers, cxx_host))
+ if flavor == 'win':
+ master_ninja.variable('ld_host', ld_host)
+ else:
+ master_ninja.variable('ld_host', CommandWithWrapper(
+ 'LINK', wrappers, ld_host))
master_ninja.newline()
diff --git a/test/compiler-override/gyptest-compiler-global-settings.py b/test/compiler-override/gyptest-compiler-global-settings.py
index 23ebe366..8a60e8fa 100755
--- a/test/compiler-override/gyptest-compiler-global-settings.py
+++ b/test/compiler-override/gyptest-compiler-global-settings.py
@@ -34,7 +34,12 @@ output = open(gypfile, 'w')
output.write(s.substitute(replacements))
output.close()
+old_env = dict(os.environ)
+os.environ['GYP_CROSSCOMPILE'] = '1'
test.run_gyp(gypfile)
+os.environ.clear()
+os.environ.update(old_env)
+
test.build(gypfile)
test.must_contain_all_lines(test.stdout(), ['my_cc.py', 'my_cxx.py', 'FOO'])
@@ -45,7 +50,12 @@ output = open(gypfile, 'w')
output.write(s.substitute(replacements))
output.close()
+old_env = dict(os.environ)
+os.environ['GYP_CROSSCOMPILE'] = '1'
test.run_gyp(gypfile)
+os.environ.clear()
+os.environ.update(old_env)
+
test.build(gypfile)
test.must_contain_all_lines(test.stdout(), ['my_cc.py', 'my_cxx.py', 'BAR'])
diff --git a/test/make_global_settings/env-wrapper/gyptest-wrapper.py b/test/make_global_settings/env-wrapper/gyptest-wrapper.py
index 5246c222..09470e1f 100644
--- a/test/make_global_settings/env-wrapper/gyptest-wrapper.py
+++ b/test/make_global_settings/env-wrapper/gyptest-wrapper.py
@@ -20,7 +20,11 @@ os.environ['CC.host_wrapper'] = 'ccache'
test = TestGyp.TestGyp(formats=test_format)
+old_env = dict(os.environ)
+os.environ['GYP_CROSSCOMPILE'] = '1'
test.run_gyp('wrapper.gyp')
+os.environ.clear()
+os.environ.update(old_env)
if test.format == 'ninja':
cc_expected = ('cc = ' + os.path.join('..', '..', 'distcc') + ' ' +
diff --git a/test/make_global_settings/wrapper/gyptest-wrapper.py b/test/make_global_settings/wrapper/gyptest-wrapper.py
index 48c1046b..3b391e57 100644
--- a/test/make_global_settings/wrapper/gyptest-wrapper.py
+++ b/test/make_global_settings/wrapper/gyptest-wrapper.py
@@ -18,7 +18,11 @@ if sys.platform in ('linux2', 'darwin'):
test = TestGyp.TestGyp(formats=test_format)
+old_env = dict(os.environ)
+os.environ['GYP_CROSSCOMPILE'] = '1'
test.run_gyp('wrapper.gyp')
+os.environ.clear()
+os.environ.update(old_env)
if test.format == 'make':
cc_expected = """ifneq (,$(filter $(origin CC), undefined default))