summaryrefslogtreecommitdiffstats
path: root/src/engine/SCons/Node
diff options
context:
space:
mode:
authorSteven Knight <knight@baldmt.com>2001-11-24 23:15:01 (GMT)
committerSteven Knight <knight@baldmt.com>2001-11-24 23:15:01 (GMT)
commit378373defaf150feb90cd54d13626516c6dbe1b4 (patch)
treefc9783004f1cae3c3558846d6f9a1c589e104a3e /src/engine/SCons/Node
parent139a0052dc0bff059dc9b8cf1739396304e7c129 (diff)
downloadSCons-378373defaf150feb90cd54d13626516c6dbe1b4.zip
SCons-378373defaf150feb90cd54d13626516c6dbe1b4.tar.gz
SCons-378373defaf150feb90cd54d13626516c6dbe1b4.tar.bz2
More NT portability fixes.
Diffstat (limited to 'src/engine/SCons/Node')
-rw-r--r--src/engine/SCons/Node/FS.py39
-rw-r--r--src/engine/SCons/Node/FSTests.py79
2 files changed, 61 insertions, 57 deletions
diff --git a/src/engine/SCons/Node/FS.py b/src/engine/SCons/Node/FS.py
index 75f7c5c..67a5ae7 100644
--- a/src/engine/SCons/Node/FS.py
+++ b/src/engine/SCons/Node/FS.py
@@ -97,13 +97,12 @@ class PathDict(UserDict):
def __delitem__(self, key):
del(self.data[PathName(key)])
- if not hasattr(UserDict, 'setdefault'):
- def setdefault(self, key, value):
- try:
- return self.data[PathName(key)]
- except KeyError:
- self.data[PathName(key)] = value
- return value
+ def setdefault(self, key, value):
+ try:
+ return self.data[PathName(key)]
+ except KeyError:
+ self.data[PathName(key)] = value
+ return value
class FS:
def __init__(self, path = None):
@@ -120,7 +119,7 @@ class FS:
self.Root = PathDict()
self.Top = self.__doLookup(Dir, path)
self.Top.path = '.'
- self.Top.path_ = './'
+ self.Top.path_ = os.path.join('.', '')
self.cwd = self.Top
def __doLookup(self, fsclass, name, directory=None):
@@ -147,11 +146,16 @@ class FS:
# None, raise an exception.
drive, tail = os.path.splitdrive(head)
- if sys.platform is 'win32' and not drive:
- if not directory:
- raise OSError, 'No drive letter supplied for absolute path.'
- return directory.root()
- return self.Root.setdefault(drive, Dir(tail))
+ #if sys.platform is 'win32' and not drive:
+ # if not directory:
+ # raise OSError, 'No drive letter supplied for absolute path.'
+ # return directory.root()
+ dir = Dir(tail)
+ dir.path = drive + dir.path
+ dir.path_ = drive + dir.path_
+ dir.abspath = drive + dir.abspath
+ dir.abspath_ = drive + dir.abspath_
+ return self.Root.setdefault(drive, dir)
if head:
# Recursively look up our parent directories.
directory = self.__doLookup(Dir, head, directory)
@@ -181,7 +185,7 @@ class FS:
usually in preparation for a call to doLookup().
If the path name is prepended with a '#', then it is unconditionally
- interpreted as replative to the top-level directory of this FS.
+ interpreted as relative to the top-level directory of this FS.
If directory is None, and name is a relative path,
then the same applies.
@@ -256,7 +260,7 @@ class Entry(SCons.Node.Node):
if directory:
self.abspath = os.path.join(directory.abspath, name)
if str(directory.path) == '.':
- self.path = os.path.join(name)
+ self.path = name
else:
self.path = os.path.join(directory.path, name)
else:
@@ -335,9 +339,8 @@ class Dir(Entry):
def children(self):
#XXX --random: randomize "dependencies?"
- kids = map(lambda x, s=self: s.entries[x],
- filter(lambda k: k != '.' and k != '..',
- self.entries.keys()))
+ keys = filter(lambda k: k != '.' and k != '..', self.entries.keys())
+ kids = map(lambda x, s=self: s.entries[x], keys)
def c(one, two):
if one.abspath < two.abspath:
return -1
diff --git a/src/engine/SCons/Node/FSTests.py b/src/engine/SCons/Node/FSTests.py
index fe35d76..4992099 100644
--- a/src/engine/SCons/Node/FSTests.py
+++ b/src/engine/SCons/Node/FSTests.py
@@ -92,22 +92,19 @@ class FSTestCase(unittest.TestCase):
def Dir_test(lpath, path_, abspath_, up_path_, fileSys=fs, s=sep):
dir = fileSys.Dir(string.replace(lpath, '/', s))
+ if os.sep != '/':
+ path_ = string.replace(path_, '/', os.sep)
+ abspath_ = string.replace(abspath_, '/', os.sep)
+ up_path_ = string.replace(up_path_, '/', os.sep)
+
def strip_slash(p):
- if p[-1] == '/' and len(p) > 1:
+ if p[-1] == os.sep and len(p) > 1:
p = p[:-1]
return p
path = strip_slash(path_)
abspath = strip_slash(abspath_)
up_path = strip_slash(up_path_)
- name = string.split(abspath, '/')[-1]
-
- if os.sep != '/':
- path = string.replace(path, '/', os.sep)
- path_ = string.replace(path_, '/', os.sep)
- abspath = string.replace(abspath, '/', os.sep)
- abspath_ = string.replace(abspath_, '/', os.sep)
- up_path = string.replace(up_path, '/', os.sep)
- up_path_ = string.replace(up_path_, '/', os.sep)
+ name = string.split(abspath, os.sep)[-1]
assert dir.name == name, \
"dir.name %s != expected name %s" % \
@@ -211,53 +208,57 @@ class FSTestCase(unittest.TestCase):
f1.build()
assert built_it
+ def match(path, expect):
+ expect = string.replace(expect, '/', os.sep)
+ assert path == expect, "path %s != expected %s" % (path, expect)
+
e1 = fs.Entry("d1")
assert e1.__class__.__name__ == 'Dir'
- assert e1.path == "d1", e1.path
- assert e1.path_ == "d1/", e1.path_
- assert e1.dir.path == ".", e1.dir.path
+ match(e1.path, "d1")
+ match(e1.path_, "d1/")
+ match(e1.dir.path, ".")
e2 = fs.Entry("d1/f1")
assert e2.__class__.__name__ == 'File'
- assert e2.path == "d1/f1", e2.path
- assert e2.path_ == "d1/f1", e2.path_
- assert e2.dir.path == "d1", e2.dir.path
+ match(e2.path, "d1/f1")
+ match(e2.path_, "d1/f1")
+ match(e2.dir.path, "d1")
e3 = fs.Entry("e3")
assert e3.__class__.__name__ == 'Entry'
- assert e3.path == "e3", e3.path
- assert e3.path_ == "e3", e3.path_
- assert e3.dir.path == ".", e3.dir.path
+ match(e3.path, "e3")
+ match(e3.path_, "e3")
+ match(e3.dir.path, ".")
e4 = fs.Entry("d1/e4")
assert e4.__class__.__name__ == 'Entry'
- assert e4.path == "d1/e4", e4.path
- assert e4.path_ == "d1/e4", e4.path_
- assert e4.dir.path == "d1", e4.dir.path
+ match(e4.path, "d1/e4")
+ match(e4.path_, "d1/e4")
+ match(e4.dir.path, "d1")
e5 = fs.Entry("e3/e5")
assert e3.__class__.__name__ == 'Dir'
- assert e3.path == "e3", e3.path
- assert e3.path_ == "e3/", e3.path_
- assert e3.dir.path == ".", e3.dir.path
+ match(e3.path, "e3")
+ match(e3.path_, "e3/")
+ match(e3.dir.path, ".")
assert e5.__class__.__name__ == 'Entry'
- assert e5.path == "e3/e5", e5.path
- assert e5.path_ == "e3/e5", e5.path_
- assert e5.dir.path == "e3", e5.dir.path
+ match(e5.path, "e3/e5")
+ match(e5.path_, "e3/e5")
+ match(e5.dir.path, "e3")
e6 = fs.Dir("d1/e4")
assert e6 is e4
assert e4.__class__.__name__ == 'Dir'
- assert e4.path == "d1/e4", e4.path
- assert e4.path_ == "d1/e4/", e4.path_
- assert e4.dir.path == "d1", e4.dir.path
+ match(e4.path, "d1/e4")
+ match(e4.path_, "d1/e4/")
+ match(e4.dir.path, "d1")
e7 = fs.File("e3/e5")
assert e7 is e5
assert e5.__class__.__name__ == 'File'
- assert e5.path == "e3/e5", e5.path
- assert e5.path_ == "e3/e5", e5.path_
- assert e5.dir.path == "e3", e5.dir.path
+ match(e5.path, "e3/e5")
+ match(e5.path_, "e3/e5")
+ match(e5.dir.path, "e3")
e8 = fs.Entry("e8")
assert e8.get_bsig() is None, e8.get_bsig()
@@ -285,21 +286,21 @@ class FSTestCase(unittest.TestCase):
fs.chdir(fs.Dir('subdir'))
f11 = fs.File("f11")
- assert f11.path == "subdir/f11"
+ match(f11.path, "subdir/f11")
d12 = fs.Dir("d12")
- assert d12.path_ == "subdir/d12/"
+ match(d12.path_, "subdir/d12/")
e13 = fs.Entry("subdir/e13")
- assert e13.path == "subdir/subdir/e13"
+ match(e13.path, "subdir/subdir/e13")
# Test scanning
f1.scanner = Scanner()
f1.scan()
- assert f1.depends[0].path_ == "d1/f1"
+ assert f1.depends[0].path_ == os.path.join("d1", "f1")
f1.scanner = None
f1.depends = []
f1.scanned = 0
f1.scan()
- assert f1.depends[0].path_ == "d1/f1"
+ assert f1.depends[0].path_ == os.path.join("d1", "f1")
# Test building a file whose directory is not there yet...
f1 = fs.File(test.workpath("foo/bar/baz/ack"))