summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--SCons/Tool/linkCommon/LoadableModule.py6
-rw-r--r--SCons/Tool/linkCommon/SharedLibrary.py122
2 files changed, 77 insertions, 51 deletions
diff --git a/SCons/Tool/linkCommon/LoadableModule.py b/SCons/Tool/linkCommon/LoadableModule.py
index 36921f6..6d893e6 100644
--- a/SCons/Tool/linkCommon/LoadableModule.py
+++ b/SCons/Tool/linkCommon/LoadableModule.py
@@ -46,7 +46,7 @@ def _ldmodule_soname(target, source, env, for_signature):
if 'SONAME' in env:
return '$SONAME'
else:
- return "$LDMODULEPREFIX$_get_ldmodule_stem$_LDMODULESOVERSION${LDMODULESUFFIX}"
+ return "$LDMODULEPREFIX$_get_ldmodule_stem${LDMODULESUFFIX}$_LDMODULESOVERSION"
def setup_loadable_module_logic(env):
@@ -71,11 +71,11 @@ def setup_loadable_module_logic(env):
# This is the non versioned LDMODULE filename
# If LDMODULEVERSION is defined then this will symlink to $LDMODULENAME
- env['LDMODULE_NOVERSION_SYMLINK'] = '${LDMODULEPREFIX}$_get_ldmodule_stem${LDMODULESUFFIX}'
+ env['LDMODULE_NOVERSION_SYMLINK'] = '$_get_shlib_dir${LDMODULEPREFIX}$_get_ldmodule_stem${LDMODULESUFFIX}'
# This is the sonamed file name
# If LDMODULEVERSION is defined then this will symlink to $LDMODULENAME
- env['LDMODULE_SONAME_SYMLINK'] = '$_LDMODULESONAME'
+ env['LDMODULE_SONAME_SYMLINK'] = '$_get_shlib_dir$_LDMODULESONAME'
env['_LDMODULEVERSION'] = "${LDMODULEVERSION and '.'+LDMODULEVERSION or ''}"
env['_LDMODULEVERSIONFLAGS'] = '$LDMODULEVERSIONFLAGS -Wl,-soname=$_LDMODULESONAME'
diff --git a/SCons/Tool/linkCommon/SharedLibrary.py b/SCons/Tool/linkCommon/SharedLibrary.py
index bddcb42..9214939 100644
--- a/SCons/Tool/linkCommon/SharedLibrary.py
+++ b/SCons/Tool/linkCommon/SharedLibrary.py
@@ -7,36 +7,51 @@ from . import lib_emitter, EmitLibSymlinks, StringizeLibSymlinks
def shlib_symlink_emitter(target, source, env, **kw):
verbose = False
- if 'variable_prefix' in kw:
- var_prefix = kw['variable_prefix']
+ if "variable_prefix" in kw:
+ var_prefix = kw["variable_prefix"]
else:
- var_prefix = 'SHLIB'
+ var_prefix = "SHLIB"
- do_symlinks = env.subst('$%sNOVERSIONSYMLINKS' % var_prefix)
- if do_symlinks in ['1', 'True', 'true', True]:
+ do_symlinks = env.subst("$%sNOVERSIONSYMLINKS" % var_prefix)
+ if do_symlinks in ["1", "True", "true", True]:
return target, source
- shlibversion = env.subst('$%sVERSION' % var_prefix)
+ shlibversion = env.subst("$%sVERSION" % var_prefix)
if shlibversion:
if verbose:
print("shlib_symlink_emitter: %sVERSION=%s" % (var_prefix, shlibversion))
libnode = target[0]
- shlib_soname_symlink = env.subst('$%s_SONAME_SYMLINK' % var_prefix, target=target, source=source)
- shlib_noversion_symlink = env.subst('$%s_NOVERSION_SYMLINK' % var_prefix, target=target, source=source)
+ shlib_soname_symlink = env.subst(
+ "$%s_SONAME_SYMLINK" % var_prefix, target=target, source=source
+ )
+ shlib_noversion_symlink = env.subst(
+ "$%s_NOVERSION_SYMLINK" % var_prefix, target=target, source=source
+ )
if verbose:
print("shlib_soname_symlink :%s" % shlib_soname_symlink)
print("shlib_noversion_symlink :%s" % shlib_noversion_symlink)
print("libnode :%s" % libnode)
- symlinks = [(env.File(shlib_soname_symlink), libnode),
- (env.File(shlib_noversion_symlink), libnode)]
+ shlib_soname_symlink = env.File(shlib_soname_symlink)
+ shlib_noversion_symlink = env.File(shlib_noversion_symlink)
+
+ symlinks = []
+ if shlib_soname_symlink != libnode:
+ # If soname and library name machine, don't symlink them together
+ symlinks.append((env.File(shlib_soname_symlink), libnode))
+
+ symlinks.append((env.File(shlib_noversion_symlink), libnode))
if verbose:
- print("_lib_emitter: symlinks={!r}".format(
- ', '.join(["%r->%r" % (k, v) for k, v in StringizeLibSymlinks(symlinks)])
- ))
+ print(
+ "_lib_emitter: symlinks={!r}".format(
+ ", ".join(
+ ["%r->%r" % (k, v) for k, v in StringizeLibSymlinks(symlinks)]
+ )
+ )
+ )
if symlinks:
# This does the actual symlinking
@@ -52,25 +67,28 @@ def shlib_symlink_emitter(target, source, env, **kw):
def _soversion(target, source, env, for_signature):
"""Function to determine what to use for SOVERSION"""
- if 'SOVERSION' in env:
- return '.$SOVERSION'
- elif 'SHLIBVERSION' in env:
- shlibversion = env.subst('$SHLIBVERSION')
+ if "SOVERSION" in env:
+ return ".$SOVERSION"
+ elif "SHLIBVERSION" in env:
+ shlibversion = env.subst("$SHLIBVERSION")
# We use only the most significant digit of SHLIBVERSION
- return '.' + shlibversion.split('.')[0]
+ return "." + shlibversion.split(".")[0]
else:
- return ''
+ return ""
def _soname(target, source, env, for_signature):
- if 'SONAME' in env:
+ if "SONAME" in env:
# Now verify that SOVERSION is not also set as that is not allowed
- if 'SOVERSION' in env:
- raise UserError('Ambiguous library .so naming, both SONAME: %s and SOVERSION: %s are defined. '
- 'Only one can be defined for a target library.' % (env['SONAME'], env['SOVERSION']))
- return '$SONAME'
+ if "SOVERSION" in env:
+ raise UserError(
+ "Ambiguous library .so naming, both SONAME: %s and SOVERSION: %s are defined. "
+ "Only one can be defined for a target library."
+ % (env["SONAME"], env["SOVERSION"])
+ )
+ return "$SONAME"
else:
- return "$_get_shlib_dir$SHLIBPREFIX$_get_shlib_stem$_SHLIBSOVERSION${SHLIBSUFFIX}"
+ return "$SHLIBPREFIX$_get_shlib_stem${SHLIBSUFFIX}$_SHLIBSOVERSION"
def _get_shlib_stem(target, source, env, for_signature):
@@ -82,20 +100,23 @@ def _get_shlib_stem(target, source, env, for_signature):
:param for_signature:
:return:
"""
- verbose = False
+ verbose = True
target_name = str(target.name)
- shlibprefix = env.subst('$SHLIBPREFIX')
+ shlibprefix = env.subst("$SHLIBPREFIX")
shlibsuffix = env.subst("$_SHLIBSUFFIX")
if verbose and not for_signature:
- print("_get_shlib_stem: target_name:%s shlibprefix:%s shlibsuffix:%s" % (target_name, shlibprefix, shlibsuffix))
+ print(
+ "_get_shlib_stem: target_name:%s shlibprefix:%s shlibsuffix:%s"
+ % (target_name, shlibprefix, shlibsuffix)
+ )
if target_name.startswith(shlibprefix):
- target_name = target_name[len(shlibprefix):]
+ target_name = target_name[len(shlibprefix) :]
if target_name.endswith(shlibsuffix):
- target_name = target_name[:-len(shlibsuffix)]
+ target_name = target_name[: -len(shlibsuffix)]
if verbose and not for_signature:
print("_get_shlib_stem: target_name:%s AFTER" % (target_name,))
@@ -107,7 +128,8 @@ def _get_shlib_dir(target, source, env, for_signature):
"""
Get the directory the shlib is in.
"""
- if target.dir:
+ if target.dir and str(target.dir) != ".":
+ print("target.dir:%s" % target.dir)
return "%s/" % str(target.dir)
else:
return ""
@@ -121,33 +143,37 @@ def setup_shared_lib_logic(env):
"""
createSharedLibBuilder(env)
- env['_get_shlib_stem'] = _get_shlib_stem
- env['_get_shlib_dir'] = _get_shlib_dir
- env['_SHLIBSOVERSION'] = _soversion
- env['_SHLIBSONAME'] = _soname
+ env["_get_shlib_stem"] = _get_shlib_stem
+ env["_get_shlib_dir"] = _get_shlib_dir
+ env["_SHLIBSOVERSION"] = _soversion
+ env["_SHLIBSONAME"] = _soname
- env['SHLIBNAME'] = '${_get_shlib_dir}${SHLIBPREFIX}$_get_shlib_stem${_SHLIBSUFFIX}'
+ env["SHLIBNAME"] = "${_get_shlib_dir}${SHLIBPREFIX}$_get_shlib_stem${_SHLIBSUFFIX}"
# This is the non versioned shlib filename
# If SHLIBVERSION is defined then this will symlink to $SHLIBNAME
- env['SHLIB_NOVERSION_SYMLINK'] = '${_get_shlib_dir}${SHLIBPREFIX}$_get_shlib_stem${SHLIBSUFFIX}'
+ env[
+ "SHLIB_NOVERSION_SYMLINK"
+ ] = "${_get_shlib_dir}${SHLIBPREFIX}$_get_shlib_stem${SHLIBSUFFIX}"
# This is the sonamed file name
# If SHLIBVERSION is defined then this will symlink to $SHLIBNAME
- env['SHLIB_SONAME_SYMLINK'] = '$_SHLIBSONAME'
+ env["SHLIB_SONAME_SYMLINK"] = "${_get_shlib_dir}$_SHLIBSONAME"
# Note this is gnu style
- env['SHLIBSONAMEFLAGS'] = '-Wl,-soname=$_SHLIBSONAME'
- env['_SHLIBVERSION'] = "${SHLIBVERSION and '.'+SHLIBVERSION or ''}"
- env['_SHLIBVERSIONFLAGS'] = '$SHLIBVERSIONFLAGS -Wl,-soname=$_SHLIBSONAME'
+ env["SHLIBSONAMEFLAGS"] = "-Wl,-soname=$_SHLIBSONAME"
+ env["_SHLIBVERSION"] = "${SHLIBVERSION and '.'+SHLIBVERSION or ''}"
+ env["_SHLIBVERSIONFLAGS"] = "$SHLIBVERSIONFLAGS -Wl,-soname=$_SHLIBSONAME"
- env['SHLIBEMITTER'] = [lib_emitter, shlib_symlink_emitter]
+ env["SHLIBEMITTER"] = [lib_emitter, shlib_symlink_emitter]
- env['SHLIBPREFIX'] = 'lib'
- env['_SHLIBSUFFIX'] = '${SHLIBSUFFIX}${_SHLIBVERSION}'
+ env["SHLIBPREFIX"] = "lib"
+ env["_SHLIBSUFFIX"] = "${SHLIBSUFFIX}${_SHLIBVERSION}"
- env['SHLINKFLAGS'] = CLVar('$LINKFLAGS -shared')
+ env["SHLINKFLAGS"] = CLVar("$LINKFLAGS -shared")
- env['SHLINKCOM'] = '$SHLINK -o $TARGET $SHLINKFLAGS $__SHLIBVERSIONFLAGS $__RPATH $SOURCES $_LIBDIRFLAGS $_LIBFLAGS'
- env['SHLINKCOMSTR'] = '$SHLINKCOM'
- env['SHLINK'] = '$LINK'
+ env[
+ "SHLINKCOM"
+ ] = "$SHLINK -o $TARGET $SHLINKFLAGS $__SHLIBVERSIONFLAGS $__RPATH $SOURCES $_LIBDIRFLAGS $_LIBFLAGS"
+ env["SHLINKCOMSTR"] = "$SHLINKCOM"
+ env["SHLINK"] = "$LINK"