Normalize directory paths in SConsignFile() database files. (Chad Austin)
authorstevenknight <stevenknight@fdb21ef1-2011-0410-befe-b5e4ea1792b1>
Fri, 1 Apr 2005 16:05:36 +0000 (16:05 +0000)
committerstevenknight <stevenknight@fdb21ef1-2011-0410-befe-b5e4ea1792b1>
Fri, 1 Apr 2005 16:05:36 +0000 (16:05 +0000)
git-svn-id: http://scons.tigris.org/svn/scons/trunk@1272 fdb21ef1-2011-0410-befe-b5e4ea1792b1

src/CHANGES.txt
src/RELEASE.txt
src/engine/SCons/SConsign.py
src/engine/SCons/SConsignTests.py

index 7e2e68a4d1041f37ebcc326002f4fe47087b5dd5..555139b2d0dc1191571c6ec8f5c97dfac0ce18d3 100644 (file)
@@ -28,6 +28,10 @@ RELEASE 0.97 - XXX
   - Have the environment store the toolpath and re-use it to find Tools
     modules during later Copy() or Tool() calls (unless overridden).
 
+  - Normalize the directory path names in SConsignFile() database
+    files so the same signature file can interoperate on Windows and
+    non-Windows systems.
+
   From Stanislav Baranov:
 
   - Make it possible to support with custom Alias (sub-)classes.
index eabc4f60d925fb69322c64602be1307f22d1c87e..095671d63bf7969fbdca824fb5b76ccf71958d8a 100644 (file)
@@ -58,6 +58,21 @@ RELEASE 0.97 - XXX
         or /usr/local was passed as the source to a Builder or Command()
         call, in which case SCons would scan the entire directory tree.
 
+    --  SIGNATURE CHANGES WILL CAUSE LIKELY REBUILDS AFTER UPGRADE
+
+        This release adds several changes to the signature mechanism that
+        will cause SCons to rebuild most configurations after upgrading
+        (and if switching back from 0.97 to an earlier release).
+        These changes are:
+
+          --  NORMALIZED PATHS IN SConsignFile() DATABASES ON WINDOWS
+
+              When using an SConsignFile() database, instead of individual
+              .sconsign files in each directory, the path names are
+              stored in normalized form with / (forward slash) separating
+              the elements.  This may cause rebuilds on Windows systems
+              with hierarchical configurations.
+
     --  CACHED Configure() RESULTS ARE STORED IN A DIFFERENT FILE
 
         The Configure() subsystem now stores its cached results in a
index 6610eafea88f2559da246945dd1007623bd8acc0..212ec8def5f7cc24e1979f14fb29df5a64ee75d7 100644 (file)
@@ -32,6 +32,7 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
 import cPickle
 import os
 import os.path
+import string
 import time
 
 import SCons.Node
@@ -41,8 +42,15 @@ import SCons.Warnings
 #XXX Get rid of the global array so this becomes re-entrant.
 sig_files = []
 
+# Handle to open database object if using the DB SConsign implementation.
 database = None
 
+if os.sep == '/':
+    norm_entry = lambda s: s
+else:
+    def norm_entry(str):
+        return string.replace(str, os.sep, '/')
+
 def write():
     global sig_files
     for sig_file in sig_files:
@@ -98,7 +106,7 @@ class DB(Base):
 
         try:
             global database
-            rawentries = database[self.dir.path]
+            rawentries = database[norm_entry(self.dir.path)]
         except KeyError:
             pass
         else:
@@ -119,7 +127,7 @@ class DB(Base):
     def write(self, sync=1):
         if self.dirty:
             global database
-            database[self.dir.path] = cPickle.dumps(self.entries, 1)
+            database[norm_entry(self.dir.path)] = cPickle.dumps(self.entries, 1)
             if sync:
                 try:
                     syncmethod = database.sync
index c2c05ac52210e97667a34d96de4677a8e246c065..c2f40bd623399e28c23d46c23c3db8e2c5c274fe 100644 (file)
 
 __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
 
-import SCons.SConsign
+import os
 import sys
 import TestCmd
 import unittest
 
+import SCons.SConsign
+
 class BuildInfo:
     def __init__(self, name):
         self.name = name
@@ -111,13 +113,29 @@ class SConsignDBTestCase(unittest.TestCase):
             bbb = d1.get_entry('bbb')
             assert bbb.name == 'bbb name'
 
-            d2 = SCons.SConsign.DB(DummyNode('dir1'))
+            d2 = SCons.SConsign.DB(DummyNode('dir2'))
             d2.set_entry('ccc', BuildInfo('ccc name'))
             d2.set_entry('ddd', BuildInfo('ddd name'))
             ccc = d2.get_entry('ccc')
             assert ccc.name == 'ccc name'
             ddd = d2.get_entry('ddd')
             assert ddd.name == 'ddd name'
+
+            d31 = SCons.SConsign.DB(DummyNode('dir3/sub1'))
+            d31.set_entry('eee', BuildInfo('eee name'))
+            d31.set_entry('fff', BuildInfo('fff name'))
+            eee = d31.get_entry('eee')
+            assert eee.name == 'eee name'
+            fff = d31.get_entry('fff')
+            assert fff.name == 'fff name'
+
+            d32 = SCons.SConsign.DB(DummyNode('dir3%ssub2' % os.sep))
+            d32.set_entry('ggg', BuildInfo('ggg name'))
+            d32.set_entry('hhh', BuildInfo('hhh name'))
+            ggg = d32.get_entry('ggg')
+            assert ggg.name == 'ggg name'
+            hhh = d32.get_entry('hhh')
+            assert hhh.name == 'hhh name'
         finally:
             SCons.SConsign.database = save_database