Index: pylib/gyp/generator/ninja.py |
diff --git a/pylib/gyp/generator/ninja.py b/pylib/gyp/generator/ninja.py |
index 3c41dacf5027984e3f81f07446d516c290920dd4..5516a7d701c87dd26ea5f08eb27df1d1f32ec08b 100644 |
--- a/pylib/gyp/generator/ninja.py |
+++ b/pylib/gyp/generator/ninja.py |
@@ -3,18 +3,19 @@ |
# found in the LICENSE file. |
import copy |
+import hashlib |
+import os.path |
+import re |
+import subprocess |
+import sys |
import gyp |
import gyp.common |
import gyp.msvs_emulation |
import gyp.MSVSVersion |
import gyp.system_test |
import gyp.xcode_emulation |
-import hashlib |
-import os.path |
-import re |
-import subprocess |
-import sys |
+from gyp.common import GetEnvironFallback |
import gyp.ninja_syntax as ninja_syntax |
generator_default_variables = { |
@@ -1201,7 +1202,6 @@ def CalculateVariables(default_variables, params): |
"""Calculate additional variables for use in the build (called by gyp).""" |
global generator_additional_non_configuration_keys |
global generator_additional_path_sections |
- cc_target = os.environ.get('CC.target', os.environ.get('CC', 'cc')) |
flavor = gyp.common.GetFlavor(params) |
if flavor == 'mac': |
default_variables.setdefault('OS', 'mac') |
@@ -1272,13 +1272,6 @@ def OpenOutput(path, mode='w'): |
return open(path, mode) |
-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'] |
@@ -1307,11 +1300,16 @@ def GenerateOutputForConfig(target_list, target_dicts, data, params, |
# 'CC_host'/'CXX_host' enviroment variable, cc_host/cxx_host should be set |
# to cc/cxx. |
if flavor == 'win': |
- cc = cxx = 'cl.exe' |
+ cc = 'cl.exe' |
+ cxx = 'cl.exe' |
+ ld = 'link.exe' |
gyp.msvs_emulation.GenerateEnvironmentFiles( |
toplevel_build, generator_flags, OpenOutput) |
else: |
- cc, cxx = 'gcc', 'g++' |
+ cc = 'gcc' |
+ cxx = 'g++' |
+ ld = '$cxx' |
+ |
cc_host = None |
cxx_host = None |
cc_host_global_setting = None |
@@ -1321,12 +1319,16 @@ def GenerateOutputForConfig(target_list, target_dicts, data, params, |
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) |
- if key == 'CC.host': cc_host_global_setting = value |
- if key == 'CXX.host': cxx_host_global_setting = value |
+ 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) |
+ cc_host_global_setting = value |
+ if key == 'CXX.host': |
+ cxx_host = os.path.join(build_to_root, value) |
+ cxx_host_global_setting = value |
flock = 'flock' |
if flavor == 'mac': |
@@ -1335,12 +1337,13 @@ def GenerateOutputForConfig(target_list, target_dicts, data, params, |
master_ninja.variable('cc', cc) |
cxx = GetEnvironFallback(['CXX_target', 'CXX'], cxx) |
master_ninja.variable('cxx', 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', 'link.exe') |
+ master_ninja.variable('ld', ld) |
master_ninja.variable('idl', 'midl.exe') |
master_ninja.variable('ar', 'lib.exe') |
master_ninja.variable('rc', 'rc.exe') |
@@ -1348,7 +1351,7 @@ def GenerateOutputForConfig(target_list, target_dicts, data, params, |
master_ninja.variable('mt', 'mt.exe') |
master_ninja.variable('use_dep_database', '1') |
else: |
- master_ninja.variable('ld', flock + ' linker.lock $cxx') |
+ master_ninja.variable('ld', flock + ' linker.lock ' + ld) |
master_ninja.variable('ar', GetEnvironFallback(['AR_target', 'AR'], 'ar')) |
master_ninja.variable('ar_host', GetEnvironFallback(['AR_host'], 'ar')) |
@@ -1356,16 +1359,17 @@ def GenerateOutputForConfig(target_list, target_dicts, data, params, |
cxx_host = GetEnvironFallback(['CXX_host'], cxx_host) |
# The environment variable could be used in 'make_global_settings', like |
# ['CC.host', '$(CC)'] or ['CXX.host', '$(CXX)'], transform them here. |
- if cc_host.find('$(CC)') != -1 and cc_host_global_setting: |
+ if '$(CC)' in cc_host and cc_host_global_setting: |
cc_host = cc_host_global_setting.replace('$(CC)', cc) |
- if cxx_host.find('$(CXX)') != -1 and cxx_host_global_setting: |
+ if '$(CXX)' in cxx_host and cxx_host_global_setting: |
cxx_host = cxx_host_global_setting.replace('$(CXX)', cxx) |
master_ninja.variable('cc_host', cc_host) |
master_ninja.variable('cxx_host', cxx_host) |
if flavor == 'win': |
master_ninja.variable('ld_host', os.environ.get('LD_host', '$ld')) |
else: |
- master_ninja.variable('ld_host', flock + ' linker.lock $cxx_host') |
+ ld_host = os.environ.get('LD_host', '$cxx_host') |
+ master_ninja.variable('ld_host', flock + ' linker.lock ' + ld_host) |
if flavor == 'mac': |
master_ninja.variable('mac_tool', os.path.join('.', 'gyp-mac-tool')) |
@@ -1516,14 +1520,19 @@ def GenerateOutputForConfig(target_list, target_dicts, data, params, |
restat=True) |
# Note that ldflags goes at the end so that it has the option of |
# overriding default settings earlier in the command line. |
+ command = ('%s gyp-win-tool link-wrapper $arch ' |
+ '$ld /nologo /OUT:$out /PDB:$out.pdb @$out.rsp' % |
+ sys.executable) |
+ if ('LD_target' not in os.environ |
+ and 'LD' not in os.environ |
+ and 'LD_host' not in os.environ): |
+ command += (' && %s gyp-win-tool manifest-wrapper $arch ' |
+ '$mt -nologo -manifest $manifests -out:$out.manifest' % |
Nico
2012/08/13 23:14:07
nit: Windows doesn't do cross-compiling, this isn'
Sam Clegg
2012/08/14 21:10:32
Done
|
+ sys.executable) |
master_ninja.rule( |
'link', |
description='LINK $out', |
- command=('%s gyp-win-tool link-wrapper $arch ' |
- '$ld /nologo /OUT:$out /PDB:$out.pdb @$out.rsp && ' |
- '%s gyp-win-tool manifest-wrapper $arch ' |
- '$mt -nologo -manifest $manifests -out:$out.manifest' % |
- (sys.executable, sys.executable)), |
+ command=command, |
rspfile='$out.rsp', |
rspfile_content='$in_newline $libs $ldflags') |
else: |