OLD | NEW |
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 Loading... |
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 _WinIdlRule(self, source, prebuild, outputs): |
| 388 """Handle the implicit VS .idl rule for one source file. Fills |outputs| |
| 389 with files that are generated.""" |
| 390 outdir, output, vars, flags = self.msvs_settings.GetIdlBuildData( |
| 391 source, self.config_name) |
| 392 outdir = self.GypPathToNinja(outdir) |
| 393 def fix_path(path, rel=None): |
| 394 path = os.path.join(outdir, path) |
| 395 dirname, basename = os.path.split(source) |
| 396 root, ext = os.path.splitext(basename) |
| 397 path = self.ExpandRuleVariables( |
| 398 path, root, dirname, source, ext, basename) |
| 399 if rel: |
| 400 path = os.path.relpath(path, rel) |
| 401 return path |
| 402 vars = [(name, fix_path(value, outdir)) for name, value in vars] |
| 403 output = [fix_path(p) for p in output] |
| 404 vars.append(('outdir', outdir)) |
| 405 vars.append(('idlflags', flags)) |
| 406 input = self.GypPathToNinja(source) |
| 407 self.ninja.build(output, 'idl', input, |
| 408 variables=vars, order_only=prebuild) |
| 409 outputs.extend(output) |
| 410 |
| 411 def WriteWinIdlFiles(self, spec, prebuild): |
| 412 """Writes rules to match MSVS's implicit idl handling.""" |
| 413 assert self.flavor == 'win' |
| 414 if self.msvs_settings.HasExplicitIdlRules(spec): |
| 415 return [] |
| 416 outputs = [] |
| 417 for source in filter(lambda x: x.endswith('.idl'), spec['sources']): |
| 418 self._WinIdlRule(source, prebuild, outputs) |
| 419 return outputs |
| 420 |
387 def WriteActionsRulesCopies(self, spec, extra_sources, prebuild, | 421 def WriteActionsRulesCopies(self, spec, extra_sources, prebuild, |
388 mac_bundle_depends): | 422 mac_bundle_depends): |
389 """Write out the Actions, Rules, and Copies steps. Return a path | 423 """Write out the Actions, Rules, and Copies steps. Return a path |
390 representing the outputs of these steps.""" | 424 representing the outputs of these steps.""" |
391 outputs = [] | 425 outputs = [] |
392 extra_mac_bundle_resources = [] | 426 extra_mac_bundle_resources = [] |
393 | 427 |
394 if 'actions' in spec: | 428 if 'actions' in spec: |
395 outputs += self.WriteActions(spec['actions'], extra_sources, prebuild, | 429 outputs += self.WriteActions(spec['actions'], extra_sources, prebuild, |
396 extra_mac_bundle_resources) | 430 extra_mac_bundle_resources) |
397 if 'rules' in spec: | 431 if 'rules' in spec: |
398 outputs += self.WriteRules(spec['rules'], extra_sources, prebuild, | 432 outputs += self.WriteRules(spec['rules'], extra_sources, prebuild, |
399 extra_mac_bundle_resources) | 433 extra_mac_bundle_resources) |
400 if 'copies' in spec: | 434 if 'copies' in spec: |
401 outputs += self.WriteCopies(spec['copies'], prebuild) | 435 outputs += self.WriteCopies(spec['copies'], prebuild) |
402 | 436 |
| 437 if 'sources' in spec and self.flavor == 'win': |
| 438 outputs += self.WriteWinIdlFiles(spec, prebuild) |
| 439 |
403 stamp = self.WriteCollapsedDependencies('actions_rules_copies', outputs) | 440 stamp = self.WriteCollapsedDependencies('actions_rules_copies', outputs) |
404 | 441 |
405 if self.is_mac_bundle: | 442 if self.is_mac_bundle: |
406 mac_bundle_resources = spec.get('mac_bundle_resources', []) + \ | 443 mac_bundle_resources = spec.get('mac_bundle_resources', []) + \ |
407 extra_mac_bundle_resources | 444 extra_mac_bundle_resources |
408 self.WriteMacBundleResources(mac_bundle_resources, mac_bundle_depends) | 445 self.WriteMacBundleResources(mac_bundle_resources, mac_bundle_depends) |
409 self.WriteMacInfoPlist(mac_bundle_depends) | 446 self.WriteMacInfoPlist(mac_bundle_depends) |
410 | 447 |
411 return stamp | 448 return stamp |
412 | 449 |
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
651 ext = ext[1:] | 688 ext = ext[1:] |
652 if ext in ('cc', 'cpp', 'cxx'): | 689 if ext in ('cc', 'cpp', 'cxx'): |
653 command = 'cxx' | 690 command = 'cxx' |
654 elif ext in ('c', 's', 'S'): | 691 elif ext in ('c', 's', 'S'): |
655 command = 'cc' | 692 command = 'cc' |
656 elif self.flavor == 'mac' and ext == 'm': | 693 elif self.flavor == 'mac' and ext == 'm': |
657 command = 'objc' | 694 command = 'objc' |
658 elif self.flavor == 'mac' and ext == 'mm': | 695 elif self.flavor == 'mac' and ext == 'mm': |
659 command = 'objcxx' | 696 command = 'objcxx' |
660 else: | 697 else: |
661 # TODO: should we assert here on unexpected extensions? | 698 # Ignore unhandled extensions. |
662 continue | 699 continue |
663 input = self.GypPathToNinja(source) | 700 input = self.GypPathToNinja(source) |
664 output = self.GypPathToUniqueOutput(filename + self.obj_ext) | 701 output = self.GypPathToUniqueOutput(filename + self.obj_ext) |
665 implicit = precompiled_header.GetObjDependencies([input], [output]) | 702 implicit = precompiled_header.GetObjDependencies([input], [output]) |
666 self.ninja.build(output, command, input, | 703 self.ninja.build(output, command, input, |
667 implicit=[gch for _, _, gch in implicit], | 704 implicit=[gch for _, _, gch in implicit], |
668 order_only=predepends) | 705 order_only=predepends) |
669 outputs.append(output) | 706 outputs.append(output) |
670 | 707 |
671 self.WritePchTargets(pch_commands) | 708 self.WritePchTargets(pch_commands) |
(...skipping 506 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1178 master_ninja.rule( | 1215 master_ninja.rule( |
1179 'cxx', | 1216 'cxx', |
1180 description='CXX $out', | 1217 description='CXX $out', |
1181 command=('cmd /s /c "$cxx /nologo /showIncludes ' | 1218 command=('cmd /s /c "$cxx /nologo /showIncludes ' |
1182 '@$out.rsp ' | 1219 '@$out.rsp ' |
1183 '$cflags_pch_cc /c $in /Fo$out /Fd$pdbname ' | 1220 '$cflags_pch_cc /c $in /Fo$out /Fd$pdbname ' |
1184 '| ninja-deplist-helper -q -f cl -o $out.dl"'), | 1221 '| ninja-deplist-helper -q -f cl -o $out.dl"'), |
1185 deplist='$out.dl', | 1222 deplist='$out.dl', |
1186 rspfile='$out.rsp', | 1223 rspfile='$out.rsp', |
1187 rspfile_content='$defines $includes $cflags $cflags_cc') | 1224 rspfile_content='$defines $includes $cflags $cflags_cc') |
| 1225 master_ninja.rule( |
| 1226 'idl', |
| 1227 description='IDL $in', |
| 1228 command=('python gyp-win-tool midl-wrapper $outdir ' |
| 1229 '$tlb $h $dlldata $iid $proxy $in ' |
| 1230 '$idlflags')) |
1188 | 1231 |
1189 if flavor != 'mac' and flavor != 'win': | 1232 if flavor != 'mac' and flavor != 'win': |
1190 master_ninja.rule( | 1233 master_ninja.rule( |
1191 'alink', | 1234 'alink', |
1192 description='AR $out', | 1235 description='AR $out', |
1193 command='rm -f $out && $ar rcsT $out $in') | 1236 command='rm -f $out && $ar rcsT $out $in') |
1194 master_ninja.rule( | 1237 master_ninja.rule( |
1195 'solink', | 1238 'solink', |
1196 description='SOLINK $out', | 1239 description='SOLINK $out', |
1197 command=('$ld -shared $ldflags -o $out -Wl,-soname=$soname ' | 1240 command=('$ld -shared $ldflags -o $out -Wl,-soname=$soname ' |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1353 | 1396 |
1354 user_config = params.get('generator_flags', {}).get('config', None) | 1397 user_config = params.get('generator_flags', {}).get('config', None) |
1355 if user_config: | 1398 if user_config: |
1356 GenerateOutputForConfig(target_list, target_dicts, data, params, | 1399 GenerateOutputForConfig(target_list, target_dicts, data, params, |
1357 user_config) | 1400 user_config) |
1358 else: | 1401 else: |
1359 config_names = target_dicts[target_list[0]]['configurations'].keys() | 1402 config_names = target_dicts[target_list[0]]['configurations'].keys() |
1360 for config_name in config_names: | 1403 for config_name in config_names: |
1361 GenerateOutputForConfig(target_list, target_dicts, data, params, | 1404 GenerateOutputForConfig(target_list, target_dicts, data, params, |
1362 config_name) | 1405 config_name) |
OLD | NEW |