From 24039c12619be3b419ba4f08f17e8e10c9edb85c Mon Sep 17 00:00:00 2001 From: stevenknight Date: Sat, 25 Jan 2003 08:23:44 +0000 Subject: [PATCH] PharLap follow-on patch. (Charles Crain) git-svn-id: http://scons.tigris.org/svn/scons/trunk@566 fdb21ef1-2011-0410-befe-b5e4ea1792b1 --- src/engine/SCons/Tool/PharLapCommon.py | 12 ++++++++++-- src/engine/SCons/Tool/PharLapCommonTests.py | 9 ++++++++- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/src/engine/SCons/Tool/PharLapCommon.py b/src/engine/SCons/Tool/PharLapCommon.py index ddcaba6b..7f562c53 100644 --- a/src/engine/SCons/Tool/PharLapCommon.py +++ b/src/engine/SCons/Tool/PharLapCommon.py @@ -94,9 +94,17 @@ def addPathIfNotExists(env_dict, key, path, sep=os.pathsep): separated by tokens. The 'path' will get added to the list if it is not already there.""" try: - paths = string.split(env_dict[key], sep) + is_list = 1 + paths = env_dict[key] + if not SCons.Util.is_List(env_dict[key]): + paths = string.split(paths, sep) + is_list = 0 if not os.path.normcase(path) in map(os.path.normcase, paths): - env_dict[key] = string.join([ path ] + paths, sep) + paths = [ path ] + paths + if is_list: + env_dict[key] = paths + else: + env_dict[key] = string.join(paths, sep) except KeyError: env_dict[key] = path diff --git a/src/engine/SCons/Tool/PharLapCommonTests.py b/src/engine/SCons/Tool/PharLapCommonTests.py index 663b25e8..d1794570 100644 --- a/src/engine/SCons/Tool/PharLapCommonTests.py +++ b/src/engine/SCons/Tool/PharLapCommonTests.py @@ -37,10 +37,14 @@ class PharLapCommonTestCase(unittest.TestCase): env_dict = { 'FOO' : os.path.normpath('/foo/bar') + os.pathsep + \ os.path.normpath('/baz/blat'), 'BAR' : os.path.normpath('/foo/bar') + os.pathsep + \ - os.path.normpath('/baz/blat') } + os.path.normpath('/baz/blat'), + 'BLAT' : [ os.path.normpath('/foo/bar'), + os.path.normpath('/baz/blat') ] } addPathIfNotExists(env_dict, 'FOO', os.path.normpath('/foo/bar')) addPathIfNotExists(env_dict, 'BAR', os.path.normpath('/bar/foo')) addPathIfNotExists(env_dict, 'BAZ', os.path.normpath('/foo/baz')) + addPathIfNotExists(env_dict, 'BLAT', os.path.normpath('/baz/blat')) + addPathIfNotExists(env_dict, 'BLAT', os.path.normpath('/baz/foo')) assert env_dict['FOO'] == os.path.normpath('/foo/bar') + os.pathsep + \ os.path.normpath('/baz/blat'), env_dict['FOO'] @@ -48,6 +52,9 @@ class PharLapCommonTestCase(unittest.TestCase): os.path.normpath('/foo/bar') + os.pathsep + \ os.path.normpath('/baz/blat'), env_dict['BAR'] assert env_dict['BAZ'] == os.path.normpath('/foo/baz'), env_dict['BAZ'] + assert env_dict['BLAT'] == [ os.path.normpath('/baz/foo'), + os.path.normpath('/foo/bar'), + os.path.normpath('/baz/blat') ], env_dict['BLAT' ] if __name__ == "__main__": suite = unittest.makeSuite(PharLapCommonTestCase, 'test_') -- 2.26.2