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

Side by Side 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: macro expansion 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | pylib/gyp/msvs_emulation.py » ('j') | pylib/gyp/msvs_emulation.py » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright (c) 2012 Google Inc. All rights reserved. 1 # Copyright (c) 2012 Google Inc. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 import copy 5 import copy
6 import gyp 6 import gyp
7 import gyp.common 7 import gyp.common
8 import gyp.msvs_emulation 8 import gyp.msvs_emulation
9 import gyp.MSVSVersion 9 import gyp.MSVSVersion
10 import gyp.system_test 10 import gyp.system_test
(...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after
377 377
378 if self.name != output and self.toolset == 'target': 378 if self.name != output and self.toolset == 'target':
379 # Write a short name to build this target. This benefits both the 379 # Write a short name to build this target. This benefits both the
380 # "build chrome" case as well as the gyp tests, which expect to be 380 # "build chrome" case as well as the gyp tests, which expect to be
381 # able to run actions and build libraries by their short name. 381 # able to run actions and build libraries by their short name.
382 self.ninja.build(self.name, 'phony', output) 382 self.ninja.build(self.name, 'phony', output)
383 383
384 assert self.target.FinalOutput(), output 384 assert self.target.FinalOutput(), output
385 return self.target 385 return self.target
386 386
387 def _HandleIdlFiles(self, spec, prebuild):
388 """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.
389 projects (e.g., WebKit) use .idl of a different import format with custom
390 build rules. So, we only do the implicit rules if they're not overridden by
391 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?
392 native_idl = True
393 for rule in spec.get('rules', []):
394 if rule['extension'] == 'idl' and int(rule.get('msvs_external_rule', 0)):
395 native_idl = False
396 if not native_idl:
397 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.
398 outputs = []
399 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.
400 dirname, basename = os.path.split(source)
401 root, ext = os.path.splitext(basename)
402 if ext == '.idl':
403 input = self.GypPathToNinja(source)
404 outdir, output, vars, flags = self.msvs_settings.GetIdlBuildData(
405 source, self.config_name)
406 outdir = self.GypPathToNinja(self.msvs_settings.ConvertVSMacros(outdir))
407 def fix_path(path, rel=None):
408 path = os.path.join(outdir, path)
409 path = self.ExpandRuleVariables(
410 path, root, dirname, source, ext, basename)
411 if rel:
412 path = os.path.relpath(path, rel)
413 return path
414 vars = [(name, fix_path(value, outdir)) for name, value in vars]
415 output = [fix_path(p) for p in output]
416 vars.append(('outdir', outdir))
417 vars.append(('idlflags', flags))
418 outputs.extend(output)
419 self.ninja.build(output, 'idl', input,
420 variables=vars, order_only=prebuild)
421 return outputs
422
387 def WriteActionsRulesCopies(self, spec, extra_sources, prebuild, 423 def WriteActionsRulesCopies(self, spec, extra_sources, prebuild,
388 mac_bundle_depends): 424 mac_bundle_depends):
389 """Write out the Actions, Rules, and Copies steps. Return a path 425 """Write out the Actions, Rules, and Copies steps. Return a path
390 representing the outputs of these steps.""" 426 representing the outputs of these steps."""
391 outputs = [] 427 outputs = []
392 extra_mac_bundle_resources = [] 428 extra_mac_bundle_resources = []
393 429
394 if 'actions' in spec: 430 if 'actions' in spec:
395 outputs += self.WriteActions(spec['actions'], extra_sources, prebuild, 431 outputs += self.WriteActions(spec['actions'], extra_sources, prebuild,
396 extra_mac_bundle_resources) 432 extra_mac_bundle_resources)
397 if 'rules' in spec: 433 if 'rules' in spec:
398 outputs += self.WriteRules(spec['rules'], extra_sources, prebuild, 434 outputs += self.WriteRules(spec['rules'], extra_sources, prebuild,
399 extra_mac_bundle_resources) 435 extra_mac_bundle_resources)
400 if 'copies' in spec: 436 if 'copies' in spec:
401 outputs += self.WriteCopies(spec['copies'], prebuild) 437 outputs += self.WriteCopies(spec['copies'], prebuild)
402 438
439 if 'sources' in spec:
440 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.
441
403 stamp = self.WriteCollapsedDependencies('actions_rules_copies', outputs) 442 stamp = self.WriteCollapsedDependencies('actions_rules_copies', outputs)
404 443
405 if self.is_mac_bundle: 444 if self.is_mac_bundle:
406 mac_bundle_resources = spec.get('mac_bundle_resources', []) + \ 445 mac_bundle_resources = spec.get('mac_bundle_resources', []) + \
407 extra_mac_bundle_resources 446 extra_mac_bundle_resources
408 self.WriteMacBundleResources(mac_bundle_resources, mac_bundle_depends) 447 self.WriteMacBundleResources(mac_bundle_resources, mac_bundle_depends)
409 self.WriteMacInfoPlist(mac_bundle_depends) 448 self.WriteMacInfoPlist(mac_bundle_depends)
410 449
411 return stamp 450 return stamp
412 451
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after
651 ext = ext[1:] 690 ext = ext[1:]
652 if ext in ('cc', 'cpp', 'cxx'): 691 if ext in ('cc', 'cpp', 'cxx'):
653 command = 'cxx' 692 command = 'cxx'
654 elif ext in ('c', 's', 'S'): 693 elif ext in ('c', 's', 'S'):
655 command = 'cc' 694 command = 'cc'
656 elif self.flavor == 'mac' and ext == 'm': 695 elif self.flavor == 'mac' and ext == 'm':
657 command = 'objc' 696 command = 'objc'
658 elif self.flavor == 'mac' and ext == 'mm': 697 elif self.flavor == 'mac' and ext == 'mm':
659 command = 'objcxx' 698 command = 'objcxx'
660 else: 699 else:
661 # TODO: should we assert here on unexpected extensions? 700 # Ignore unhandled extensions.
662 continue 701 continue
663 input = self.GypPathToNinja(source) 702 input = self.GypPathToNinja(source)
664 output = self.GypPathToUniqueOutput(filename + self.obj_ext) 703 output = self.GypPathToUniqueOutput(filename + self.obj_ext)
665 implicit = precompiled_header.GetObjDependencies([input], [output]) 704 implicit = precompiled_header.GetObjDependencies([input], [output])
666 self.ninja.build(output, command, input, 705 self.ninja.build(output, command, input,
667 implicit=[gch for _, _, gch in implicit], 706 implicit=[gch for _, _, gch in implicit],
668 order_only=predepends) 707 order_only=predepends)
669 outputs.append(output) 708 outputs.append(output)
670 709
671 self.WritePchTargets(pch_commands) 710 self.WritePchTargets(pch_commands)
(...skipping 505 matching lines...) Expand 10 before | Expand all | Expand 10 after
1177 master_ninja.rule( 1216 master_ninja.rule(
1178 'cxx', 1217 'cxx',
1179 description='CXX $out', 1218 description='CXX $out',
1180 command=('cmd /s /c "$cxx /nologo /showIncludes ' 1219 command=('cmd /s /c "$cxx /nologo /showIncludes '
1181 '@$out.rsp ' 1220 '@$out.rsp '
1182 '$cflags_pch_cc /c $in /Fo$out /Fd$pdbname ' 1221 '$cflags_pch_cc /c $in /Fo$out /Fd$pdbname '
1183 '| ninja-deplist-helper -q -f cl -o $out.dl"'), 1222 '| ninja-deplist-helper -q -f cl -o $out.dl"'),
1184 deplist='$out.dl', 1223 deplist='$out.dl',
1185 rspfile='$out.rsp', 1224 rspfile='$out.rsp',
1186 rspfile_content='$defines $includes $cflags $cflags_cc') 1225 rspfile_content='$defines $includes $cflags $cflags_cc')
1226 master_ninja.rule(
1227 'idl',
1228 description='IDL $in',
1229 command=('python gyp-win-tool midl-wrapper $outdir '
1230 '$tlb $h $dlldata $iid $proxy $in '
1231 '$idlflags'))
1187 1232
1188 if flavor != 'mac' and flavor != 'win': 1233 if flavor != 'mac' and flavor != 'win':
1189 master_ninja.rule( 1234 master_ninja.rule(
1190 'alink', 1235 'alink',
1191 description='AR $out', 1236 description='AR $out',
1192 command='rm -f $out && $ar rcsT $out $in') 1237 command='rm -f $out && $ar rcsT $out $in')
1193 master_ninja.rule( 1238 master_ninja.rule(
1194 'solink', 1239 'solink',
1195 description='SOLINK $out', 1240 description='SOLINK $out',
1196 command=('$ld -shared $ldflags -o $out -Wl,-soname=$soname ' 1241 command=('$ld -shared $ldflags -o $out -Wl,-soname=$soname '
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
1352 1397
1353 user_config = params.get('generator_flags', {}).get('config', None) 1398 user_config = params.get('generator_flags', {}).get('config', None)
1354 if user_config: 1399 if user_config:
1355 GenerateOutputForConfig(target_list, target_dicts, data, params, 1400 GenerateOutputForConfig(target_list, target_dicts, data, params,
1356 user_config) 1401 user_config)
1357 else: 1402 else:
1358 config_names = target_dicts[target_list[0]]['configurations'].keys() 1403 config_names = target_dicts[target_list[0]]['configurations'].keys()
1359 for config_name in config_names: 1404 for config_name in config_names:
1360 GenerateOutputForConfig(target_list, target_dicts, data, params, 1405 GenerateOutputForConfig(target_list, target_dicts, data, params,
1361 config_name) 1406 config_name)
OLDNEW
« 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