| 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 collections | 5 import collections |
| 6 import copy | 6 import copy |
| 7 import hashlib | 7 import hashlib |
| 8 import json | 8 import json |
| 9 import multiprocessing | 9 import multiprocessing |
| 10 import os.path | 10 import os.path |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 self.precompile_stamp = None | 132 self.precompile_stamp = None |
| 133 # File representing the completion of actions/rules/copies, if any. | 133 # File representing the completion of actions/rules/copies, if any. |
| 134 self.actions_stamp = None | 134 self.actions_stamp = None |
| 135 # Path to the output of the link step, if any. | 135 # Path to the output of the link step, if any. |
| 136 self.binary = None | 136 self.binary = None |
| 137 # Path to the file representing the completion of building the bundle, | 137 # Path to the file representing the completion of building the bundle, |
| 138 # if any. | 138 # if any. |
| 139 self.bundle = None | 139 self.bundle = None |
| 140 # On Windows, incremental linking requires linking against all the .objs | 140 # On Windows, incremental linking requires linking against all the .objs |
| 141 # that compose a .lib (rather than the .lib itself). That list is stored | 141 # that compose a .lib (rather than the .lib itself). That list is stored |
| 142 # here. | 142 # here. In this case, we also need to save the compile_deps for the target, |
| 143 # so that the the target that directly depends on the .objs can also depend |
| 144 # on those. |
| 143 self.component_objs = None | 145 self.component_objs = None |
| 146 self.compile_deps = None |
| 144 # Windows only. The import .lib is the output of a build step, but | 147 # Windows only. The import .lib is the output of a build step, but |
| 145 # because dependents only link against the lib (not both the lib and the | 148 # because dependents only link against the lib (not both the lib and the |
| 146 # dll) we keep track of the import library here. | 149 # dll) we keep track of the import library here. |
| 147 self.import_lib = None | 150 self.import_lib = None |
| 148 | 151 |
| 149 def Linkable(self): | 152 def Linkable(self): |
| 150 """Return true if this is a target that can be linked against.""" | 153 """Return true if this is a target that can be linked against.""" |
| 151 return self.type in ('static_library', 'shared_library') | 154 return self.type in ('static_library', 'shared_library') |
| 152 | 155 |
| 153 def UsesToc(self, flavor): | 156 def UsesToc(self, flavor): |
| (...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 467 obj_outputs = [f for f in sources if f.endswith(self.obj_ext)] | 470 obj_outputs = [f for f in sources if f.endswith(self.obj_ext)] |
| 468 if obj_outputs: | 471 if obj_outputs: |
| 469 if self.flavor != 'mac' or len(self.archs) == 1: | 472 if self.flavor != 'mac' or len(self.archs) == 1: |
| 470 link_deps += [self.GypPathToNinja(o) for o in obj_outputs] | 473 link_deps += [self.GypPathToNinja(o) for o in obj_outputs] |
| 471 else: | 474 else: |
| 472 print "Warning: Actions/rules writing object files don't work with " \ | 475 print "Warning: Actions/rules writing object files don't work with " \ |
| 473 "multiarch targets, dropping. (target %s)" % spec['target_name'] | 476 "multiarch targets, dropping. (target %s)" % spec['target_name'] |
| 474 elif self.flavor == 'mac' and len(self.archs) > 1: | 477 elif self.flavor == 'mac' and len(self.archs) > 1: |
| 475 link_deps = collections.defaultdict(list) | 478 link_deps = collections.defaultdict(list) |
| 476 | 479 |
| 477 | 480 compile_deps = self.target.actions_stamp or actions_depends |
| 478 if self.flavor == 'win' and self.target.type == 'static_library': | 481 if self.flavor == 'win' and self.target.type == 'static_library': |
| 479 self.target.component_objs = link_deps | 482 self.target.component_objs = link_deps |
| 483 self.target.compile_deps = compile_deps |
| 480 | 484 |
| 481 # Write out a link step, if needed. | 485 # Write out a link step, if needed. |
| 482 output = None | 486 output = None |
| 483 is_empty_bundle = not link_deps and not mac_bundle_depends | 487 is_empty_bundle = not link_deps and not mac_bundle_depends |
| 484 if link_deps or self.target.actions_stamp or actions_depends: | 488 if link_deps or self.target.actions_stamp or actions_depends: |
| 485 output = self.WriteTarget(spec, config_name, config, link_deps, | 489 output = self.WriteTarget(spec, config_name, config, link_deps, |
| 486 self.target.actions_stamp or actions_depends) | 490 compile_deps) |
| 487 if self.is_mac_bundle: | 491 if self.is_mac_bundle: |
| 488 mac_bundle_depends.append(output) | 492 mac_bundle_depends.append(output) |
| 489 | 493 |
| 490 # Bundle all of the above together, if needed. | 494 # Bundle all of the above together, if needed. |
| 491 if self.is_mac_bundle: | 495 if self.is_mac_bundle: |
| 492 output = self.WriteMacBundle(spec, mac_bundle_depends, is_empty_bundle) | 496 output = self.WriteMacBundle(spec, mac_bundle_depends, is_empty_bundle) |
| 493 | 497 |
| 494 if not output: | 498 if not output: |
| 495 return None | 499 return None |
| 496 | 500 |
| (...skipping 589 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1086 """Write out a link step. Fills out target.binary. """ | 1090 """Write out a link step. Fills out target.binary. """ |
| 1087 command = { | 1091 command = { |
| 1088 'executable': 'link', | 1092 'executable': 'link', |
| 1089 'loadable_module': 'solink_module', | 1093 'loadable_module': 'solink_module', |
| 1090 'shared_library': 'solink', | 1094 'shared_library': 'solink', |
| 1091 }[spec['type']] | 1095 }[spec['type']] |
| 1092 command_suffix = '' | 1096 command_suffix = '' |
| 1093 | 1097 |
| 1094 implicit_deps = set() | 1098 implicit_deps = set() |
| 1095 solibs = set() | 1099 solibs = set() |
| 1100 order_deps = set() |
| 1096 | 1101 |
| 1097 if 'dependencies' in spec: | 1102 if 'dependencies' in spec: |
| 1098 # Two kinds of dependencies: | 1103 # Two kinds of dependencies: |
| 1099 # - Linkable dependencies (like a .a or a .so): add them to the link line. | 1104 # - Linkable dependencies (like a .a or a .so): add them to the link line. |
| 1100 # - Non-linkable dependencies (like a rule that generates a file | 1105 # - Non-linkable dependencies (like a rule that generates a file |
| 1101 # and writes a stamp file): add them to implicit_deps | 1106 # and writes a stamp file): add them to implicit_deps |
| 1102 extra_link_deps = set() | 1107 extra_link_deps = set() |
| 1103 for dep in spec['dependencies']: | 1108 for dep in spec['dependencies']: |
| 1104 target = self.target_outputs.get(dep) | 1109 target = self.target_outputs.get(dep) |
| 1105 if not target: | 1110 if not target: |
| 1106 continue | 1111 continue |
| 1107 linkable = target.Linkable() | 1112 linkable = target.Linkable() |
| 1108 if linkable: | 1113 if linkable: |
| 1109 new_deps = [] | 1114 new_deps = [] |
| 1110 if (self.flavor == 'win' and | 1115 if (self.flavor == 'win' and |
| 1111 target.component_objs and | 1116 target.component_objs and |
| 1112 self.msvs_settings.IsUseLibraryDependencyInputs(config_name)): | 1117 self.msvs_settings.IsUseLibraryDependencyInputs(config_name)): |
| 1113 new_deps = target.component_objs | 1118 new_deps = target.component_objs |
| 1119 if target.compile_deps: |
| 1120 order_deps.add(target.compile_deps) |
| 1114 elif self.flavor == 'win' and target.import_lib: | 1121 elif self.flavor == 'win' and target.import_lib: |
| 1115 new_deps = [target.import_lib] | 1122 new_deps = [target.import_lib] |
| 1116 elif target.UsesToc(self.flavor): | 1123 elif target.UsesToc(self.flavor): |
| 1117 solibs.add(target.binary) | 1124 solibs.add(target.binary) |
| 1118 implicit_deps.add(target.binary + '.TOC') | 1125 implicit_deps.add(target.binary + '.TOC') |
| 1119 else: | 1126 else: |
| 1120 new_deps = [target.binary] | 1127 new_deps = [target.binary] |
| 1121 for new_dep in new_deps: | 1128 for new_dep in new_deps: |
| 1122 if new_dep not in extra_link_deps: | 1129 if new_dep not in extra_link_deps: |
| 1123 extra_link_deps.add(new_dep) | 1130 extra_link_deps.add(new_dep) |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1242 config_name, self.ExpandSpecial, output + '.pdb') | 1249 config_name, self.ExpandSpecial, output + '.pdb') |
| 1243 if pdbname: | 1250 if pdbname: |
| 1244 output = [output, pdbname] | 1251 output = [output, pdbname] |
| 1245 | 1252 |
| 1246 | 1253 |
| 1247 if len(solibs): | 1254 if len(solibs): |
| 1248 extra_bindings.append(('solibs', gyp.common.EncodePOSIXShellList(solibs))) | 1255 extra_bindings.append(('solibs', gyp.common.EncodePOSIXShellList(solibs))) |
| 1249 | 1256 |
| 1250 ninja_file.build(output, command + command_suffix, link_deps, | 1257 ninja_file.build(output, command + command_suffix, link_deps, |
| 1251 implicit=list(implicit_deps), | 1258 implicit=list(implicit_deps), |
| 1259 order_only=list(order_deps), |
| 1252 variables=extra_bindings) | 1260 variables=extra_bindings) |
| 1253 return linked_binary | 1261 return linked_binary |
| 1254 | 1262 |
| 1255 def WriteTarget(self, spec, config_name, config, link_deps, compile_deps): | 1263 def WriteTarget(self, spec, config_name, config, link_deps, compile_deps): |
| 1256 extra_link_deps = any(self.target_outputs.get(dep).Linkable() | 1264 extra_link_deps = any(self.target_outputs.get(dep).Linkable() |
| 1257 for dep in spec.get('dependencies', []) | 1265 for dep in spec.get('dependencies', []) |
| 1258 if dep in self.target_outputs) | 1266 if dep in self.target_outputs) |
| 1259 if spec['type'] == 'none' or (not link_deps and not extra_link_deps): | 1267 if spec['type'] == 'none' or (not link_deps and not extra_link_deps): |
| 1260 # TODO(evan): don't call this function for 'none' target types, as | 1268 # TODO(evan): don't call this function for 'none' target types, as |
| 1261 # it doesn't do anything, and we fake out a 'binary' with a stamp file. | 1269 # it doesn't do anything, and we fake out a 'binary' with a stamp file. |
| (...skipping 1131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2393 arglists.append( | 2401 arglists.append( |
| 2394 (target_list, target_dicts, data, params, config_name)) | 2402 (target_list, target_dicts, data, params, config_name)) |
| 2395 pool.map(CallGenerateOutputForConfig, arglists) | 2403 pool.map(CallGenerateOutputForConfig, arglists) |
| 2396 except KeyboardInterrupt, e: | 2404 except KeyboardInterrupt, e: |
| 2397 pool.terminate() | 2405 pool.terminate() |
| 2398 raise e | 2406 raise e |
| 2399 else: | 2407 else: |
| 2400 for config_name in config_names: | 2408 for config_name in config_names: |
| 2401 GenerateOutputForConfig(target_list, target_dicts, data, params, | 2409 GenerateOutputForConfig(target_list, target_dicts, data, params, |
| 2402 config_name) | 2410 config_name) |
| OLD | NEW |