1. SCons
  2. Core
  3. SCons

Commits

Steven Knight  committed 993b524

Add a getcwd() method to Node.FS so we can wrap up a delayed call to setting the root of the FS.

  • Participants
  • Parent commits 079efe3
  • Branches default

Comments (0)

Files changed (4)

File src/engine/SCons/Builder.py

View file
  • Ignore whitespace
                                 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)

File src/engine/SCons/Node/FS.py

View file
  • Ignore whitespace
             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()
             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.
             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):
         """
         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.

File src/engine/SCons/Node/FSTests.py

View file
  • Ignore whitespace
         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()
 

File src/engine/SCons/Node/__init__.py

View file
  • Ignore whitespace
             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)