diff options
author | Mats Wichmann <mats@linux.com> | 2021-02-20 20:28:43 (GMT) |
---|---|---|
committer | Mats Wichmann <mats@linux.com> | 2021-03-12 19:57:04 (GMT) |
commit | dd0de0935302adbb2cb315a6246870c2434100e9 (patch) | |
tree | 736221431ae2283e0f511b25ffdeca355ef8e841 | |
parent | d10c8b15aa2ca3b6024fa6d9c99656d11205e266 (diff) | |
download | SCons-dd0de0935302adbb2cb315a6246870c2434100e9.zip SCons-dd0de0935302adbb2cb315a6246870c2434100e9.tar.gz SCons-dd0de0935302adbb2cb315a6246870c2434100e9.tar.bz2 |
Don't chop some shlib names in _get_shlib_stem
Avoid a couple of pathological cases: if SHLIBPREFIX or SHLIBSUFFIX is
empty, there's nothing to chop anyway , so just skip (the latter case
had the chance of returning an empty string). If the libname is exactly
SHLIBPREFIX, leave it alone, else we'd return an empty string.
Fiddle some docstrings.
Signed-off-by: Mats Wichmann <mats@linux.com>
-rw-r--r-- | SCons/Tool/linkCommon/SharedLibrary.py | 49 |
1 files changed, 31 insertions, 18 deletions
diff --git a/SCons/Tool/linkCommon/SharedLibrary.py b/SCons/Tool/linkCommon/SharedLibrary.py index 5c6250d..a79d78c 100644 --- a/SCons/Tool/linkCommon/SharedLibrary.py +++ b/SCons/Tool/linkCommon/SharedLibrary.py @@ -114,14 +114,17 @@ def _soname(target, source, env, for_signature): return "$SHLIBPREFIX$_get_shlib_stem${SHLIBSUFFIX}$_SHLIBSOVERSION" -def _get_shlib_stem(target, source, env, for_signature): - """ - Get the basename for a library (so for libxyz.so, return xyz) - :param target: - :param source: - :param env: - :param for_signature: - :return: +def _get_shlib_stem(target, source, env, for_signature: bool) -> str: + """Get the base name of a shared library. + + Args: + target: target node containing the lib name + source: source node, not used + env: environment context for running subst + for_signature: whether this is being done for signature generation + + Returns: + the library name without prefix/suffix """ verbose = False @@ -135,10 +138,12 @@ def _get_shlib_stem(target, source, env, for_signature): % (target_name, shlibprefix, shlibsuffix) ) - if target_name.startswith(shlibprefix): - target_name = target_name[len(shlibprefix) :] + if shlibprefix and target_name.startswith(shlibprefix): + # skip pathlogical case were target _is_ the prefix + if target_name != shlibprefix: + target_name = target_name[len(shlibprefix) :] - if target_name.endswith(shlibsuffix): + if shlibsuffix and target_name.endswith(shlibsuffix): target_name = target_name[: -len(shlibsuffix)] if verbose and not for_signature: @@ -147,9 +152,17 @@ def _get_shlib_stem(target, source, env, for_signature): return target_name -def _get_shlib_dir(target, source, env, for_signature): - """ - Get the directory the shlib is in. +def _get_shlib_dir(target, source, env, for_signature: bool) -> str: + """Get the directory the shared library is in. + + Args: + target: target node + source: source node, not used + env: environment context, not used + for_signature: whether this is being done for signature generation + + Returns: + the directory the library will be in (empty string if '.') """ if target.dir and str(target.dir) != ".": print("target.dir:%s" % target.dir) @@ -159,10 +172,10 @@ def _get_shlib_dir(target, source, env, for_signature): def setup_shared_lib_logic(env): - """ - Just the logic for shared libraries - :param env: - :return: + """Initialize an environment for shared library building. + + Args: + env: environment to set up """ createSharedLibBuilder(env) |