| OLD | NEW |
| 1 # Copyright (c) 2013 Google Inc. All rights reserved. | 1 # Copyright (c) 2013 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 hashlib | 6 import hashlib |
| 7 import json | 7 import json |
| 8 import multiprocessing | 8 import multiprocessing |
| 9 import os.path | 9 import os.path |
| 10 import re | 10 import re |
| (...skipping 1019 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1030 is_executable = spec['type'] == 'executable' | 1030 is_executable = spec['type'] == 'executable' |
| 1031 # The ldflags config key is not used on mac or win. On those platforms | 1031 # The ldflags config key is not used on mac or win. On those platforms |
| 1032 # linker flags are set via xcode_settings and msvs_settings, respectively. | 1032 # linker flags are set via xcode_settings and msvs_settings, respectively. |
| 1033 env_ldflags = os.environ.get('LDFLAGS', '').split() | 1033 env_ldflags = os.environ.get('LDFLAGS', '').split() |
| 1034 if self.flavor == 'mac': | 1034 if self.flavor == 'mac': |
| 1035 ldflags = self.xcode_settings.GetLdflags(config_name, | 1035 ldflags = self.xcode_settings.GetLdflags(config_name, |
| 1036 self.ExpandSpecial(generator_default_variables['PRODUCT_DIR']), | 1036 self.ExpandSpecial(generator_default_variables['PRODUCT_DIR']), |
| 1037 self.GypPathToNinja, arch) | 1037 self.GypPathToNinja, arch) |
| 1038 ldflags = env_ldflags + ldflags | 1038 ldflags = env_ldflags + ldflags |
| 1039 elif self.flavor == 'win': | 1039 elif self.flavor == 'win': |
| 1040 manifest_name = self.GypPathToUniqueOutput( | 1040 manifest_base_name = self.GypPathToUniqueOutput( |
| 1041 self.ComputeOutputFileName(spec)) | 1041 self.ComputeOutputFileName(spec)) |
| 1042 ldflags, intermediate_manifest, manifest_files = \ | 1042 ldflags, intermediate_manifest, manifest_files = \ |
| 1043 self.msvs_settings.GetLdflags(config_name, self.GypPathToNinja, | 1043 self.msvs_settings.GetLdflags(config_name, self.GypPathToNinja, |
| 1044 self.ExpandSpecial, manifest_name, | 1044 self.ExpandSpecial, manifest_base_name, |
| 1045 is_executable, self.toplevel_build) | 1045 output, is_executable, |
| 1046 self.toplevel_build) |
| 1046 ldflags = env_ldflags + ldflags | 1047 ldflags = env_ldflags + ldflags |
| 1047 self.WriteVariableList(ninja_file, 'manifests', manifest_files) | 1048 self.WriteVariableList(ninja_file, 'manifests', manifest_files) |
| 1048 implicit_deps = implicit_deps.union(manifest_files) | 1049 implicit_deps = implicit_deps.union(manifest_files) |
| 1049 if intermediate_manifest: | 1050 if intermediate_manifest: |
| 1050 self.WriteVariableList( | 1051 self.WriteVariableList( |
| 1051 ninja_file, 'intermediatemanifest', [intermediate_manifest]) | 1052 ninja_file, 'intermediatemanifest', [intermediate_manifest]) |
| 1052 command_suffix = _GetWinLinkRuleNameSuffix( | 1053 command_suffix = _GetWinLinkRuleNameSuffix( |
| 1053 self.msvs_settings.IsEmbedManifest(config_name)) | 1054 self.msvs_settings.IsEmbedManifest(config_name)) |
| 1054 def_file = self.msvs_settings.GetDefFile(self.GypPathToNinja) | 1055 def_file = self.msvs_settings.GetDefFile(self.GypPathToNinja) |
| 1055 if def_file: | 1056 if def_file: |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1088 | 1089 |
| 1089 self.WriteVariableList(ninja_file, 'libs', library_dirs + libraries) | 1090 self.WriteVariableList(ninja_file, 'libs', library_dirs + libraries) |
| 1090 | 1091 |
| 1091 linked_binary = output | 1092 linked_binary = output |
| 1092 | 1093 |
| 1093 if command in ('solink', 'solink_module'): | 1094 if command in ('solink', 'solink_module'): |
| 1094 extra_bindings.append(('soname', os.path.split(output)[1])) | 1095 extra_bindings.append(('soname', os.path.split(output)[1])) |
| 1095 extra_bindings.append(('lib', | 1096 extra_bindings.append(('lib', |
| 1096 gyp.common.EncodePOSIXShellArgument(output))) | 1097 gyp.common.EncodePOSIXShellArgument(output))) |
| 1097 if self.flavor == 'win': | 1098 if self.flavor == 'win': |
| 1098 extra_bindings.append(('dll', output)) | 1099 extra_bindings.append(('binary', output)) |
| 1099 if '/NOENTRY' not in ldflags: | 1100 if '/NOENTRY' not in ldflags: |
| 1100 self.target.import_lib = output + '.lib' | 1101 self.target.import_lib = output + '.lib' |
| 1101 extra_bindings.append(('implibflag', | 1102 extra_bindings.append(('implibflag', |
| 1102 '/IMPLIB:%s' % self.target.import_lib)) | 1103 '/IMPLIB:%s' % self.target.import_lib)) |
| 1104 pdbname = self.msvs_settings.GetPDBName( |
| 1105 config_name, self.ExpandSpecial, output + '.pdb') |
| 1103 output = [output, self.target.import_lib] | 1106 output = [output, self.target.import_lib] |
| 1107 if pdbname: |
| 1108 output.append(pdbname) |
| 1104 elif not self.is_mac_bundle: | 1109 elif not self.is_mac_bundle: |
| 1105 output = [output, output + '.TOC'] | 1110 output = [output, output + '.TOC'] |
| 1106 else: | 1111 else: |
| 1107 command = command + '_notoc' | 1112 command = command + '_notoc' |
| 1113 elif self.flavor == 'win': |
| 1114 extra_bindings.append(('binary', output)) |
| 1115 pdbname = self.msvs_settings.GetPDBName( |
| 1116 config_name, self.ExpandSpecial, output + '.pdb') |
| 1117 if pdbname: |
| 1118 output = [output, pdbname] |
| 1119 |
| 1108 | 1120 |
| 1109 if len(solibs): | 1121 if len(solibs): |
| 1110 extra_bindings.append(('solibs', gyp.common.EncodePOSIXShellList(solibs))) | 1122 extra_bindings.append(('solibs', gyp.common.EncodePOSIXShellList(solibs))) |
| 1111 | 1123 |
| 1112 ninja_file.build(output, command + command_suffix, link_deps, | 1124 ninja_file.build(output, command + command_suffix, link_deps, |
| 1113 implicit=list(implicit_deps), | 1125 implicit=list(implicit_deps), |
| 1114 variables=extra_bindings) | 1126 variables=extra_bindings) |
| 1115 return linked_binary | 1127 return linked_binary |
| 1116 | 1128 |
| 1117 def WriteTarget(self, spec, config_name, config, link_deps, compile_deps): | 1129 def WriteTarget(self, spec, config_name, config, link_deps, compile_deps): |
| (...skipping 466 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1584 }[binary_type] | 1596 }[binary_type] |
| 1585 return '%(python)s gyp-win-tool link-with-manifests $arch %(embed)s ' \ | 1597 return '%(python)s gyp-win-tool link-with-manifests $arch %(embed)s ' \ |
| 1586 '%(out)s "%(ldcmd)s" %(resname)s $mt $rc "$intermediatemanifest" ' \ | 1598 '%(out)s "%(ldcmd)s" %(resname)s $mt $rc "$intermediatemanifest" ' \ |
| 1587 '$manifests' % { | 1599 '$manifests' % { |
| 1588 'python': sys.executable, | 1600 'python': sys.executable, |
| 1589 'out': out, | 1601 'out': out, |
| 1590 'ldcmd': ldcmd, | 1602 'ldcmd': ldcmd, |
| 1591 'resname': resource_name, | 1603 'resname': resource_name, |
| 1592 'embed': embed_manifest } | 1604 'embed': embed_manifest } |
| 1593 rule_name_suffix = _GetWinLinkRuleNameSuffix(embed_manifest) | 1605 rule_name_suffix = _GetWinLinkRuleNameSuffix(embed_manifest) |
| 1594 dlldesc = 'LINK%s(DLL) $dll' % rule_name_suffix.upper() | 1606 dlldesc = 'LINK%s(DLL) $binary' % rule_name_suffix.upper() |
| 1595 dllcmd = ('%s gyp-win-tool link-wrapper $arch ' | 1607 dllcmd = ('%s gyp-win-tool link-wrapper $arch ' |
| 1596 '$ld /nologo $implibflag /DLL /OUT:$dll ' | 1608 '$ld /nologo $implibflag /DLL /OUT:$binary ' |
| 1597 '/PDB:$dll.pdb @$dll.rsp' % sys.executable) | 1609 '@$binary.rsp' % sys.executable) |
| 1598 dllcmd = FullLinkCommand(dllcmd, '$dll', 'dll') | 1610 dllcmd = FullLinkCommand(dllcmd, '$binary', 'dll') |
| 1599 master_ninja.rule('solink' + rule_name_suffix, | 1611 master_ninja.rule('solink' + rule_name_suffix, |
| 1600 description=dlldesc, command=dllcmd, | 1612 description=dlldesc, command=dllcmd, |
| 1601 rspfile='$dll.rsp', | 1613 rspfile='$binary.rsp', |
| 1602 rspfile_content='$libs $in_newline $ldflags', | 1614 rspfile_content='$libs $in_newline $ldflags', |
| 1603 restat=True, | 1615 restat=True, |
| 1604 pool='link_pool') | 1616 pool='link_pool') |
| 1605 master_ninja.rule('solink_module' + rule_name_suffix, | 1617 master_ninja.rule('solink_module' + rule_name_suffix, |
| 1606 description=dlldesc, command=dllcmd, | 1618 description=dlldesc, command=dllcmd, |
| 1607 rspfile='$dll.rsp', | 1619 rspfile='$binary.rsp', |
| 1608 rspfile_content='$libs $in_newline $ldflags', | 1620 rspfile_content='$libs $in_newline $ldflags', |
| 1609 restat=True, | 1621 restat=True, |
| 1610 pool='link_pool') | 1622 pool='link_pool') |
| 1611 # Note that ldflags goes at the end so that it has the option of | 1623 # Note that ldflags goes at the end so that it has the option of |
| 1612 # overriding default settings earlier in the command line. | 1624 # overriding default settings earlier in the command line. |
| 1613 exe_cmd = ('%s gyp-win-tool link-wrapper $arch ' | 1625 exe_cmd = ('%s gyp-win-tool link-wrapper $arch ' |
| 1614 '$ld /nologo /OUT:$out /PDB:$out.pdb @$out.rsp' % | 1626 '$ld /nologo /OUT:$binary @$binary.rsp' % |
| 1615 sys.executable) | 1627 sys.executable) |
| 1616 exe_cmd = FullLinkCommand(exe_cmd, '$out', 'exe') | 1628 exe_cmd = FullLinkCommand(exe_cmd, '$binary', 'exe') |
| 1617 master_ninja.rule('link' + rule_name_suffix, | 1629 master_ninja.rule('link' + rule_name_suffix, |
| 1618 description='LINK%s $out' % rule_name_suffix.upper(), | 1630 description='LINK%s $binary' % rule_name_suffix.upper(), |
| 1619 command=exe_cmd, | 1631 command=exe_cmd, |
| 1620 rspfile='$out.rsp', | 1632 rspfile='$binary.rsp', |
| 1621 rspfile_content='$in_newline $libs $ldflags', | 1633 rspfile_content='$in_newline $libs $ldflags', |
| 1622 pool='link_pool') | 1634 pool='link_pool') |
| 1623 | 1635 |
| 1624 | 1636 |
| 1625 def GenerateOutputForConfig(target_list, target_dicts, data, params, | 1637 def GenerateOutputForConfig(target_list, target_dicts, data, params, |
| 1626 config_name): | 1638 config_name): |
| 1627 options = params['options'] | 1639 options = params['options'] |
| 1628 flavor = gyp.common.GetFlavor(params) | 1640 flavor = gyp.common.GetFlavor(params) |
| 1629 generator_flags = params.get('generator_flags', {}) | 1641 generator_flags = params.get('generator_flags', {}) |
| 1630 | 1642 |
| (...skipping 493 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2124 arglists.append( | 2136 arglists.append( |
| 2125 (target_list, target_dicts, data, params, config_name)) | 2137 (target_list, target_dicts, data, params, config_name)) |
| 2126 pool.map(CallGenerateOutputForConfig, arglists) | 2138 pool.map(CallGenerateOutputForConfig, arglists) |
| 2127 except KeyboardInterrupt, e: | 2139 except KeyboardInterrupt, e: |
| 2128 pool.terminate() | 2140 pool.terminate() |
| 2129 raise e | 2141 raise e |
| 2130 else: | 2142 else: |
| 2131 for config_name in config_names: | 2143 for config_name in config_names: |
| 2132 GenerateOutputForConfig(target_list, target_dicts, data, params, | 2144 GenerateOutputForConfig(target_list, target_dicts, data, params, |
| 2133 config_name) | 2145 config_name) |
| OLD | NEW |