diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/CHANGES.txt | 3 | ||||
-rw-r--r-- | src/engine/SCons/Environment.py | 15 | ||||
-rw-r--r-- | src/engine/SCons/EnvironmentTests.py | 20 | ||||
-rw-r--r-- | src/engine/SCons/Node/FS.py | 5 | ||||
-rw-r--r-- | src/engine/SCons/Node/FSTests.py | 6 | ||||
-rw-r--r-- | src/engine/SCons/Node/NodeTests.py | 9 | ||||
-rw-r--r-- | src/engine/SCons/Node/__init__.py | 11 |
7 files changed, 63 insertions, 6 deletions
diff --git a/src/CHANGES.txt b/src/CHANGES.txt index 9e2591b..cd3ebd4 100644 --- a/src/CHANGES.txt +++ b/src/CHANGES.txt @@ -54,6 +54,9 @@ RELEASE 0.04 - - Provide an error message when a nonexistent target is specified on the command line. + - Remove targets before building them, and add an Environment + Precious() method to override that. + From Steve Leblanc: - Add var=value command-line arguments. diff --git a/src/engine/SCons/Environment.py b/src/engine/SCons/Environment.py index 3c1ee43..6373a55 100644 --- a/src/engine/SCons/Environment.py +++ b/src/engine/SCons/Environment.py @@ -66,9 +66,6 @@ def installFunc(env, target, source): InstallBuilder = SCons.Builder.Builder(name='Install', action=installFunc) -def InstallAs(): - pass # XXX - def our_deepcopy(x): """deepcopy lists and dictionaries, and just copy the reference for everything else.""" @@ -185,6 +182,18 @@ class Environment: tlist = tlist[0] return tlist + def Precious(self, *targets): + tlist = [] + for t in targets: + tlist.extend(SCons.Util.scons_str2nodes(t)) + + for t in tlist: + t.set_precious() + + if len(tlist) == 1: + tlist = tlist[0] + return tlist + def Dictionary(self, *args): if not args: return self._dict diff --git a/src/engine/SCons/EnvironmentTests.py b/src/engine/SCons/EnvironmentTests.py index 59f3c78..def5998 100644 --- a/src/engine/SCons/EnvironmentTests.py +++ b/src/engine/SCons/EnvironmentTests.py @@ -233,9 +233,6 @@ class EnvironmentTestCase(unittest.TestCase): assert paths == expect, paths for tnode in tgt: assert tnode.builder == InstallBuilder - - def test_InstallAs(self): - pass # XXX def test_Update(self): """Test updating an Environment with new construction variables @@ -269,6 +266,23 @@ class EnvironmentTestCase(unittest.TestCase): assert i.__class__.__name__ == 'File' assert i.path == 'dep.py' + def test_Precious(self): + """Test the Precious() method.""" + env = Environment() + t = env.Precious('a', 'b', ['c', 'd']) + assert t[0].__class__.__name__ == 'File' + assert t[0].path == 'a' + assert t[0].precious + assert t[1].__class__.__name__ == 'File' + assert t[1].path == 'b' + assert t[1].precious + assert t[2].__class__.__name__ == 'File' + assert t[2].path == 'c' + assert t[2].precious + assert t[3].__class__.__name__ == 'File' + assert t[3].path == 'd' + assert t[3].precious + def test_Command(self): """Test the Command() method.""" env = Environment() diff --git a/src/engine/SCons/Node/FS.py b/src/engine/SCons/Node/FS.py index 2ce1151..7c19b81 100644 --- a/src/engine/SCons/Node/FS.py +++ b/src/engine/SCons/Node/FS.py @@ -566,5 +566,10 @@ class File(Entry): Entry.build(self) self.exists_flag = self.exists() + def remove(self): + """Remove this file.""" + if self.exists(): + os.unlink(self.path) + default_fs = FS() diff --git a/src/engine/SCons/Node/FSTests.py b/src/engine/SCons/Node/FSTests.py index 12dfdbe..2b3ba37 100644 --- a/src/engine/SCons/Node/FSTests.py +++ b/src/engine/SCons/Node/FSTests.py @@ -438,6 +438,12 @@ class FSTestCase(unittest.TestCase): nonexistent(fs.Dir, 'nonexistent') nonexistent(fs.Dir, 'nonexistent/foo') + test.write("remove_me", "\n") + assert os.path.exists(test.workpath("remove_me")) + f1 = fs.File(test.workpath("remove_me")) + f1.remove() + assert not os.path.exists(test.workpath("remove_me")) + #XXX test current() for directories #XXX test sconsign() for directories diff --git a/src/engine/SCons/Node/NodeTests.py b/src/engine/SCons/Node/NodeTests.py index aa9dccb..bcaf1a0 100644 --- a/src/engine/SCons/Node/NodeTests.py +++ b/src/engine/SCons/Node/NodeTests.py @@ -206,6 +206,15 @@ class NodeTestCase(unittest.TestCase): node.set_csig('zzz') assert node.get_csig() == 'zzz' + def test_set_precious(self): + """Test setting a Node's precious value + """ + node = SCons.Node.Node() + node.set_precious() + assert node.precious + node.set_precious(7) + assert node.precious == 7 + def test_add_dependency(self): """Test adding dependencies to a Node's list. """ diff --git a/src/engine/SCons/Node/__init__.py b/src/engine/SCons/Node/__init__.py index 03705f7..02c14bb 100644 --- a/src/engine/SCons/Node/__init__.py +++ b/src/engine/SCons/Node/__init__.py @@ -70,11 +70,14 @@ class Node: self.bsig = None self.csig = None self.use_signature = 1 + self.precious = None def build(self): """Actually build the node. Return the status from the build.""" if not self.builder: return None + if not self.precious: + self.remove() try: stat = self.builder.execute(env = self.env.Dictionary(), target = self, source = self.sources) @@ -164,6 +167,14 @@ class Node: """Set the signature of the node's content.""" self.csig = csig + def set_precious(self, precious = 1): + """Set the Node's precious value.""" + self.precious = precious + + def remove(self): + """Remove this Node's external object: no-op by default.""" + pass + def add_dependency(self, depend): """Adds dependencies. The depend argument must be a list.""" self._add_child(self.depends, depend) |