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