diff options
author | Gary Oberbrunner <garyo@oberbrunner.com> | 2009-01-06 23:04:47 +0000 |
---|---|---|
committer | Gary Oberbrunner <garyo@oberbrunner.com> | 2009-01-06 23:04:47 +0000 |
commit | 70bafd78f8a009a0d82d0cdbe7d09d86e937eef3 (patch) | |
tree | 4cd5c4b683e48b27e7a0af01b267528c94ebf594 /src/engine/SCons/Tool/mslink.py | |
parent | 5d789012dbac7678af6a2ef89aeb7ba635c43246 (diff) | |
download | scons-70bafd78f8a009a0d82d0cdbe7d09d86e937eef3.tar.gz |
Fix issue 2274 (LDMODULE* ignored except on Mac): integrated patch from Arve Knudsen.
Diffstat (limited to 'src/engine/SCons/Tool/mslink.py')
-rw-r--r-- | src/engine/SCons/Tool/mslink.py | 68 |
1 files changed, 48 insertions, 20 deletions
diff --git a/src/engine/SCons/Tool/mslink.py b/src/engine/SCons/Tool/mslink.py index 42eabafb..4268b58f 100644 --- a/src/engine/SCons/Tool/mslink.py +++ b/src/engine/SCons/Tool/mslink.py @@ -50,9 +50,9 @@ def pdbGenerator(env, target, source, for_signature): except (AttributeError, IndexError): return None -def windowsShlinkTargets(target, source, env, for_signature): +def _dllTargets(target, source, env, for_signature, paramtp): listCmd = [] - dll = env.FindIxes(target, 'SHLIBPREFIX', 'SHLIBSUFFIX') + dll = env.FindIxes(target, '%sPREFIX' % paramtp, '%sSUFFIX' % paramtp) if dll: listCmd.append("/out:%s"%dll.get_string(for_signature)) implib = env.FindIxes(target, 'LIBPREFIX', 'LIBSUFFIX') @@ -60,7 +60,7 @@ def windowsShlinkTargets(target, source, env, for_signature): return listCmd -def windowsShlinkSources(target, source, env, for_signature): +def _dllSources(target, source, env, for_signature, paramtp): listCmd = [] deffile = env.FindIxes(source, "WINDOWSDEFPREFIX", "WINDOWSDEFSUFFIX") @@ -73,17 +73,32 @@ def windowsShlinkSources(target, source, env, for_signature): listCmd.append(src) return listCmd -def windowsLibEmitter(target, source, env): +def windowsShlinkTargets(target, source, env, for_signature): + return _dllTargets(target, source, env, for_signature, 'SHLIB') + +def windowsShlinkSources(target, source, env, for_signature): + return _dllSources(target, source, env, for_signature, 'SHLIB') + +def _windowsLdmodTargets(target, source, env, for_signature): + """Get targets for loadable modules.""" + return _dllTargets(target, source, env, for_signature, 'LDMODULE') + +def _windowsLdmodSources(target, source, env, for_signature): + """Get sources for loadable modules.""" + return _dllSources(target, source, env, for_signature, 'LDMODULE') + +def _dllEmitter(target, source, env, paramtp): + """Common implementation of dll emitter.""" SCons.Tool.msvc.validate_vars(env) extratargets = [] extrasources = [] - dll = env.FindIxes(target, "SHLIBPREFIX", "SHLIBSUFFIX") + dll = env.FindIxes(target, '%sPREFIX' % paramtp, '%sSUFFIX' % paramtp) no_import_lib = env.get('no_import_lib', 0) if not dll: - raise SCons.Errors.UserError, "A shared library should have exactly one target with the suffix: %s" % env.subst("$SHLIBSUFFIX") + raise SCons.Errors.UserError, 'A shared library should have exactly one target with the suffix: %s' % env.subst('$%sSUFFIX' % paramtp) insert_def = env.subst("$WINDOWS_INSERT_DEF") if not insert_def in ['', '0', 0] and \ @@ -92,7 +107,7 @@ def windowsLibEmitter(target, source, env): # append a def file to the list of sources extrasources.append( env.ReplaceIxes(dll, - "SHLIBPREFIX", "SHLIBSUFFIX", + '%sPREFIX' % paramtp, '%sSUFFIX' % paramtp, "WINDOWSDEFPREFIX", "WINDOWSDEFSUFFIX")) version_num, suite = SCons.Tool.msvs.msvs_parse_version(env.get('MSVS_VERSION', '6.0')) @@ -100,7 +115,7 @@ def windowsLibEmitter(target, source, env): # MSVC 8 automatically generates .manifest files that must be installed extratargets.append( env.ReplaceIxes(dll, - "SHLIBPREFIX", "SHLIBSUFFIX", + '%sPREFIX' % paramtp, '%sSUFFIX' % paramtp, "WINDOWSSHLIBMANIFESTPREFIX", "WINDOWSSHLIBMANIFESTSUFFIX")) if env.has_key('PDB') and env['PDB']: @@ -113,16 +128,27 @@ def windowsLibEmitter(target, source, env): # Append an import library to the list of targets. extratargets.append( env.ReplaceIxes(dll, - "SHLIBPREFIX", "SHLIBSUFFIX", + '%sPREFIX' % paramtp, '%sSUFFIX' % paramtp, "LIBPREFIX", "LIBSUFFIX")) # and .exp file is created if there are exports from a DLL extratargets.append( env.ReplaceIxes(dll, - "SHLIBPREFIX", "SHLIBSUFFIX", + '%sPREFIX' % paramtp, '%sSUFFIX' % paramtp, "WINDOWSEXPPREFIX", "WINDOWSEXPSUFFIX")) return (target+extratargets, source+extrasources) +def windowsLibEmitter(target, source, env): + return _dllEmitter(target, source, env, 'SHLIB') + +def ldmodEmitter(target, source, env): + """Emitter for loadable modules. + + Loadable modules are identical to shared libraries on Windows, but building + them is subject to different parameters (LDMODULE*). + """ + return _dllEmitter(target, source, env, 'LDMODULE') + def prog_emitter(target, source, env): SCons.Tool.msvc.validate_vars(env) @@ -160,7 +186,9 @@ def RegServerFunc(target, source, env): regServerAction = SCons.Action.Action("$REGSVRCOM", "$REGSVRCOMSTR") regServerCheck = SCons.Action.Action(RegServerFunc, None) shlibLinkAction = SCons.Action.Action('${TEMPFILE("$SHLINK $SHLINKFLAGS $_SHLINK_TARGETS $( $_LIBDIRFLAGS $) $_LIBFLAGS $_PDB $_SHLINK_SOURCES")}') -compositeLinkAction = shlibLinkAction + regServerCheck +compositeShLinkAction = shlibLinkAction + regServerCheck +ldmodLinkAction = SCons.Action.Action('${TEMPFILE("$LDMODULE $LDMODULEFLAGS $_LDMODULE_TARGETS $( $_LIBDIRFLAGS $) $_LIBFLAGS $_PDB $_LDMODULE_SOURCES")}') +compositeLdmodAction = ldmodLinkAction + regServerCheck def generate(env): """Add Builders and construction variables for ar to an Environment.""" @@ -171,7 +199,7 @@ def generate(env): env['SHLINKFLAGS'] = SCons.Util.CLVar('$LINKFLAGS /dll') env['_SHLINK_TARGETS'] = windowsShlinkTargets env['_SHLINK_SOURCES'] = windowsShlinkSources - env['SHLINKCOM'] = compositeLinkAction + env['SHLINKCOM'] = compositeShLinkAction env.Append(SHLIBEMITTER = [windowsLibEmitter]) env['LINK'] = 'link' env['LINKFLAGS'] = SCons.Util.CLVar('/nologo') @@ -221,19 +249,19 @@ def generate(env): except (SCons.Util.RegError, SCons.Errors.InternalError): pass - # For most platforms, a loadable module is the same as a shared - # library. Platforms which are different can override these, but - # setting them the same means that LoadableModule works everywhere. + # Loadable modules are on Windows the same as shared libraries, but they + # are subject to different build parameters (LDMODULE* variables). + # Therefore LDMODULE* variables correspond as much as possible to + # SHLINK*/SHLIB* ones. SCons.Tool.createLoadableModuleBuilder(env) env['LDMODULE'] = '$SHLINK' env['LDMODULEPREFIX'] = '$SHLIBPREFIX' env['LDMODULESUFFIX'] = '$SHLIBSUFFIX' env['LDMODULEFLAGS'] = '$SHLINKFLAGS' - # We can't use '$SHLINKCOM' here because that will stringify the - # action list on expansion, and will then try to execute expanded - # strings, with the upshot that it would try to execute RegServerFunc - # as a command. - env['LDMODULECOM'] = compositeLinkAction + env['_LDMODULE_TARGETS'] = _windowsLdmodTargets + env['_LDMODULE_SOURCES'] = _windowsLdmodSources + env['LDMODULEEMITTER'] = [ldmodEmitter] + env['LDMODULECOM'] = compositeLdmodAction def exists(env): platform = env.get('PLATFORM', '') |