summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSteven Knight <knight@baldmt.com>2001-12-19 19:10:20 (GMT)
committerSteven Knight <knight@baldmt.com>2001-12-19 19:10:20 (GMT)
commit98bdd799b0c61d2bf1004a9dc39976e4a31abc9c (patch)
treebc2a34afc07f4cea3a05434e83e4acfd83191ac6 /src
parent8a2a326bd1eebca4dc635c2eb7b8e873ebd6be73 (diff)
downloadSCons-98bdd799b0c61d2bf1004a9dc39976e4a31abc9c.zip
SCons-98bdd799b0c61d2bf1004a9dc39976e4a31abc9c.tar.gz
SCons-98bdd799b0c61d2bf1004a9dc39976e4a31abc9c.tar.bz2
Add a getcwd() method to Node.FS so we can wrap up a delayed call to setting the root of the FS.
Diffstat (limited to 'src')
-rw-r--r--src/engine/SCons/Builder.py2
-rw-r--r--src/engine/SCons/Node/FS.py10
-rw-r--r--src/engine/SCons/Node/FSTests.py8
-rw-r--r--src/engine/SCons/Node/__init__.py2
4 files changed, 17 insertions, 5 deletions
diff --git a/src/engine/SCons/Builder.py b/src/engine/SCons/Builder.py
index c7551af..d221629 100644
--- a/src/engine/SCons/Builder.py
+++ b/src/engine/SCons/Builder.py
@@ -180,7 +180,7 @@ class BuilderBase:
self.node_factory)
for t in tlist:
- t.cwd = SCons.Node.FS.default_fs.cwd # XXX
+ t.cwd = SCons.Node.FS.default_fs.getcwd() # XXX
t.builder_set(self)
t.env_set(env)
t.add_source(slist)
diff --git a/src/engine/SCons/Node/FS.py b/src/engine/SCons/Node/FS.py
index 6a7fcc8..5cc06ac 100644
--- a/src/engine/SCons/Node/FS.py
+++ b/src/engine/SCons/Node/FS.py
@@ -143,7 +143,7 @@ class FS:
self.Top.path = '.'
self.Top.srcpath = '.'
self.Top.path_ = os.path.join('.', '')
- self.cwd = self.Top
+ self._cwd = self.Top
def __hash__(self):
self.__setTopLevelDir()
@@ -155,6 +155,10 @@ class FS:
other.__setTopLevelDir()
return cmp(self.__dict__, other.__dict__)
+ def getcwd(self):
+ self.__setTopLevelDir()
+ return self._cwd
+
def __doLookup(self, fsclass, name, directory=None):
"""This method differs from the File and Dir factory methods in
one important way: the meaning of the directory parameter.
@@ -228,7 +232,7 @@ class FS:
directory = self.Top
name = os.path.join(os.path.normpath('./'), name[1:])
elif not directory:
- directory = self.cwd
+ directory = self._cwd
return (name, directory)
def chdir(self, dir):
@@ -236,7 +240,7 @@ class FS:
"""
self.__setTopLevelDir()
if not dir is None:
- self.cwd = dir
+ self._cwd = dir
def Entry(self, name, directory = None):
"""Lookup or create a generic Entry node with the specified name.
diff --git a/src/engine/SCons/Node/FSTests.py b/src/engine/SCons/Node/FSTests.py
index 6851e5e..f97627e 100644
--- a/src/engine/SCons/Node/FSTests.py
+++ b/src/engine/SCons/Node/FSTests.py
@@ -416,6 +416,14 @@ class FSTestCase(unittest.TestCase):
val[e] = 'e'
for k, v in val.items():
assert k == os.path.normpath("hash/" + v)
+
+ # Test getcwd()
+ fs = SCons.Node.FS.FS()
+ assert str(fs.getcwd()) == ".", str(fs.getcwd())
+ fs.chdir(fs.Dir('subdir'))
+ assert str(fs.getcwd()) == "subdir", str(fs.getcwd())
+ fs.chdir(fs.Dir('../..'))
+ assert str(fs.getcwd()) == test.workdir, str(fs.getcwd())
#XXX test exists()
diff --git a/src/engine/SCons/Node/__init__.py b/src/engine/SCons/Node/__init__.py
index 0682c7f..b81f911 100644
--- a/src/engine/SCons/Node/__init__.py
+++ b/src/engine/SCons/Node/__init__.py
@@ -118,7 +118,7 @@ class Node:
def get_contents(self):
env = self.node.env.Dictionary()
try:
- dir = self.node.cwd
+ dir = self.node.getcwd()
except AttributeError:
dir = None
return self.node.builder.get_contents(env = env, dir = dir)