Chromium Code Reviews| 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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 755 self.WritePchTargets(pch_commands) | 761 self.WritePchTargets(pch_commands) |
| 756 | 762 |
| 757 self.ninja.newline() | 763 self.ninja.newline() |
| 758 return outputs | 764 return outputs |
| 759 | 765 |
| 760 def WritePchTargets(self, pch_commands): | 766 def WritePchTargets(self, pch_commands): |
| 761 """Writes ninja rules to compile prefix headers.""" | 767 """Writes ninja rules to compile prefix headers.""" |
| 762 if not pch_commands: | 768 if not pch_commands: |
| 763 return | 769 return |
| 764 | 770 |
| 765 for gch, lang_flag, lang, input in pch_commands: | 771 for gch, lang_flag, lang, input, extra_variables 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 cmd = { 'c': 'cc', 'cc': 'cxx', 'm': 'objc', 'mm': 'objcxx', }.get(lang) |
| 774 self.ninja.build(gch, cmd, input, variables=[(var_name, lang_flag)]) | 780 variables = [(var_name, lang_flag)] |
| 775 | 781 variables += extra_variables |
|
Nico
2012/05/25 22:35:39
maybe:
variables = [(var_name, lang_flag)] + extra
scottmg
2012/05/26 02:27:12
Done.
| |
| 782 self.ninja.build(gch, cmd, input, variables=variables) | |
| 776 | 783 |
| 777 def WriteLink(self, spec, config_name, config, link_deps): | 784 def WriteLink(self, spec, config_name, config, link_deps): |
| 778 """Write out a link step. Fills out target.binary. """ | 785 """Write out a link step. Fills out target.binary. """ |
| 779 | 786 |
| 780 command = { | 787 command = { |
| 781 'executable': 'link', | 788 'executable': 'link', |
| 782 'loadable_module': 'solink_module', | 789 'loadable_module': 'solink_module', |
| 783 'shared_library': 'solink', | 790 'shared_library': 'solink', |
| 784 }[spec['type']] | 791 }[spec['type']] |
| 785 | 792 |
| (...skipping 496 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1282 depfile='$out.d') | 1289 depfile='$out.d') |
| 1283 master_ninja.rule( | 1290 master_ninja.rule( |
| 1284 'cxx', | 1291 'cxx', |
| 1285 description='CXX $out', | 1292 description='CXX $out', |
| 1286 command=('$cxx -MMD -MF $out.d $defines $includes $cflags $cflags_cc ' | 1293 command=('$cxx -MMD -MF $out.d $defines $includes $cflags $cflags_cc ' |
| 1287 '$cflags_pch_cc -c $in -o $out'), | 1294 '$cflags_pch_cc -c $in -o $out'), |
| 1288 depfile='$out.d') | 1295 depfile='$out.d') |
| 1289 else: | 1296 else: |
| 1290 # TODO(scottmg): Requires fork of ninja for dependency and linking | 1297 # TODO(scottmg): Requires fork of ninja for dependency and linking |
| 1291 # support: https://github.com/sgraham/ninja | 1298 # support: https://github.com/sgraham/ninja |
| 1299 # | |
| 1300 # Normally, we want to name the object file when we run compile step. This | |
| 1301 # is done with /Fo. However, when compiling a precompiled header, the | |
| 1302 # flag is /Fp, so override that in the pch compile step. | |
| 1303 master_ninja.variable('outflag', '/Fo') | |
| 1292 master_ninja.rule( | 1304 master_ninja.rule( |
| 1293 'cc', | 1305 'cc', |
| 1294 description='CC $out', | 1306 description='CC $out', |
| 1295 command=('cmd /s /c "$cc /nologo /showIncludes ' | 1307 command=('cmd /s /c "$cc /nologo /showIncludes ' |
| 1296 '@$out.rsp ' | 1308 '@$out.rsp ' |
| 1297 '$cflags_pch_c /c $in /Fo$out /Fd$pdbname ' | 1309 '$cflags_pch_c /c $in $outflag$out $pchobj /Fd$pdbname ' |
| 1298 '| ninja-deplist-helper -r . -q -f cl -o $out.dl"'), | 1310 '| ninja-deplist-helper -r . -q -f cl -o $out.dl"'), |
| 1299 deplist='$out.dl', | 1311 deplist='$out.dl', |
| 1300 rspfile='$out.rsp', | 1312 rspfile='$out.rsp', |
| 1301 rspfile_content='$defines $includes $cflags $cflags_c') | 1313 rspfile_content='$defines $includes $cflags $cflags_c') |
| 1302 master_ninja.rule( | 1314 master_ninja.rule( |
| 1303 'cxx', | 1315 'cxx', |
| 1304 description='CXX $out', | 1316 description='CXX $out', |
| 1305 command=('cmd /s /c "$cxx /nologo /showIncludes ' | 1317 command=('cmd /s /c "$cxx /nologo /showIncludes ' |
| 1306 '@$out.rsp ' | 1318 '@$out.rsp ' |
| 1307 '$cflags_pch_cc /c $in /Fo$out /Fd$pdbname ' | 1319 '$cflags_pch_cc /c $in $outflag$out $pchobj /Fd$pdbname ' |
| 1308 '| ninja-deplist-helper -r . -q -f cl -o $out.dl"'), | 1320 '| ninja-deplist-helper -r . -q -f cl -o $out.dl"'), |
| 1309 deplist='$out.dl', | 1321 deplist='$out.dl', |
| 1310 rspfile='$out.rsp', | 1322 rspfile='$out.rsp', |
| 1311 rspfile_content='$defines $includes $cflags $cflags_cc') | 1323 rspfile_content='$defines $includes $cflags $cflags_cc') |
| 1312 master_ninja.rule( | 1324 master_ninja.rule( |
| 1313 'idl', | 1325 'idl', |
| 1314 description='IDL $in', | 1326 description='IDL $in', |
| 1315 command=('python gyp-win-tool midl-wrapper $outdir ' | 1327 command=('python gyp-win-tool midl-wrapper $outdir ' |
| 1316 '$tlb $h $dlldata $iid $proxy $in ' | 1328 '$tlb $h $dlldata $iid $proxy $in ' |
| 1317 '$idlflags')) | 1329 '$idlflags')) |
| (...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1495 | 1507 |
| 1496 user_config = params.get('generator_flags', {}).get('config', None) | 1508 user_config = params.get('generator_flags', {}).get('config', None) |
| 1497 if user_config: | 1509 if user_config: |
| 1498 GenerateOutputForConfig(target_list, target_dicts, data, params, | 1510 GenerateOutputForConfig(target_list, target_dicts, data, params, |
| 1499 user_config) | 1511 user_config) |
| 1500 else: | 1512 else: |
| 1501 config_names = target_dicts[target_list[0]]['configurations'].keys() | 1513 config_names = target_dicts[target_list[0]]['configurations'].keys() |
| 1502 for config_name in config_names: | 1514 for config_name in config_names: |
| 1503 GenerateOutputForConfig(target_list, target_dicts, data, params, | 1515 GenerateOutputForConfig(target_list, target_dicts, data, params, |
| 1504 config_name) | 1516 config_name) |
| OLD | NEW |