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

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: update docstrings 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
« no previous file with comments | « no previous file | pylib/gyp/msvs_emulation.py » ('j') | pylib/gyp/msvs_emulation.py » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pylib/gyp/generator/ninja.py
diff --git a/pylib/gyp/generator/ninja.py b/pylib/gyp/generator/ninja.py
index 19dcc1bb7fe788a0323c5de4946ee84350b21e59..e05aad6b84db3d225ecb02bdc46b571b65d6cc14 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 == 'mac':
+ pch = gyp.xcode_emulation.MacPrefixHeader(
+ self.xcode_settings, self.GypPathToNinja,
+ lambda path, lang: self.GypPathToUniqueOutput(path + '-' + lang))
+ elif self.flavor == 'win':
+ pch = gyp.msvs_emulation.PrecompiledHeader(
+ self.msvs_settings, config_name, self.GypPathToNinja)
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')])
@@ -748,7 +754,7 @@ class NinjaWriter:
output = self.GypPathToUniqueOutput(filename + obj_ext)
implicit = precompiled_header.GetObjDependencies([input], [output])
self.ninja.build(output, command, input,
- implicit=[gch for _, _, gch in implicit],
+ implicit=implicit,
order_only=predepends)
outputs.append(output)
@@ -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
+ 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 '
Nico 2012/05/23 20:53:29 Out of interest: Have you compared empty build tim
scottmg 2012/05/24 20:34:39 I didn't time it. I thought about doing it like th
'| 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',
« no previous file with comments | « no previous file | pylib/gyp/msvs_emulation.py » ('j') | pylib/gyp/msvs_emulation.py » ('J')

Powered by Google App Engine
This is Rietveld 408576698