From: stevenknight Date: Fri, 1 Apr 2005 16:05:36 +0000 (+0000) Subject: Normalize directory paths in SConsignFile() database files. (Chad Austin) X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=9edf036aeb5cbb5bdcb16a92a41c5667ece44389;p=scons.git Normalize directory paths in SConsignFile() database files. (Chad Austin) git-svn-id: http://scons.tigris.org/svn/scons/trunk@1272 fdb21ef1-2011-0410-befe-b5e4ea1792b1 --- diff --git a/src/CHANGES.txt b/src/CHANGES.txt index 7e2e68a4..555139b2 100644 --- a/src/CHANGES.txt +++ b/src/CHANGES.txt @@ -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. diff --git a/src/RELEASE.txt b/src/RELEASE.txt index eabc4f60..095671d6 100644 --- a/src/RELEASE.txt +++ b/src/RELEASE.txt @@ -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 diff --git a/src/engine/SCons/SConsign.py b/src/engine/SCons/SConsign.py index 6610eafe..212ec8de 100644 --- a/src/engine/SCons/SConsign.py +++ b/src/engine/SCons/SConsign.py @@ -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 diff --git a/src/engine/SCons/SConsignTests.py b/src/engine/SCons/SConsignTests.py index c2c05ac5..c2f40bd6 100644 --- a/src/engine/SCons/SConsignTests.py +++ b/src/engine/SCons/SConsignTests.py @@ -23,11 +23,13 @@ __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