Index: pylib/gyp/generator/ninja.py |
diff --git a/pylib/gyp/generator/ninja.py b/pylib/gyp/generator/ninja.py |
index 5f7a525cbd0724fc591f5bdd51cd2dd0cfefe617..6c12979d8737daaf954473d4a6f254b89292141c 100644 |
--- a/pylib/gyp/generator/ninja.py |
+++ b/pylib/gyp/generator/ninja.py |
@@ -384,6 +384,42 @@ class NinjaWriter: |
assert self.target.FinalOutput(), output |
return self.target |
+ def _HandleIdlFiles(self, spec, prebuild): |
+ """Visual Studio has implicit .idl build rules for MIDL files, but other |
Nico
2012/04/05 04:37:11
I'd make the docstring just """Writes rules for MS
scottmg
2012/04/05 17:52:42
Done.
|
+ projects (e.g., WebKit) use .idl of a different import format with custom |
+ build rules. So, we only do the implicit rules if they're not overridden by |
+ explicit rules.""" |
Nico
2012/04/05 04:37:11
This function is fairly long and branchy. I find f
scottmg
2012/04/05 17:52:42
True, improved-ish?
|
+ native_idl = True |
+ for rule in spec.get('rules', []): |
+ if rule['extension'] == 'idl' and int(rule.get('msvs_external_rule', 0)): |
+ native_idl = False |
+ if not native_idl: |
+ return [] |
Nico
2012/04/05 04:37:11
Maybe this could be
if self.msvs_settings.HasEx
scottmg
2012/04/05 17:52:42
Done.
|
+ outputs = [] |
+ for source in spec['sources']: |
Nico
2012/04/05 04:37:11
Maybe
for source in filter(lambda x: x.endswith('
scottmg
2012/04/05 17:52:42
Done.
|
+ dirname, basename = os.path.split(source) |
+ root, ext = os.path.splitext(basename) |
+ if ext == '.idl': |
+ input = self.GypPathToNinja(source) |
+ outdir, output, vars, flags = self.msvs_settings.GetIdlBuildData( |
+ source, self.config_name) |
+ outdir = self.GypPathToNinja(self.msvs_settings.ConvertVSMacros(outdir)) |
+ def fix_path(path, rel=None): |
+ path = os.path.join(outdir, path) |
+ 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)) |
+ outputs.extend(output) |
+ self.ninja.build(output, 'idl', input, |
+ variables=vars, order_only=prebuild) |
+ 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 +436,9 @@ class NinjaWriter: |
if 'copies' in spec: |
outputs += self.WriteCopies(spec['copies'], prebuild) |
+ if 'sources' in spec: |
+ outputs += self._HandleIdlFiles(spec, prebuild) |
Nico
2012/04/05 04:37:11
For consistency with the rest of this function, Wr
scottmg
2012/04/05 17:52:42
Done.
|
+ |
stamp = self.WriteCollapsedDependencies('actions_rules_copies', outputs) |
if self.is_mac_bundle: |
@@ -658,7 +697,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 +1223,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( |