summaryrefslogtreecommitdiffstats
path: root/SCons/Util.py
diff options
context:
space:
mode:
authorWilliam Deegan <bill@baddogconsulting.com>2021-03-18 01:27:51 (GMT)
committerGitHub <noreply@github.com>2021-03-18 01:27:51 (GMT)
commit1a782f346d213ed28a52e4027abe871407817986 (patch)
treeac6badfc0c726e2235a28db04e88b8c48596cb86 /SCons/Util.py
parent84124633878d155422c7d708719ef71bd4423e3f (diff)
parent23900b6edc8faf001c9d5bb40984ff1279e40135 (diff)
downloadSCons-1a782f346d213ed28a52e4027abe871407817986.zip
SCons-1a782f346d213ed28a52e4027abe871407817986.tar.gz
SCons-1a782f346d213ed28a52e4027abe871407817986.tar.bz2
Merge pull request #3899 from mwichmann/shlib-tweaks
Don't chop some shlib names in _get_shlib_stem and adjustixes
Diffstat (limited to 'SCons/Util.py')
-rw-r--r--SCons/Util.py25
1 files changed, 18 insertions, 7 deletions
diff --git a/SCons/Util.py b/SCons/Util.py
index 427792e..e614880 100644
--- a/SCons/Util.py
+++ b/SCons/Util.py
@@ -23,12 +23,12 @@
"""Various SCons utility functions."""
-import os
-import sys
import copy
-import re
-import pprint
import hashlib
+import os
+import pprint
+import re
+import sys
from collections import UserDict, UserList, UserString, OrderedDict
from collections.abc import MappingView
from types import MethodType, FunctionType
@@ -1112,17 +1112,28 @@ else:
def case_sensitive_suffixes(s1, s2):
return (os.path.normcase(s1) != os.path.normcase(s2))
+
def adjustixes(fname, pre, suf, ensure_suffix=False):
+ """
+ Add prefix to file if specified.
+ Add suffix to file if specified and if ensure_suffix = True
+
+ """
if pre:
path, fn = os.path.split(os.path.normpath(fname))
- if fn[:len(pre)] != pre:
+
+ # Handle the odd case where the filename = the prefix.
+ # In that case, we still want to add the prefix to the file
+ if fn[:len(pre)] != pre or fn == pre:
fname = os.path.join(path, pre + fn)
# Only append a suffix if the suffix we're going to add isn't already
# there, and if either we've been asked to ensure the specific suffix
# is present or there's no suffix on it at all.
+ # Also handle the odd case where the filename = the suffix.
+ # in that case we still want to append the suffix
if suf and fname[-len(suf):] != suf and \
- (ensure_suffix or not splitext(fname)[1]):
- fname = fname + suf
+ (ensure_suffix or not splitext(fname)[1]):
+ fname = fname + suf
return fname