| 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 1563 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1574 if embed_manifest: | 1574 if embed_manifest: |
| 1575 suffix += '_embed' | 1575 suffix += '_embed' |
| 1576 if link_incremental: | 1576 if link_incremental: |
| 1577 suffix += '_inc' | 1577 suffix += '_inc' |
| 1578 return suffix | 1578 return suffix |
| 1579 | 1579 |
| 1580 | 1580 |
| 1581 def _AddWinLinkRules(master_ninja, embed_manifest, link_incremental): | 1581 def _AddWinLinkRules(master_ninja, embed_manifest, link_incremental): |
| 1582 """Adds link rules for Windows platform to |master_ninja|.""" | 1582 """Adds link rules for Windows platform to |master_ninja|.""" |
| 1583 def FullLinkCommand(ldcmd, out, binary_type): | 1583 def FullLinkCommand(ldcmd, out, binary_type): |
| 1584 cmd = ('cmd /c %(ldcmd)s' | 1584 """Returns a one-liner written for cmd.exe to handle multiphase linker |
| 1585 ' && %(python)s gyp-win-tool manifest-wrapper $arch' | 1585 operations including manifest file generation. The command will be |
| 1586 ' cmd /c if exist %(out)s.manifest del %(out)s.manifest' | 1586 structured as follows: |
| 1587 ' && %(python)s gyp-win-tool manifest-wrapper $arch' | 1587 cmd /c (linkcmd1 a b) && (linkcmd2 x y) && ... && |
| 1588 ' $mt -nologo -manifest $manifests') | 1588 if not "$manifests"=="" ((manifestcmd1 a b) && (manifestcmd2 x y) && ... ) |
| 1589 Note that $manifests becomes empty when no manifest file is generated.""" |
| 1590 link_commands = ['%(ldcmd)s', |
| 1591 'if exist %(out)s.manifest del %(out)s.manifest'] |
| 1592 mt_cmd = ('%(python)s gyp-win-tool manifest-wrapper' |
| 1593 ' $arch $mt -nologo -manifest $manifests') |
| 1589 if embed_manifest and not link_incremental: | 1594 if embed_manifest and not link_incremental: |
| 1590 # Embed manifest into a binary. If incremental linking is enabled, | 1595 # Embed manifest into a binary. If incremental linking is enabled, |
| 1591 # embedding is postponed to the re-linking stage (see below). | 1596 # embedding is postponed to the re-linking stage (see below). |
| 1592 cmd += ' -outputresource:%(out)s;%(resname)s' | 1597 mt_cmd += ' -outputresource:%(out)s;%(resname)s' |
| 1593 else: | 1598 else: |
| 1594 # Save manifest as an external file. | 1599 # Save manifest as an external file. |
| 1595 cmd += ' -out:%(out)s.manifest' | 1600 mt_cmd += ' -out:%(out)s.manifest' |
| 1601 manifest_commands = [mt_cmd] |
| 1596 if link_incremental: | 1602 if link_incremental: |
| 1597 # There is no point in generating separate rule for the case when | 1603 # There is no point in generating separate rule for the case when |
| 1598 # incremental linking is enabled, but manifest embedding is disabled. | 1604 # incremental linking is enabled, but manifest embedding is disabled. |
| 1599 # In that case the basic rule should be used (e.g. 'link'). | 1605 # In that case the basic rule should be used (e.g. 'link'). |
| 1600 # See also implementation of _GetWinLinkRuleNameSuffix(). | 1606 # See also implementation of _GetWinLinkRuleNameSuffix(). |
| 1601 assert embed_manifest | 1607 assert embed_manifest |
| 1602 # Make .rc file out of manifest, compile it to .res file and re-link. | 1608 # Make .rc file out of manifest, compile it to .res file and re-link. |
| 1603 cmd += (' && %(python)s gyp-win-tool manifest-to-rc $arch' | 1609 manifest_commands += [ |
| 1604 ' %(out)s.manifest %(out)s.manifest.rc %(resname)s' | 1610 ('%(python)s gyp-win-tool manifest-to-rc $arch %(out)s.manifest' |
| 1605 ' && %(python)s gyp-win-tool rc-wrapper $arch $rc' | 1611 ' %(out)s.manifest.rc %(resname)s'), |
| 1606 ' %(out)s.manifest.rc' | 1612 '%(python)s gyp-win-tool rc-wrapper $arch $rc %(out)s.manifest.rc', |
| 1607 ' && %(ldcmd)s %(out)s.manifest.res') | 1613 '%(ldcmd)s %(out)s.manifest.res'] |
| 1614 cmd = 'cmd /c %s && if not "$manifests"=="" (%s)' % ( |
| 1615 ' && '.join(['(%s)' % c for c in link_commands]), |
| 1616 ' && '.join(['(%s)' % c for c in manifest_commands])) |
| 1608 resource_name = { | 1617 resource_name = { |
| 1609 'exe': '1', | 1618 'exe': '1', |
| 1610 'dll': '2', | 1619 'dll': '2', |
| 1611 }[binary_type] | 1620 }[binary_type] |
| 1612 return cmd % {'python': sys.executable, | 1621 return cmd % {'python': sys.executable, |
| 1613 'out': out, | 1622 'out': out, |
| 1614 'ldcmd': ldcmd, | 1623 'ldcmd': ldcmd, |
| 1615 'resname': resource_name} | 1624 'resname': resource_name} |
| 1616 | 1625 |
| 1617 rule_name_suffix = _GetWinLinkRuleNameSuffix(embed_manifest, link_incremental) | 1626 rule_name_suffix = _GetWinLinkRuleNameSuffix(embed_manifest, link_incremental) |
| (...skipping 533 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2151 arglists.append( | 2160 arglists.append( |
| 2152 (target_list, target_dicts, data, params, config_name)) | 2161 (target_list, target_dicts, data, params, config_name)) |
| 2153 pool.map(CallGenerateOutputForConfig, arglists) | 2162 pool.map(CallGenerateOutputForConfig, arglists) |
| 2154 except KeyboardInterrupt, e: | 2163 except KeyboardInterrupt, e: |
| 2155 pool.terminate() | 2164 pool.terminate() |
| 2156 raise e | 2165 raise e |
| 2157 else: | 2166 else: |
| 2158 for config_name in config_names: | 2167 for config_name in config_names: |
| 2159 GenerateOutputForConfig(target_list, target_dicts, data, params, | 2168 GenerateOutputForConfig(target_list, target_dicts, data, params, |
| 2160 config_name) | 2169 config_name) |
| OLD | NEW |