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 364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
375 # If we have actions/rules/copies, we depend directly on those, but | 375 # If we have actions/rules/copies, we depend directly on those, but |
376 # otherwise we depend on dependent target's actions/rules/copies etc. | 376 # otherwise we depend on dependent target's actions/rules/copies etc. |
377 # We never need to explicitly depend on previous target's link steps, | 377 # We never need to explicitly depend on previous target's link steps, |
378 # because no compile ever depends on them. | 378 # because no compile ever depends on them. |
379 compile_depends_stamp = (self.target.actions_stamp or compile_depends) | 379 compile_depends_stamp = (self.target.actions_stamp or compile_depends) |
380 | 380 |
381 # Write out the compilation steps, if any. | 381 # Write out the compilation steps, if any. |
382 link_deps = [] | 382 link_deps = [] |
383 sources = spec.get('sources', []) + extra_sources | 383 sources = spec.get('sources', []) + extra_sources |
384 if sources: | 384 if sources: |
| 385 pch = None |
| 386 if self.flavor == 'win': |
| 387 pch = gyp.msvs_emulation.PrecompiledHeader( |
| 388 self.msvs_settings, config_name, self.GypPathToNinja) |
| 389 else: |
| 390 pch = gyp.xcode_emulation.MacPrefixHeader( |
| 391 self.xcode_settings, self.GypPathToNinja, |
| 392 lambda path, lang: self.GypPathToUniqueOutput(path + '-' + lang)) |
385 link_deps = self.WriteSources( | 393 link_deps = self.WriteSources( |
386 config_name, config, sources, compile_depends_stamp, | 394 config_name, config, sources, compile_depends_stamp, pch) |
387 gyp.xcode_emulation.MacPrefixHeader( | |
388 self.xcode_settings, self.GypPathToNinja, | |
389 lambda path, lang: self.GypPathToUniqueOutput(path + '-' + lang))) | |
390 # Some actions/rules output 'sources' that are already object files. | 395 # Some actions/rules output 'sources' that are already object files. |
391 link_deps += [self.GypPathToNinja(f) | 396 link_deps += [self.GypPathToNinja(f) |
392 for f in sources if f.endswith(self.obj_ext)] | 397 for f in sources if f.endswith(self.obj_ext)] |
393 | 398 |
394 if self.flavor == 'win' and self.target.type == 'static_library': | 399 if self.flavor == 'win' and self.target.type == 'static_library': |
395 self.target.component_objs = link_deps | 400 self.target.component_objs = link_deps |
396 | 401 |
397 # Write out a link step, if needed. | 402 # Write out a link step, if needed. |
398 output = None | 403 output = None |
399 if link_deps or self.target.actions_stamp or actions_depends: | 404 if link_deps or self.target.actions_stamp or actions_depends: |
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
679 cflags_objc = ['$cflags_c'] + \ | 684 cflags_objc = ['$cflags_c'] + \ |
680 self.xcode_settings.GetCflagsObjC(config_name) | 685 self.xcode_settings.GetCflagsObjC(config_name) |
681 cflags_objcc = ['$cflags_cc'] + \ | 686 cflags_objcc = ['$cflags_cc'] + \ |
682 self.xcode_settings.GetCflagsObjCC(config_name) | 687 self.xcode_settings.GetCflagsObjCC(config_name) |
683 elif self.flavor == 'win': | 688 elif self.flavor == 'win': |
684 cflags = self.msvs_settings.GetCflags(config_name) | 689 cflags = self.msvs_settings.GetCflags(config_name) |
685 cflags_c = self.msvs_settings.GetCflagsC(config_name) | 690 cflags_c = self.msvs_settings.GetCflagsC(config_name) |
686 cflags_cc = self.msvs_settings.GetCflagsCC(config_name) | 691 cflags_cc = self.msvs_settings.GetCflagsCC(config_name) |
687 extra_defines = self.msvs_settings.GetComputedDefines(config_name) | 692 extra_defines = self.msvs_settings.GetComputedDefines(config_name) |
688 self.WriteVariableList('pdbname', [self.name + '.pdb']) | 693 self.WriteVariableList('pdbname', [self.name + '.pdb']) |
| 694 self.WriteVariableList('pchprefix', [self.name]) |
689 else: | 695 else: |
690 cflags = config.get('cflags', []) | 696 cflags = config.get('cflags', []) |
691 cflags_c = config.get('cflags_c', []) | 697 cflags_c = config.get('cflags_c', []) |
692 cflags_cc = config.get('cflags_cc', []) | 698 cflags_cc = config.get('cflags_cc', []) |
693 | 699 |
694 defines = config.get('defines', []) + extra_defines | 700 defines = config.get('defines', []) + extra_defines |
695 self.WriteVariableList('defines', [Define(d, self.flavor) for d in defines]) | 701 self.WriteVariableList('defines', [Define(d, self.flavor) for d in defines]) |
696 if self.flavor == 'win': | 702 if self.flavor == 'win': |
697 self.WriteVariableList('rcflags', | 703 self.WriteVariableList('rcflags', |
698 [QuoteShellArgument(self.ExpandSpecial(f), self.flavor) | 704 [QuoteShellArgument(self.ExpandSpecial(f), self.flavor) |
699 for f in self.msvs_settings.GetRcflags(config_name)]) | 705 for f in self.msvs_settings.GetRcflags(config_name)]) |
700 | 706 |
701 include_dirs = config.get('include_dirs', []) | 707 include_dirs = config.get('include_dirs', []) |
702 if self.flavor == 'win': | 708 if self.flavor == 'win': |
703 include_dirs = self.msvs_settings.AdjustIncludeDirs(include_dirs, | 709 include_dirs = self.msvs_settings.AdjustIncludeDirs(include_dirs, |
704 config_name) | 710 config_name) |
705 self.WriteVariableList('includes', | 711 self.WriteVariableList('includes', |
706 [QuoteShellArgument('-I' + self.GypPathToNinja(i), self.flavor) | 712 [QuoteShellArgument('-I' + self.GypPathToNinja(i), self.flavor) |
707 for i in include_dirs]) | 713 for i in include_dirs]) |
708 | 714 |
709 pch_commands = precompiled_header.GetGchBuildCommands() | 715 pch_commands = precompiled_header.GetPchBuildCommands() |
710 if self.flavor == 'mac': | 716 if self.flavor == 'mac': |
711 self.WriteVariableList('cflags_pch_c', | 717 self.WriteVariableList('cflags_pch_c', |
712 [precompiled_header.GetInclude('c')]) | 718 [precompiled_header.GetInclude('c')]) |
713 self.WriteVariableList('cflags_pch_cc', | 719 self.WriteVariableList('cflags_pch_cc', |
714 [precompiled_header.GetInclude('cc')]) | 720 [precompiled_header.GetInclude('cc')]) |
715 self.WriteVariableList('cflags_pch_objc', | 721 self.WriteVariableList('cflags_pch_objc', |
716 [precompiled_header.GetInclude('m')]) | 722 [precompiled_header.GetInclude('m')]) |
717 self.WriteVariableList('cflags_pch_objcc', | 723 self.WriteVariableList('cflags_pch_objcc', |
718 [precompiled_header.GetInclude('mm')]) | 724 [precompiled_header.GetInclude('mm')]) |
719 | 725 |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
768 return | 774 return |
769 | 775 |
770 for gch, lang_flag, lang, input in pch_commands: | 776 for gch, lang_flag, lang, input in pch_commands: |
771 var_name = { | 777 var_name = { |
772 'c': 'cflags_pch_c', | 778 'c': 'cflags_pch_c', |
773 'cc': 'cflags_pch_cc', | 779 'cc': 'cflags_pch_cc', |
774 'm': 'cflags_pch_objc', | 780 'm': 'cflags_pch_objc', |
775 'mm': 'cflags_pch_objcc', | 781 'mm': 'cflags_pch_objcc', |
776 }[lang] | 782 }[lang] |
777 | 783 |
778 cmd = { 'c': 'cc', 'cc': 'cxx', 'm': 'objc', 'mm': 'objcxx', }.get(lang) | 784 map = { 'c': 'cc', 'cc': 'cxx', 'm': 'objc', 'mm': 'objcxx', } |
| 785 if self.flavor == 'win': |
| 786 map.update({'c': 'cc_pch', 'cc': 'cxx_pch'}) |
| 787 cmd = map.get(lang) |
779 self.ninja.build(gch, cmd, input, variables=[(var_name, lang_flag)]) | 788 self.ninja.build(gch, cmd, input, variables=[(var_name, lang_flag)]) |
780 | 789 |
781 | |
782 def WriteLink(self, spec, config_name, config, link_deps): | 790 def WriteLink(self, spec, config_name, config, link_deps): |
783 """Write out a link step. Fills out target.binary. """ | 791 """Write out a link step. Fills out target.binary. """ |
784 | 792 |
785 command = { | 793 command = { |
786 'executable': 'link', | 794 'executable': 'link', |
787 'loadable_module': 'solink_module', | 795 'loadable_module': 'solink_module', |
788 'shared_library': 'solink', | 796 'shared_library': 'solink', |
789 }[spec['type']] | 797 }[spec['type']] |
790 | 798 |
791 implicit_deps = set() | 799 implicit_deps = set() |
(...skipping 495 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1287 depfile='$out.d') | 1295 depfile='$out.d') |
1288 master_ninja.rule( | 1296 master_ninja.rule( |
1289 'cxx', | 1297 'cxx', |
1290 description='CXX $out', | 1298 description='CXX $out', |
1291 command=('$cxx -MMD -MF $out.d $defines $includes $cflags $cflags_cc ' | 1299 command=('$cxx -MMD -MF $out.d $defines $includes $cflags $cflags_cc ' |
1292 '$cflags_pch_cc -c $in -o $out'), | 1300 '$cflags_pch_cc -c $in -o $out'), |
1293 depfile='$out.d') | 1301 depfile='$out.d') |
1294 else: | 1302 else: |
1295 # TODO(scottmg): Requires fork of ninja for dependency and linking | 1303 # TODO(scottmg): Requires fork of ninja for dependency and linking |
1296 # support: https://github.com/sgraham/ninja | 1304 # support: https://github.com/sgraham/ninja |
| 1305 # Template for compile commands mostly shared between compiling files |
| 1306 # and generating PCH. In the case of PCH, the "output" is specified by /Fp |
| 1307 # rather than /Fo (for object files), but we still need to specify an /Fo |
| 1308 # when compiling PCH. |
| 1309 cc_template = ('cmd /s /c "$cc /nologo /showIncludes ' |
| 1310 '@$out.rsp ' |
| 1311 '$cflags_pch_c /c $in %(outspec)s /Fd$pdbname ' |
| 1312 '| ninja-deplist-helper -r . -q -f cl -o $out.dl"') |
| 1313 cxx_template = ('cmd /s /c "$cxx /nologo /showIncludes ' |
| 1314 '@$out.rsp ' |
| 1315 '$cflags_pch_cc /c $in %(outspec)s $pchobj /Fd$pdbname ' |
| 1316 '| ninja-deplist-helper -r . -q -f cl -o $out.dl"') |
1297 master_ninja.rule( | 1317 master_ninja.rule( |
1298 'cc', | 1318 'cc', |
1299 description='CC $out', | 1319 description='CC $out', |
1300 command=('cmd /s /c "$cc /nologo /showIncludes ' | 1320 command=cc_template % {'outspec': '/Fo$out'}, |
1301 '@$out.rsp ' | 1321 deplist='$out.dl', |
1302 '$cflags_pch_c /c $in /Fo$out /Fd$pdbname ' | 1322 rspfile='$out.rsp', |
1303 '| ninja-deplist-helper -r . -q -f cl -o $out.dl"'), | 1323 rspfile_content='$defines $includes $cflags $cflags_c') |
| 1324 master_ninja.rule( |
| 1325 'cc_pch', |
| 1326 description='CC PCH $out', |
| 1327 command=cc_template % {'outspec': '/Fp$out /Fo$out.obj'}, |
1304 deplist='$out.dl', | 1328 deplist='$out.dl', |
1305 rspfile='$out.rsp', | 1329 rspfile='$out.rsp', |
1306 rspfile_content='$defines $includes $cflags $cflags_c') | 1330 rspfile_content='$defines $includes $cflags $cflags_c') |
1307 master_ninja.rule( | 1331 master_ninja.rule( |
1308 'cxx', | 1332 'cxx', |
1309 description='CXX $out', | 1333 description='CXX $out', |
1310 command=('cmd /s /c "$cxx /nologo /showIncludes ' | 1334 command=cxx_template % {'outspec': '/Fo$out'}, |
1311 '@$out.rsp ' | 1335 deplist='$out.dl', |
1312 '$cflags_pch_cc /c $in /Fo$out /Fd$pdbname ' | 1336 rspfile='$out.rsp', |
1313 '| ninja-deplist-helper -r . -q -f cl -o $out.dl"'), | 1337 rspfile_content='$defines $includes $cflags $cflags_cc') |
| 1338 master_ninja.rule( |
| 1339 'cxx_pch', |
| 1340 description='CXX PCH $out', |
| 1341 command=cxx_template % {'outspec': '/Fp$out /Fo$out.obj'}, |
1314 deplist='$out.dl', | 1342 deplist='$out.dl', |
1315 rspfile='$out.rsp', | 1343 rspfile='$out.rsp', |
1316 rspfile_content='$defines $includes $cflags $cflags_cc') | 1344 rspfile_content='$defines $includes $cflags $cflags_cc') |
1317 master_ninja.rule( | 1345 master_ninja.rule( |
1318 'idl', | 1346 'idl', |
1319 description='IDL $in', | 1347 description='IDL $in', |
1320 command=('python gyp-win-tool midl-wrapper $outdir ' | 1348 command=('python gyp-win-tool midl-wrapper $outdir ' |
1321 '$tlb $h $dlldata $iid $proxy $in ' | 1349 '$tlb $h $dlldata $iid $proxy $in ' |
1322 '$idlflags')) | 1350 '$idlflags')) |
1323 master_ninja.rule( | 1351 master_ninja.rule( |
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1500 | 1528 |
1501 user_config = params.get('generator_flags', {}).get('config', None) | 1529 user_config = params.get('generator_flags', {}).get('config', None) |
1502 if user_config: | 1530 if user_config: |
1503 GenerateOutputForConfig(target_list, target_dicts, data, params, | 1531 GenerateOutputForConfig(target_list, target_dicts, data, params, |
1504 user_config) | 1532 user_config) |
1505 else: | 1533 else: |
1506 config_names = target_dicts[target_list[0]]['configurations'].keys() | 1534 config_names = target_dicts[target_list[0]]['configurations'].keys() |
1507 for config_name in config_names: | 1535 for config_name in config_names: |
1508 GenerateOutputForConfig(target_list, target_dicts, data, params, | 1536 GenerateOutputForConfig(target_list, target_dicts, data, params, |
1509 config_name) | 1537 config_name) |
OLD | NEW |