Chromium Code Reviews| Index: pylib/gyp/generator/ninja.py |
| diff --git a/pylib/gyp/generator/ninja.py b/pylib/gyp/generator/ninja.py |
| index 7c66a1d0a7544eef40a0d46917fc5cb8ed274226..199b829311c9ce0948be33a63dae58a4e862c7c8 100644 |
| --- a/pylib/gyp/generator/ninja.py |
| +++ b/pylib/gyp/generator/ninja.py |
| @@ -47,7 +47,12 @@ generator_default_variables = { |
| # TODO: figure out how to not build extra host objects in the non-cross-compile |
| # case when this is enabled, and enable unconditionally. |
| generator_supports_multiple_toolsets = ( |
| - os.environ.get('AR_target') or os.environ.get('CC_target') or |
| + os.environ.get('GYP_CROSSCOMPILE') or |
| + os.environ.get('AR_host') or |
| + os.environ.get('CC_host') or |
| + os.environ.get('CXX_host') or |
| + os.environ.get('AR_target') or |
| + os.environ.get('CC_target') or |
| os.environ.get('CXX_target')) |
| @@ -577,11 +582,11 @@ class NinjaWriter: |
| def WriteSources(self, config_name, config, sources, predepends, |
| precompiled_header): |
| """Write build rules to compile all of |sources|.""" |
| - if self.toolset == 'target': |
| - self.ninja.variable('ar', '$ar_target') |
| - self.ninja.variable('cc', '$cc_target') |
| - self.ninja.variable('cxx', '$cxx_target') |
| - self.ninja.variable('ld', '$ld_target') |
| + if self.toolset == 'host': |
| + self.ninja.variable('ar', '$ar_host') |
| + self.ninja.variable('cc', '$cc_host') |
| + self.ninja.variable('cxx', '$cxx_host') |
| + self.ninja.variable('ld', '$ld_host') |
| if self.flavor == 'mac': |
| cflags = self.xcode_settings.GetCflags(config_name) |
| @@ -1031,6 +1036,13 @@ def OpenOutput(path): |
| return open(path, 'w') |
| +def GetEnvironFallback(var_list, default): |
| + for var in var_list: |
| + if var in os.environ: |
| + return os.environ[var] |
| + return default |
| + |
| + |
| def GenerateOutputForConfig(target_list, target_dicts, data, params, |
| config_name): |
| options = params['options'] |
| @@ -1054,31 +1066,34 @@ def GenerateOutputForConfig(target_list, target_dicts, data, params, |
| cc = cxx = 'cl' |
| else: |
| cc, cxx = 'gcc', 'g++' |
| + cc_host, cxx_host = cc, cxx |
|
Nico
2012/08/03 04:41:34
The mac bots set just 'CC' and nothing else. In th
|
| build_file, _, _ = gyp.common.ParseQualifiedTarget(target_list[0]) |
| make_global_settings = data[build_file].get('make_global_settings', []) |
| build_to_root = InvertRelativePath(build_dir) |
| for key, value in make_global_settings: |
| if key == 'CC': cc = os.path.join(build_to_root, value) |
| if key == 'CXX': cxx = os.path.join(build_to_root, value) |
| + if key == 'CC.host': cc_host = os.path.join(build_to_root, value) |
| + if key == 'CXX.host': cxx_host = os.path.join(build_to_root, value) |
| flock = 'flock' |
| if flavor == 'mac': |
| flock = './gyp-mac-tool flock' |
| - master_ninja.variable('ar', os.environ.get('AR', 'ar')) |
| - master_ninja.variable('cc', os.environ.get('CC', cc)) |
| - master_ninja.variable('cxx', os.environ.get('CXX', cxx)) |
| + master_ninja.variable('ar', GetEnvironFallback(['AR_target', 'AR'], 'ar')) |
| + master_ninja.variable('cc', GetEnvironFallback(['CC_target', 'CC'], cc)) |
| + master_ninja.variable('cxx', GetEnvironFallback(['CXX_target', 'CXX'], cxx)) |
| if flavor == 'win': |
| master_ninja.variable('ld', 'link') |
| else: |
| master_ninja.variable('ld', flock + ' linker.lock $cxx') |
| - master_ninja.variable('ar_target', os.environ.get('AR_target', '$ar')) |
| - master_ninja.variable('cc_target', os.environ.get('CC_target', '$cc')) |
| - master_ninja.variable('cxx_target', os.environ.get('CXX_target', '$cxx')) |
| + master_ninja.variable('ar_host', GetEnvironFallback(['AR_host'], 'ar')) |
| + master_ninja.variable('cc_host', GetEnvironFallback(['CC_host'], cc_host)) |
| + master_ninja.variable('cxx_host', GetEnvironFallback(['CXX_host'], cxx_host)) |
| if flavor == 'win': |
| - master_ninja.variable('ld_target', 'link') |
| + master_ninja.variable('ld_host', 'link') |
| else: |
| - master_ninja.variable('ld_target', flock + ' linker.lock $cxx_target') |
| + master_ninja.variable('ld_host', flock + ' linker.lock $cxx_host') |
| if flavor == 'mac': |
| master_ninja.variable('mac_tool', os.path.join('.', 'gyp-mac-tool')) |