summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSteven Knight <knight@baldmt.com>2005-11-19 16:26:31 (GMT)
committerSteven Knight <knight@baldmt.com>2005-11-19 16:26:31 (GMT)
commitb48e679512303fd62e13430b73bd7a76d6df1b47 (patch)
tree6cdd8dda6d3eb1488c44d2c8b7cbae05008f5ca8 /src
parent499a2f21504c0727cf3c3dffd4be6c847ff2ec43 (diff)
downloadSCons-b48e679512303fd62e13430b73bd7a76d6df1b47.zip
SCons-b48e679512303fd62e13430b73bd7a76d6df1b47.tar.gz
SCons-b48e679512303fd62e13430b73bd7a76d6df1b47.tar.bz2
Support specifying absolute path names without drive letters on Win32.
Diffstat (limited to 'src')
-rw-r--r--src/CHANGES.txt3
-rw-r--r--src/engine/SCons/EnvironmentTests.py46
-rw-r--r--src/engine/SCons/Node/FS.py16
-rw-r--r--src/engine/SCons/Node/FSTests.py8
4 files changed, 50 insertions, 23 deletions
diff --git a/src/CHANGES.txt b/src/CHANGES.txt
index d087d74..1d67c5a 100644
--- a/src/CHANGES.txt
+++ b/src/CHANGES.txt
@@ -389,6 +389,9 @@ RELEASE 0.97 - XXX
- Handle signature calculation properly when the Python function used
for a FunctionAction is an object method.
+ - On Windows, assume that absolute path names without a drive letter
+ refer to the drive on which the SConstruct file lives.
+
From Chen Lee:
- Handle Visual Studio project and solution files in Unicode.
diff --git a/src/engine/SCons/EnvironmentTests.py b/src/engine/SCons/EnvironmentTests.py
index a397d4f..58c8ae8 100644
--- a/src/engine/SCons/EnvironmentTests.py
+++ b/src/engine/SCons/EnvironmentTests.py
@@ -794,6 +794,12 @@ class BaseTestCase(unittest.TestCase):
def test_autogenerate(dict):
"""Test autogenerating variables in a dictionary."""
+ drive, p = os.path.splitdrive(os.getcwd())
+ def normalize_path(path, drive=drive):
+ if path[0] in '\\/':
+ path = drive + path
+ return os.path.normpath(path)
+
env = Environment(LIBS = [ 'foo', 'bar', 'baz' ],
LIBLINKPREFIX = 'foo',
LIBLINKSUFFIX = 'bar')
@@ -813,12 +819,12 @@ class BaseTestCase(unittest.TestCase):
FOO = 'baz')
flags = env.subst_list('$_CPPINCFLAGS', 1)[0]
expect = [ '$(',
- os.path.normpath('foo'),
- os.path.normpath('xx/foobar'),
- os.path.normpath('foo'),
- os.path.normpath('xx/baz/bar'),
- os.path.normpath('foo'),
- os.path.normpath('blatbar'),
+ normalize_path('foo'),
+ normalize_path('xx/foobar'),
+ normalize_path('foo'),
+ normalize_path('xx/baz/bar'),
+ normalize_path('foo'),
+ normalize_path('blatbar'),
'$)',
]
assert flags == expect, flags
@@ -829,12 +835,12 @@ class BaseTestCase(unittest.TestCase):
FOO = 'baz')
flags = env.subst_list('$_F77INCFLAGS', 1)[0]
expect = [ '$(',
- os.path.normpath('foo'),
- os.path.normpath('xx/foobar'),
- os.path.normpath('foo'),
- os.path.normpath('xx/baz/bar'),
- os.path.normpath('foo'),
- os.path.normpath('blatbar'),
+ normalize_path('foo'),
+ normalize_path('xx/foobar'),
+ normalize_path('foo'),
+ normalize_path('xx/baz/bar'),
+ normalize_path('foo'),
+ normalize_path('blatbar'),
'$)',
]
assert flags == expect, flags
@@ -855,14 +861,14 @@ class BaseTestCase(unittest.TestCase):
FOO = 'baz')
flags = env.subst_list('$_CPPINCFLAGS', 1)[0]
expect = [ '$(',
- '-I', os.path.normpath('xx/fooXXX'),
- '-I', os.path.normpath('/rep1/xx/fooXXX'),
- '-I', os.path.normpath('/rep2/xx/fooXXX'),
- '-I', os.path.normpath('/a/bXXX'),
- '-I', os.path.normpath('xx/baz/barXXX'),
- '-I', os.path.normpath('/rep1/xx/baz/barXXX'),
- '-I', os.path.normpath('/rep2/xx/baz/barXXX'),
- '-I', os.path.normpath('blatXXX'),
+ '-I', normalize_path('xx/fooXXX'),
+ '-I', normalize_path('/rep1/xx/fooXXX'),
+ '-I', normalize_path('/rep2/xx/fooXXX'),
+ '-I', normalize_path('/a/bXXX'),
+ '-I', normalize_path('xx/baz/barXXX'),
+ '-I', normalize_path('/rep1/xx/baz/barXXX'),
+ '-I', normalize_path('/rep2/xx/baz/barXXX'),
+ '-I', normalize_path('blatXXX'),
'$)'
]
assert flags == expect, flags
diff --git a/src/engine/SCons/Node/FS.py b/src/engine/SCons/Node/FS.py
index 810ede7..7d4d8df 100644
--- a/src/engine/SCons/Node/FS.py
+++ b/src/engine/SCons/Node/FS.py
@@ -837,6 +837,7 @@ class FS(LocalFS):
The path argument must be a valid absolute path.
"""
if __debug__: logInstanceCreation(self, 'Node.FS')
+
self.Root = {}
self.SConstruct_dir = None
self.CachePath = None
@@ -844,10 +845,12 @@ class FS(LocalFS):
self.cache_show = None
self.max_drift = default_max_drift
+ self.Top = None
if path is None:
self.pathTop = os.getcwd()
else:
self.pathTop = path
+ self.defaultDrive = _my_normcase(os.path.splitdrive(self.pathTop)[0])
self.Top = self._doLookup(Dir, os.path.normpath(self.pathTop))
self.Top.path = '.'
@@ -913,8 +916,8 @@ class FS(LocalFS):
path_orig = [ path_first, ] + path_orig
path_norm = [ _my_normcase(path_first), ] + path_norm
else:
- drive = _my_normcase(drive)
# Absolute path
+ drive = _my_normcase(drive)
try:
directory = self.Root[drive]
except KeyError:
@@ -922,6 +925,10 @@ class FS(LocalFS):
raise SCons.Errors.UserError
directory = RootDir(drive, self)
self.Root[drive] = directory
+ if not drive:
+ self.Root[self.defaultDrive] = directory
+ elif drive == self.defaultDrive:
+ self.Root[''] = directory
if not path_orig:
return directory
@@ -1649,6 +1656,13 @@ class File(Base):
"""Search for a list of directories in the Repository list."""
return self.fs.Rfindalldirs(pathlist, self.cwd)
+ #def generate_build_dict(self):
+ # """Return an appropriate dictionary of values for building
+ # this File."""
+ # return {'Dir' : self.Dir,
+ # 'File' : self.File,
+ # 'RDirs' : self.RDirs}
+
def _morph(self):
"""Turn a file system node into a File object. __cache_reset__"""
self.scanner_paths = {}
diff --git a/src/engine/SCons/Node/FSTests.py b/src/engine/SCons/Node/FSTests.py
index 565384f..cb98f50 100644
--- a/src/engine/SCons/Node/FSTests.py
+++ b/src/engine/SCons/Node/FSTests.py
@@ -854,9 +854,11 @@ class FSTestCase(_tempdirTestCase):
if os.sep != '/':
seps = seps + ['/']
+ drive, path = os.path.splitdrive(os.getcwd())
+
for sep in seps:
- def Dir_test(lpath, path_, abspath_, up_path_, fileSys=fs, s=sep):
+ def Dir_test(lpath, path_, abspath_, up_path_, fileSys=fs, s=sep, drive=drive):
dir = fileSys.Dir(string.replace(lpath, '/', s))
if os.sep != '/':
@@ -864,9 +866,11 @@ class FSTestCase(_tempdirTestCase):
abspath_ = string.replace(abspath_, '/', os.sep)
up_path_ = string.replace(up_path_, '/', os.sep)
- def strip_slash(p):
+ def strip_slash(p, drive=drive):
if p[-1] == os.sep and len(p) > 1:
p = p[:-1]
+ if p[0] == os.sep:
+ p = drive + p
return p
path = strip_slash(path_)
abspath = strip_slash(abspath_)