| 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 hashlib | 6 import hashlib |
| 7 import os.path | 7 import os.path |
| 8 import re | 8 import re |
| 9 import subprocess | 9 import subprocess |
| 10 import sys | 10 import sys |
| (...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 359 | 359 |
| 360 Returns a Target object, which represents the output paths for this spec. | 360 Returns a Target object, which represents the output paths for this spec. |
| 361 Returns None if there are no outputs (e.g. a settings-only 'none' type | 361 Returns None if there are no outputs (e.g. a settings-only 'none' type |
| 362 target).""" | 362 target).""" |
| 363 | 363 |
| 364 self.config_name = config_name | 364 self.config_name = config_name |
| 365 self.name = spec['target_name'] | 365 self.name = spec['target_name'] |
| 366 self.toolset = spec['toolset'] | 366 self.toolset = spec['toolset'] |
| 367 config = spec['configurations'][config_name] | 367 config = spec['configurations'][config_name] |
| 368 self.target = Target(spec['type']) | 368 self.target = Target(spec['type']) |
| 369 self.is_standalone_static_library = bool( |
| 370 spec.get('standalone_static_library', 0)) |
| 369 | 371 |
| 370 self.is_mac_bundle = gyp.xcode_emulation.IsMacBundle(self.flavor, spec) | 372 self.is_mac_bundle = gyp.xcode_emulation.IsMacBundle(self.flavor, spec) |
| 371 self.xcode_settings = self.msvs_settings = None | 373 self.xcode_settings = self.msvs_settings = None |
| 372 if self.flavor == 'mac': | 374 if self.flavor == 'mac': |
| 373 self.xcode_settings = gyp.xcode_emulation.XcodeSettings(spec) | 375 self.xcode_settings = gyp.xcode_emulation.XcodeSettings(spec) |
| 374 if self.flavor == 'win': | 376 if self.flavor == 'win': |
| 375 self.msvs_settings = gyp.msvs_emulation.MsvsSettings(spec, | 377 self.msvs_settings = gyp.msvs_emulation.MsvsSettings(spec, |
| 376 generator_flags) | 378 generator_flags) |
| 377 target_platform = self.msvs_settings.GetTargetPlatform(config_name) | 379 target_platform = self.msvs_settings.GetTargetPlatform(config_name) |
| 378 self.ninja.variable('arch', self.win_env[target_platform]) | 380 self.ninja.variable('arch', self.win_env[target_platform]) |
| (...skipping 566 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 945 elif spec['type'] == 'static_library': | 947 elif spec['type'] == 'static_library': |
| 946 self.target.binary = self.ComputeOutput(spec) | 948 self.target.binary = self.ComputeOutput(spec) |
| 947 variables = [] | 949 variables = [] |
| 948 postbuild = self.GetPostbuildCommand( | 950 postbuild = self.GetPostbuildCommand( |
| 949 spec, self.target.binary, self.target.binary) | 951 spec, self.target.binary, self.target.binary) |
| 950 if postbuild: | 952 if postbuild: |
| 951 variables.append(('postbuilds', postbuild)) | 953 variables.append(('postbuilds', postbuild)) |
| 952 if self.xcode_settings: | 954 if self.xcode_settings: |
| 953 variables.append(('libtool_flags', | 955 variables.append(('libtool_flags', |
| 954 self.xcode_settings.GetLibtoolflags(config_name))) | 956 self.xcode_settings.GetLibtoolflags(config_name))) |
| 955 self.ninja.build(self.target.binary, 'alink', link_deps, | 957 if (self.flavor not in ('mac', 'win') and not |
| 956 order_only=compile_deps, variables=variables) | 958 self.is_standalone_static_library): |
| 959 self.ninja.build(self.target.binary, 'alink_thin', link_deps, |
| 960 order_only=compile_deps, variables=variables) |
| 961 else: |
| 962 self.ninja.build(self.target.binary, 'alink', link_deps, |
| 963 order_only=compile_deps, variables=variables) |
| 957 else: | 964 else: |
| 958 self.WriteLink(spec, config_name, config, link_deps) | 965 self.WriteLink(spec, config_name, config, link_deps) |
| 959 return self.target.binary | 966 return self.target.binary |
| 960 | 967 |
| 961 def WriteMacBundle(self, spec, mac_bundle_depends): | 968 def WriteMacBundle(self, spec, mac_bundle_depends): |
| 962 assert self.is_mac_bundle | 969 assert self.is_mac_bundle |
| 963 package_framework = spec['type'] in ('shared_library', 'loadable_module') | 970 package_framework = spec['type'] in ('shared_library', 'loadable_module') |
| 964 output = self.ComputeMacBundleOutput() | 971 output = self.ComputeMacBundleOutput() |
| 965 postbuild = self.GetPostbuildCommand(spec, output, self.target.binary, | 972 postbuild = self.GetPostbuildCommand(spec, output, self.target.binary, |
| 966 is_command_start=not package_framework) | 973 is_command_start=not package_framework) |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1130 return self.ExpandSpecial(path) | 1137 return self.ExpandSpecial(path) |
| 1131 | 1138 |
| 1132 # Some products go into the output root, libraries go into shared library | 1139 # Some products go into the output root, libraries go into shared library |
| 1133 # dir, and everything else goes into the normal place. | 1140 # dir, and everything else goes into the normal place. |
| 1134 type_in_output_root = ['executable', 'loadable_module'] | 1141 type_in_output_root = ['executable', 'loadable_module'] |
| 1135 if self.flavor == 'mac' and self.toolset == 'target': | 1142 if self.flavor == 'mac' and self.toolset == 'target': |
| 1136 type_in_output_root += ['shared_library', 'static_library'] | 1143 type_in_output_root += ['shared_library', 'static_library'] |
| 1137 elif self.flavor == 'win' and self.toolset == 'target': | 1144 elif self.flavor == 'win' and self.toolset == 'target': |
| 1138 type_in_output_root += ['shared_library'] | 1145 type_in_output_root += ['shared_library'] |
| 1139 | 1146 |
| 1140 if type in type_in_output_root: | 1147 if type in type_in_output_root or self.is_standalone_static_library: |
| 1141 return filename | 1148 return filename |
| 1142 elif type == 'shared_library': | 1149 elif type == 'shared_library': |
| 1143 libdir = 'lib' | 1150 libdir = 'lib' |
| 1144 if self.toolset != 'target': | 1151 if self.toolset != 'target': |
| 1145 libdir = os.path.join('lib', '%s' % self.toolset) | 1152 libdir = os.path.join('lib', '%s' % self.toolset) |
| 1146 return os.path.join(libdir, filename) | 1153 return os.path.join(libdir, filename) |
| 1147 else: | 1154 else: |
| 1148 return self.GypPathToUniqueOutput(filename, qualified=False) | 1155 return self.GypPathToUniqueOutput(filename, qualified=False) |
| 1149 | 1156 |
| 1150 def WriteVariableList(self, var, values): | 1157 def WriteVariableList(self, var, values): |
| (...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1487 'asm', | 1494 'asm', |
| 1488 description='ASM $in', | 1495 description='ASM $in', |
| 1489 command=('%s gyp-win-tool asm-wrapper ' | 1496 command=('%s gyp-win-tool asm-wrapper ' |
| 1490 '$arch $asm $defines $includes /c /Fo $out $in' % | 1497 '$arch $asm $defines $includes /c /Fo $out $in' % |
| 1491 sys.executable)) | 1498 sys.executable)) |
| 1492 | 1499 |
| 1493 if flavor != 'mac' and flavor != 'win': | 1500 if flavor != 'mac' and flavor != 'win': |
| 1494 master_ninja.rule( | 1501 master_ninja.rule( |
| 1495 'alink', | 1502 'alink', |
| 1496 description='AR $out', | 1503 description='AR $out', |
| 1504 command='rm -f $out && $ar rcs $out $in') |
| 1505 master_ninja.rule( |
| 1506 'alink_thin', |
| 1507 description='AR $out', |
| 1497 command='rm -f $out && $ar rcsT $out $in') | 1508 command='rm -f $out && $ar rcsT $out $in') |
| 1498 | 1509 |
| 1499 # This allows targets that only need to depend on $lib's API to declare an | 1510 # This allows targets that only need to depend on $lib's API to declare an |
| 1500 # order-only dependency on $lib.TOC and avoid relinking such downstream | 1511 # order-only dependency on $lib.TOC and avoid relinking such downstream |
| 1501 # dependencies when $lib changes only in non-public ways. | 1512 # dependencies when $lib changes only in non-public ways. |
| 1502 # The resulting string leaves an uninterpolated %{suffix} which | 1513 # The resulting string leaves an uninterpolated %{suffix} which |
| 1503 # is used in the final substitution below. | 1514 # is used in the final substitution below. |
| 1504 mtime_preserving_solink_base = ( | 1515 mtime_preserving_solink_base = ( |
| 1505 'if [ ! -e $lib -o ! -e ${lib}.TOC ]; then ' | 1516 'if [ ! -e $lib -o ! -e ${lib}.TOC ]; then ' |
| 1506 '%(solink)s && %(extract_toc)s > ${lib}.TOC; else ' | 1517 '%(solink)s && %(extract_toc)s > ${lib}.TOC; else ' |
| (...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1739 def GenerateOutput(target_list, target_dicts, data, params): | 1750 def GenerateOutput(target_list, target_dicts, data, params): |
| 1740 user_config = params.get('generator_flags', {}).get('config', None) | 1751 user_config = params.get('generator_flags', {}).get('config', None) |
| 1741 if user_config: | 1752 if user_config: |
| 1742 GenerateOutputForConfig(target_list, target_dicts, data, params, | 1753 GenerateOutputForConfig(target_list, target_dicts, data, params, |
| 1743 user_config) | 1754 user_config) |
| 1744 else: | 1755 else: |
| 1745 config_names = target_dicts[target_list[0]]['configurations'].keys() | 1756 config_names = target_dicts[target_list[0]]['configurations'].keys() |
| 1746 for config_name in config_names: | 1757 for config_name in config_names: |
| 1747 GenerateOutputForConfig(target_list, target_dicts, data, params, | 1758 GenerateOutputForConfig(target_list, target_dicts, data, params, |
| 1748 config_name) | 1759 config_name) |
| OLD | NEW |