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