diff options
author | William Deegan <bill@baddogconsulting.com> | 2023-10-26 18:58:58 +0300 |
---|---|---|
committer | Mats Wichmann <mats@linux.com> | 2023-10-28 17:01:49 +0300 |
commit | e7258b088c7c7e87c9c33e3aedc79dd0a7cdf32f (patch) | |
tree | 6791592ce714d8a9e24f1260961ea3028bb6e298 | |
parent | d7904efb2c949647341d364d2235b85b21fc71b9 (diff) |
switch from embedding LIBLITERAL in _stripixes() to being a passed argument with a False default value, and add properly passing LIBLITERAL in link, dmd, ldc tools where _stripixes() is actually used in current SCons Code (#10)
-rw-r--r-- | SCons/Defaults.py | 10 | ||||
-rw-r--r-- | SCons/EnvironmentTests.py | 13 | ||||
-rw-r--r-- | SCons/Tool/dmd.py | 2 | ||||
-rw-r--r-- | SCons/Tool/ldc.py | 8 | ||||
-rw-r--r-- | SCons/Tool/link.py | 2 |
5 files changed, 23 insertions, 12 deletions
diff --git a/SCons/Defaults.py b/SCons/Defaults.py index c0e7afc17..49e9cc48d 100644 --- a/SCons/Defaults.py +++ b/SCons/Defaults.py @@ -462,6 +462,7 @@ def _stripixes( stripprefixes: str, stripsuffixes: str, env, + literal_prefix: str = "", c: Callable[[list], list] = None, ) -> list: """Returns a list with text added to items after first stripping them. @@ -498,14 +499,13 @@ def _stripixes( stripprefixes = list(map(env.subst, flatten(stripprefixes))) stripsuffixes = list(map(env.subst, flatten(stripsuffixes))) - # This is a little funky: if $LIBLITERAL is the same as os.pathsep + # This is a little funky: if literal_prefix is the same as os.pathsep # (e.g. both ':'), the normal conversion to a PathList will drop the - # $LIBLITERAL prefix. Tell it not to split in that case, which *should* + # literal_prefix prefix. Tell it not to split in that case, which *should* # be okay because if we come through here, we're normally processing # library names and won't have strings like "path:secondpath:thirdpath" # which is why PathList() otherwise wants to split strings. - libliteral = env.get('LIBLITERAL') - do_split = not libliteral == os.pathsep + do_split = not literal_prefix == os.pathsep stripped = [] for l in SCons.PathList.PathList(items, do_split).subst_path(env, None, None): @@ -516,7 +516,7 @@ def _stripixes( if not is_String(l): l = str(l) - if libliteral and l.startswith(libliteral): + if literal_prefix and l.startswith(literal_prefix): stripped.append(l) continue diff --git a/SCons/EnvironmentTests.py b/SCons/EnvironmentTests.py index 756e05592..b1b6a0d64 100644 --- a/SCons/EnvironmentTests.py +++ b/SCons/EnvironmentTests.py @@ -1538,9 +1538,20 @@ def exists(env): LIBSUFFIXES=['.yyy'], LIBLITERAL='zz', ) - x = e.subst('$( ${_stripixes(PRE, LIST, SUF, LIBPREFIXES, LIBSUFFIXES,__env__)} $)') + x = e.subst('$( ${_stripixes(PRE, LIST, SUF, LIBPREFIXES, LIBSUFFIXES,__env__, LIBLITERAL)} $)') self.assertEqual(x, 'preasuf prebsuf prezzxxx-c.yyysuf') + # Test that setting literal_prefix (in this case LIBLITERAL) + # same as os.pathsep disables the literal protection + e['LIBLITERAL'] = os.pathsep + x = e.subst('$( ${_stripixes(PRE, LIST, SUF, LIBPREFIXES, LIBSUFFIXES,__env__, LIBLITERAL)} $)') + self.assertEqual(x, 'preasuf prebsuf prezzxxx-csuf') + + # Test that setting not settingliteral_prefix doesn't fail + x = e.subst('$( ${_stripixes(PRE, LIST, SUF, LIBPREFIXES, LIBSUFFIXES,__env__)} $)') + self.assertEqual(x, 'preasuf prebsuf prezzxxx-csuf') + + def test_gvars(self) -> None: """Test the Environment gvars() method""" diff --git a/SCons/Tool/dmd.py b/SCons/Tool/dmd.py index 553670016..1a173ad31 100644 --- a/SCons/Tool/dmd.py +++ b/SCons/Tool/dmd.py @@ -138,7 +138,7 @@ def generate(env) -> None: env['DLIBLINKPREFIX'] = '' if env['PLATFORM'] == 'win32' else '-L-l' env['DLIBLINKSUFFIX'] = '.lib' if env['PLATFORM'] == 'win32' else '' - env['_DLIBFLAGS'] = '${_stripixes(DLIBLINKPREFIX, LIBS, DLIBLINKSUFFIX, LIBPREFIXES, LIBSUFFIXES, __env__)}' + env['_DLIBFLAGS'] = '${_stripixes(DLIBLINKPREFIX, LIBS, DLIBLINKSUFFIX, LIBPREFIXES, LIBSUFFIXES, __env__, LIBLITERAL)}' env['DLIBDIRPREFIX'] = '-L-L' env['DLIBDIRSUFFIX'] = '' diff --git a/SCons/Tool/ldc.py b/SCons/Tool/ldc.py index bd0767e7f..b557134fe 100644 --- a/SCons/Tool/ldc.py +++ b/SCons/Tool/ldc.py @@ -73,7 +73,7 @@ def generate(env) -> None: env['_DDEBUGFLAGS'] = '${_concat(DDEBUGPREFIX, DDEBUG, DDEBUGSUFFIX, __env__)}' env['_DI_FLAGS'] = "${DI_FILE_DIR and DI_FILE_DIR_PREFIX+DI_FILE_DIR+DI_FILE_DIR_SUFFFIX}" - + env['_DFLAGS'] = '${_concat(DFLAGPREFIX, DFLAGS, DFLAGSUFFIX, __env__)}' env['SHDC'] = '$DC' @@ -96,10 +96,10 @@ def generate(env) -> None: env['DFLAGPREFIX'] = '-' env['DFLAGSUFFIX'] = '' env['DFILESUFFIX'] = '.d' - + env['DI_FILE_DIR'] = '' env['DI_FILE_SUFFIX'] = '.di' - + env['DI_FILE_DIR_PREFIX'] = '-Hd=' env['DI_FILE_DIR_SUFFFIX'] = '' @@ -115,7 +115,7 @@ def generate(env) -> None: env['DLIBLINKPREFIX'] = '' if env['PLATFORM'] == 'win32' else '-L-l' env['DLIBLINKSUFFIX'] = '.lib' if env['PLATFORM'] == 'win32' else '' # env['_DLIBFLAGS'] = '${_concat(DLIBLINKPREFIX, LIBS, DLIBLINKSUFFIX, __env__, RDirs, TARGET, SOURCE)}' - env['_DLIBFLAGS'] = '${_stripixes(DLIBLINKPREFIX, LIBS, DLIBLINKSUFFIX, LIBPREFIXES, LIBSUFFIXES, __env__)}' + env['_DLIBFLAGS'] = '${_stripixes(DLIBLINKPREFIX, LIBS, DLIBLINKSUFFIX, LIBPREFIXES, LIBSUFFIXES, __env__, LIBLITERAL)}' env['DLIBDIRPREFIX'] = '-L-L' env['DLIBDIRSUFFIX'] = '' diff --git a/SCons/Tool/link.py b/SCons/Tool/link.py index e879ae862..bfebc5def 100644 --- a/SCons/Tool/link.py +++ b/SCons/Tool/link.py @@ -55,7 +55,7 @@ def generate(env) -> None: env['LINKCOM'] = '$LINK -o $TARGET $LINKFLAGS $__RPATH $SOURCES $_LIBDIRFLAGS $_LIBFLAGS' env['LIBDIRPREFIX'] = '-L' env['LIBDIRSUFFIX'] = '' - env['_LIBFLAGS'] = '${_stripixes(LIBLINKPREFIX, LIBS, LIBLINKSUFFIX, LIBPREFIXES, LIBSUFFIXES, __env__)}' + env['_LIBFLAGS'] = '${_stripixes(LIBLINKPREFIX, LIBS, LIBLINKSUFFIX, LIBPREFIXES, LIBSUFFIXES, __env__, LIBLITERAL)}' env['LIBLINKPREFIX'] = '-l' env['LIBLINKSUFFIX'] = '' |