Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1025)

Unified Diff: pylib/gyp/generator/ninja.py

Issue 10407108: ninja windows: support precompiled headers (Closed) Base URL: https://gyp.googlecode.com/svn/trunk
Patch Set: no-op for linux, simplify? extension handling Created 8 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: pylib/gyp/generator/ninja.py
diff --git a/pylib/gyp/generator/ninja.py b/pylib/gyp/generator/ninja.py
index 19dcc1bb7fe788a0323c5de4946ee84350b21e59..50f075908408a966ccb2cdba66646d1e0bace6d7 100644
--- a/pylib/gyp/generator/ninja.py
+++ b/pylib/gyp/generator/ninja.py
@@ -377,11 +377,16 @@ class NinjaWriter:
link_deps = []
sources = spec.get('sources', []) + extra_sources
if sources:
+ pch = None
+ if self.flavor == 'win':
+ pch = gyp.msvs_emulation.PrecompiledHeader(
+ self.msvs_settings, config_name, self.GypPathToNinja)
+ else:
+ pch = gyp.xcode_emulation.MacPrefixHeader(
+ self.xcode_settings, self.GypPathToNinja,
+ lambda path, lang: self.GypPathToUniqueOutput(path + '-' + lang))
link_deps = self.WriteSources(
- config_name, config, sources, compile_depends_stamp,
- gyp.xcode_emulation.MacPrefixHeader(
- self.xcode_settings, self.GypPathToNinja,
- lambda path, lang: self.GypPathToUniqueOutput(path + '-' + lang)))
+ config_name, config, sources, compile_depends_stamp, pch)
# Some actions/rules output 'sources' that are already object files.
link_deps += [self.GypPathToNinja(f)
for f in sources if f.endswith(self.obj_ext)]
@@ -681,6 +686,7 @@ class NinjaWriter:
cflags_cc = self.msvs_settings.GetCflagsCC(config_name)
extra_defines = self.msvs_settings.GetComputedDefines(config_name)
self.WriteVariableList('pdbname', [self.name + '.pdb'])
+ self.WriteVariableList('pchprefix', [self.name])
else:
cflags = config.get('cflags', [])
cflags_c = config.get('cflags_c', [])
@@ -701,7 +707,7 @@ class NinjaWriter:
[QuoteShellArgument('-I' + self.GypPathToNinja(i), self.flavor)
for i in include_dirs])
- pch_commands = precompiled_header.GetGchBuildCommands()
+ pch_commands = precompiled_header.GetPchBuildCommands()
if self.flavor == 'mac':
self.WriteVariableList('cflags_pch_c',
[precompiled_header.GetInclude('c')])
@@ -762,7 +768,7 @@ class NinjaWriter:
if not pch_commands:
return
- for gch, lang_flag, lang, input in pch_commands:
+ for gch, lang_flag, lang, input, extra_variables in pch_commands:
var_name = {
'c': 'cflags_pch_c',
'cc': 'cflags_pch_cc',
@@ -771,8 +777,9 @@ class NinjaWriter:
}[lang]
cmd = { 'c': 'cc', 'cc': 'cxx', 'm': 'objc', 'mm': 'objcxx', }.get(lang)
- self.ninja.build(gch, cmd, input, variables=[(var_name, lang_flag)])
-
+ variables = [(var_name, lang_flag)]
+ variables += extra_variables
Nico 2012/05/25 22:35:39 maybe: variables = [(var_name, lang_flag)] + extra
scottmg 2012/05/26 02:27:12 Done.
+ self.ninja.build(gch, cmd, input, variables=variables)
def WriteLink(self, spec, config_name, config, link_deps):
"""Write out a link step. Fills out target.binary. """
@@ -1289,12 +1296,17 @@ def GenerateOutputForConfig(target_list, target_dicts, data, params,
else:
# TODO(scottmg): Requires fork of ninja for dependency and linking
# support: https://github.com/sgraham/ninja
+ #
+ # Normally, we want to name the object file when we run compile step. This
+ # is done with /Fo. However, when compiling a precompiled header, the
+ # flag is /Fp, so override that in the pch compile step.
+ master_ninja.variable('outflag', '/Fo')
master_ninja.rule(
'cc',
description='CC $out',
command=('cmd /s /c "$cc /nologo /showIncludes '
'@$out.rsp '
- '$cflags_pch_c /c $in /Fo$out /Fd$pdbname '
+ '$cflags_pch_c /c $in $outflag$out $pchobj /Fd$pdbname '
'| ninja-deplist-helper -r . -q -f cl -o $out.dl"'),
deplist='$out.dl',
rspfile='$out.rsp',
@@ -1304,7 +1316,7 @@ def GenerateOutputForConfig(target_list, target_dicts, data, params,
description='CXX $out',
command=('cmd /s /c "$cxx /nologo /showIncludes '
'@$out.rsp '
- '$cflags_pch_cc /c $in /Fo$out /Fd$pdbname '
+ '$cflags_pch_cc /c $in $outflag$out $pchobj /Fd$pdbname '
'| ninja-deplist-helper -r . -q -f cl -o $out.dl"'),
deplist='$out.dl',
rspfile='$out.rsp',

Powered by Google App Engine
This is Rietveld 408576698