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

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

Issue 9990006: ninja windows: Support magic idl build rules (Closed) Base URL: https://gyp.googlecode.com/svn/trunk
Patch Set: rename helper Created 8 years, 8 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') | test/win/idl-rules/history_indexer.idl » ('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 5f7a525cbd0724fc591f5bdd51cd2dd0cfefe617..dbfcf221d183a9ad6ec89f130219cd400c5db1b9 100644
--- a/pylib/gyp/generator/ninja.py
+++ b/pylib/gyp/generator/ninja.py
@@ -384,6 +384,39 @@ class NinjaWriter:
assert self.target.FinalOutput(), output
return self.target
+ def _WinIdlRule(self, source, prebuild, outputs):
+ """Handle the implicit VS .idl rule for one source file. Fills |outputs|
+ with files that are generated."""
+ outdir, output, vars, flags = self.msvs_settings.GetIdlBuildData(
+ source, self.config_name)
+ outdir = self.GypPathToNinja(outdir)
+ def fix_path(path, rel=None):
+ path = os.path.join(outdir, path)
+ dirname, basename = os.path.split(source)
+ root, ext = os.path.splitext(basename)
+ path = self.ExpandRuleVariables(
+ path, root, dirname, source, ext, basename)
+ if rel:
+ path = os.path.relpath(path, rel)
+ return path
+ vars = [(name, fix_path(value, outdir)) for name, value in vars]
+ output = [fix_path(p) for p in output]
+ vars.append(('outdir', outdir))
+ vars.append(('idlflags', flags))
+ input = self.GypPathToNinja(source)
+ self.ninja.build(output, 'idl', input,
+ variables=vars, order_only=prebuild)
+ outputs.extend(output)
+
+ def WriteWinIdlFiles(self, spec, prebuild):
+ """Writes rules to match MSVS's implicit idl handling."""
+ if self.msvs_settings.HasExplicitIdlRules(spec):
+ return []
+ outputs = []
+ for source in filter(lambda x: x.endswith('.idl'), spec['sources']):
+ self._WinIdlRule(source, prebuild, outputs)
+ return outputs
+
def WriteActionsRulesCopies(self, spec, extra_sources, prebuild,
mac_bundle_depends):
"""Write out the Actions, Rules, and Copies steps. Return a path
@@ -400,6 +433,9 @@ class NinjaWriter:
if 'copies' in spec:
outputs += self.WriteCopies(spec['copies'], prebuild)
+ if 'sources' in spec and self.flavor == 'win':
+ outputs += self.WriteWinIdlFiles(spec, prebuild)
+
stamp = self.WriteCollapsedDependencies('actions_rules_copies', outputs)
if self.is_mac_bundle:
@@ -658,7 +694,7 @@ class NinjaWriter:
elif self.flavor == 'mac' and ext == 'mm':
command = 'objcxx'
else:
- # TODO: should we assert here on unexpected extensions?
+ # Ignore unhandled extensions.
continue
input = self.GypPathToNinja(source)
output = self.GypPathToUniqueOutput(filename + self.obj_ext)
@@ -1184,6 +1220,12 @@ def GenerateOutputForConfig(target_list, target_dicts, data, params,
deplist='$out.dl',
rspfile='$out.rsp',
rspfile_content='$defines $includes $cflags $cflags_cc')
+ master_ninja.rule(
+ 'idl',
+ description='IDL $in',
+ command=('python gyp-win-tool midl-wrapper $outdir '
+ '$tlb $h $dlldata $iid $proxy $in '
+ '$idlflags'))
if flavor != 'mac' and flavor != 'win':
master_ninja.rule(
« no previous file with comments | « no previous file | pylib/gyp/msvs_emulation.py » ('j') | test/win/idl-rules/history_indexer.idl » ('J')

Powered by Google App Engine
This is Rietveld 408576698