mslink.py (scons-4.2.0) | : | mslink.py (SCons-4.3.0) | ||
---|---|---|---|---|
"""SCons.Tool.mslink | # MIT License | |||
# | ||||
Tool-specific initialization for the Microsoft linker. | # Copyright The SCons Foundation | |||
There normally shouldn't be any need to import this module directly. | ||||
It will usually be imported through the generic SCons.Tool.Tool() | ||||
selection method. | ||||
""" | ||||
# | # | |||
# Permission is hereby granted, free of charge, to any person obtaining | # Permission is hereby granted, free of charge, to any person obtaining | |||
# a copy of this software and associated documentation files (the | # a copy of this software and associated documentation files (the | |||
# "Software"), to deal in the Software without restriction, including | # "Software"), to deal in the Software without restriction, including | |||
# without limitation the rights to use, copy, modify, merge, publish, | # without limitation the rights to use, copy, modify, merge, publish, | |||
# distribute, sublicense, and/or sell copies of the Software, and to | # distribute, sublicense, and/or sell copies of the Software, and to | |||
# permit persons to whom the Software is furnished to do so, subject to | # permit persons to whom the Software is furnished to do so, subject to | |||
# the following conditions: | # the following conditions: | |||
# | # | |||
# The above copyright notice and this permission notice shall be included | # The above copyright notice and this permission notice shall be included | |||
# in all copies or substantial portions of the Software. | # in all copies or substantial portions of the Software. | |||
# | # | |||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY | |||
# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE | # KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE | |||
# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | # WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | |||
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE | # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE | |||
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION | # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION | |||
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION | # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION | |||
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | |||
# | ||||
"""SCons.Tool.mslink | ||||
Tool-specific initialization for the Microsoft linker. | ||||
There normally shouldn't be any need to import this module directly. | ||||
It will usually be imported through the generic SCons.Tool.Tool() | ||||
selection method. | ||||
""" | ||||
import os | import os | |||
import os.path | import os.path | |||
import SCons.Action | import SCons.Action | |||
import SCons.Defaults | import SCons.Defaults | |||
import SCons.Errors | import SCons.Errors | |||
import SCons.Platform.win32 | import SCons.Platform.win32 | |||
import SCons.Tool | import SCons.Tool | |||
import SCons.Tool.msvc | import SCons.Tool.msvc | |||
import SCons.Tool.msvs | import SCons.Tool.msvs | |||
import SCons.Util | import SCons.Util | |||
from .MSCommon import msvc_setup_env_once, msvc_exists | from .MSCommon import msvc_setup_env_once, msvc_exists | |||
from .MSCommon.common import get_pch_node | ||||
def pdbGenerator(env, target, source, for_signature): | def pdbGenerator(env, target, source, for_signature): | |||
try: | try: | |||
return ['/PDB:%s' % target[0].attributes.pdb, '/DEBUG'] | return ['/PDB:%s' % target[0].attributes.pdb, '/DEBUG'] | |||
except (AttributeError, IndexError): | except (AttributeError, IndexError): | |||
return None | return None | |||
def _dllTargets(target, source, env, for_signature, paramtp): | def _dllTargets(target, source, env, for_signature, paramtp): | |||
listCmd = [] | listCmd = [] | |||
dll = env.FindIxes(target, '%sPREFIX' % paramtp, '%sSUFFIX' % paramtp) | dll = env.FindIxes(target, '%sPREFIX' % paramtp, '%sSUFFIX' % paramtp) | |||
skipping to change at line 129 | skipping to change at line 132 | |||
extratargets.append( | extratargets.append( | |||
env.ReplaceIxes(dll, | env.ReplaceIxes(dll, | |||
'%sPREFIX' % paramtp, '%sSUFFIX' % paramtp, | '%sPREFIX' % paramtp, '%sSUFFIX' % paramtp, | |||
"WINDOWSSHLIBMANIFESTPREFIX", "WINDOWSSHLIBMANIFESTS UFFIX")) | "WINDOWSSHLIBMANIFESTPREFIX", "WINDOWSSHLIBMANIFESTS UFFIX")) | |||
if 'PDB' in env and env['PDB']: | if 'PDB' in env and env['PDB']: | |||
pdb = env.arg2nodes('$PDB', target=target, source=source)[0] | pdb = env.arg2nodes('$PDB', target=target, source=source)[0] | |||
extratargets.append(pdb) | extratargets.append(pdb) | |||
target[0].attributes.pdb = pdb | target[0].attributes.pdb = pdb | |||
if version_num >= 11.0 and env.get('PCH', 0): | pch_node = get_pch_node(env, target, source) | |||
if version_num >= 11.0 and pch_node: | ||||
# MSVC 11 and above need the PCH object file to be added to the link lin e, | # MSVC 11 and above need the PCH object file to be added to the link lin e, | |||
# otherwise you get link error LNK2011. | # otherwise you get link error LNK2011. | |||
pchobj = SCons.Util.splitext(str(env['PCH']))[0] + '.obj' | pchobj = SCons.Util.splitext(str(pch_node))[0] + '.obj' | |||
# print "prog_emitter, version %s, appending pchobj %s"%(version_num, pc hobj) | # print "prog_emitter, version %s, appending pchobj %s"%(version_num, pc hobj) | |||
if pchobj not in extrasources: | if pchobj not in extrasources: | |||
extrasources.append(pchobj) | extrasources.append(pchobj) | |||
if not no_import_lib and \ | if not no_import_lib and \ | |||
not env.FindIxes(target, "LIBPREFIX", "LIBSUFFIX"): | not env.FindIxes(target, "LIBPREFIX", "LIBSUFFIX"): | |||
# Append an import library to the list of targets. | # Append an import library to the list of targets. | |||
extratargets.append( | extratargets.append( | |||
env.ReplaceIxes(dll, | env.ReplaceIxes(dll, | |||
'%sPREFIX' % paramtp, '%sSUFFIX' % paramtp, | '%sPREFIX' % paramtp, '%sSUFFIX' % paramtp, | |||
skipping to change at line 187 | skipping to change at line 191 | |||
extratargets.append( | extratargets.append( | |||
env.ReplaceIxes(exe, | env.ReplaceIxes(exe, | |||
"PROGPREFIX", "PROGSUFFIX", | "PROGPREFIX", "PROGSUFFIX", | |||
"WINDOWSPROGMANIFESTPREFIX", "WINDOWSPROGMANIFESTSUF FIX")) | "WINDOWSPROGMANIFESTPREFIX", "WINDOWSPROGMANIFESTSUF FIX")) | |||
if 'PDB' in env and env['PDB']: | if 'PDB' in env and env['PDB']: | |||
pdb = env.arg2nodes('$PDB', target=target, source=source)[0] | pdb = env.arg2nodes('$PDB', target=target, source=source)[0] | |||
extratargets.append(pdb) | extratargets.append(pdb) | |||
target[0].attributes.pdb = pdb | target[0].attributes.pdb = pdb | |||
if version_num >= 11.0 and env.get('PCH', 0): | pch_node = get_pch_node(env, target, source) | |||
if version_num >= 11.0 and pch_node: | ||||
# MSVC 11 and above need the PCH object file to be added to the link lin e, | # MSVC 11 and above need the PCH object file to be added to the link lin e, | |||
# otherwise you get link error LNK2011. | # otherwise you get link error LNK2011. | |||
pchobj = SCons.Util.splitext(str(env['PCH']))[0] + '.obj' | pchobj = SCons.Util.splitext(str(pch_node))[0] + '.obj' | |||
# print("prog_emitter, version %s, appending pchobj %s"%(version_num, pc | # print "prog_emitter, version %s, appending pchobj %s"%(version_num, pc | |||
hobj)) | hobj) | |||
if pchobj not in extrasources: | if pchobj not in extrasources: | |||
extrasources.append(pchobj) | extrasources.append(pchobj) | |||
return (target+extratargets,source+extrasources) | return (target+extratargets,source+extrasources) | |||
def RegServerFunc(target, source, env): | def RegServerFunc(target, source, env): | |||
if 'register' in env and env['register']: | if 'register' in env and env['register']: | |||
ret = regServerAction([target[0]], [source[0]], env) | ret = regServerAction([target[0]], [source[0]], env) | |||
if ret: | if ret: | |||
raise SCons.Errors.UserError("Unable to register %s" % target[0]) | raise SCons.Errors.UserError("Unable to register %s" % target[0]) | |||
End of changes. 7 change blocks. | ||||
17 lines changed or deleted | 22 lines changed or added |