summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSteven Knight <knight@baldmt.com>2004-07-30 17:00:27 (GMT)
committerSteven Knight <knight@baldmt.com>2004-07-30 17:00:27 (GMT)
commit3bdcea46577a5ea16cd20d201fe54cdadf5153ee (patch)
tree30440ef5750597fb8bec24b9e38259f30c2114fd /src
parent31af139b8a20b975430974a638e957b61cd4cf23 (diff)
downloadSCons-3bdcea46577a5ea16cd20d201fe54cdadf5153ee.zip
SCons-3bdcea46577a5ea16cd20d201fe54cdadf5153ee.tar.gz
SCons-3bdcea46577a5ea16cd20d201fe54cdadf5153ee.tar.bz2
Treat file extensions with all digits as part of the base name. (Gary Oberbrunne)
Diffstat (limited to 'src')
-rw-r--r--src/CHANGES.txt4
-rw-r--r--src/RELEASE.txt18
-rw-r--r--src/engine/SCons/Util.py34
-rw-r--r--src/engine/SCons/UtilTests.py15
4 files changed, 61 insertions, 10 deletions
diff --git a/src/CHANGES.txt b/src/CHANGES.txt
index 5042043..11532e6 100644
--- a/src/CHANGES.txt
+++ b/src/CHANGES.txt
@@ -179,6 +179,10 @@ RELEASE 0.96 - XXX
- Avoid stack traces when trying to read dangling symlinks.
+ - Treat file "extensions" that only contain digits as part of the
+ file basename. This supports version numbers as part of shared
+ library names, for example.
+
From Simon Perkins:
- Fix a bug introduced in building shared libraries under MinGW.
diff --git a/src/RELEASE.txt b/src/RELEASE.txt
index 7917a7e..2228a83 100644
--- a/src/RELEASE.txt
+++ b/src/RELEASE.txt
@@ -37,10 +37,10 @@ RELEASE 0.96 - XXX
import anydbm
SConsignFile('.sconsign_file_name', anydbm)
- - The internal format of .sconsign files has been changed.
- This may cause warnings about "ignoring corrupt .sconsign files"
- and rebuilds when you use SCons 0.96 for the first time in a tre
- that was previously gbuilt with SCons 0.95 or earlier.
+ - The internal format of .sconsign files has been changed. This might
+ cause warnings about "ignoring corrupt .sconsign files" and rebuilds
+ when you use SCons 0.96 for the first time in a tree that was
+ previously built with SCons 0.95 or earlier.
- The scan_check function that can be supplied to a custom Scanner now
must take two arguments, the Node to be checked and a construction
@@ -53,7 +53,6 @@ RELEASE 0.96 - XXX
the following scanner, you must now add the suffix to a construction
environment through which you plan to call the scanner, as follows:
-
CScan.add_skey('.x') => env.Append(CPPSUFFIXES = ['.x'])
DScan.add_skey('.x') => env.Append(DSUFFIXES = ['.x'])
FortranScan.add_skey('.x') => env.Append(FORTRANSUFFIXES = ['.x'])
@@ -62,6 +61,15 @@ RELEASE 0.96 - XXX
the seperate and more flexible "target_factory" and "source_factory"
keywords should be used instead.
+ - SCons now treats file "extensions" that contain all digits (for
+ example, "file.123") as part of the file basename, for easier
+ handling of version numbers in the names of shared libraries
+ and other files. Builders will now add their file extensions to
+ file names specified with all-digit extensions. If you need to
+ generate a file with an all-digit extension using a Builder that
+ adds a file extension, you can preserve the previous behavior by
+ wrapping the file name in a File() call.
+
- The behavior of the env.Append() and env.Prepend() methods has
changed when appending a string value to a UserList, or vice versa.
They now behave like normal Python addition of a string to
diff --git a/src/engine/SCons/Util.py b/src/engine/SCons/Util.py
index e2399a8..998a01b 100644
--- a/src/engine/SCons/Util.py
+++ b/src/engine/SCons/Util.py
@@ -98,15 +98,39 @@ _altsep = os.altsep
if _altsep is None and sys.platform == 'win32':
# My ActivePython 2.0.1 doesn't set os.altsep! What gives?
_altsep = '/'
+if _altsep:
+ def rightmost_separator(path, sep, _altsep=_altsep):
+ rfind = string.rfind
+ return max(rfind(path, sep), rfind(path, _altsep))
+else:
+ rightmost_separator = string.rfind
+
+# First two from the Python Cookbook, just for completeness.
+# (Yeah, yeah, YAGNI...)
+def containsAny(str, set):
+ """Check whether sequence str contains ANY of the items in set."""
+ for c in set:
+ if c in str: return 1
+ return 0
+
+def containsAll(str, set):
+ """Check whether sequence str contains ALL of the items in set."""
+ for c in set:
+ if c not in str: return 0
+ return 1
+
+def containsOnly(str, set):
+ """Check whether sequence str contains ONLY items in set."""
+ for c in str:
+ if c not in set: return 0
+ return 1
def splitext(path):
"Same as os.path.splitext() but faster."
- if _altsep:
- sep = max(string.rfind(path, os.sep), string.rfind(path, _altsep))
- else:
- sep = string.rfind(path, os.sep)
+ sep = rightmost_separator(path, os.sep)
dot = string.rfind(path, '.')
- if dot > sep:
+ # An ext is only real if it has at least one non-digit char
+ if dot > sep and not containsOnly(path[dot:], "0123456789."):
return path[:dot],path[dot:]
else:
return path,""
diff --git a/src/engine/SCons/UtilTests.py b/src/engine/SCons/UtilTests.py
index 713f522..1bce1af 100644
--- a/src/engine/SCons/UtilTests.py
+++ b/src/engine/SCons/UtilTests.py
@@ -1509,6 +1509,21 @@ class UtilTestCase(unittest.TestCase):
r = adjustixes('dir/file', 'pre-', '-suf')
assert r == os.path.join('dir', 'pre-file-suf'), r
+ def test_containsAny(self):
+ """Test the containsAny() function"""
+ assert containsAny('*.py', '*?[]')
+ assert not containsAny('file.txt', '*?[]')
+
+ def test_containsAll(self):
+ """Test the containsAll() function"""
+ assert containsAll('43221', '123')
+ assert not containsAll('134', '123')
+
+ def test_containsOnly(self):
+ """Test the containsOnly() function"""
+ assert containsOnly('.83', '0123456789.')
+ assert not containsOnly('43221', '123')
+
if __name__ == "__main__":
suite = unittest.makeSuite(UtilTestCase, 'test_')
if not unittest.TextTestRunner().run(suite).wasSuccessful():