summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteven Knight <knight@baldmt.com>2003-06-28 05:07:53 (GMT)
committerSteven Knight <knight@baldmt.com>2003-06-28 05:07:53 (GMT)
commit3757529b5b73fc69eff8a0709482198d45ed33c5 (patch)
tree49e39aab117a911546f6d61709b5cbc9c8b5dbc1
parentd3d08d4f13edc216f169f49636f3d81102727a33 (diff)
downloadSCons-3757529b5b73fc69eff8a0709482198d45ed33c5.zip
SCons-3757529b5b73fc69eff8a0709482198d45ed33c5.tar.gz
SCons-3757529b5b73fc69eff8a0709482198d45ed33c5.tar.bz2
Support targets that always rebuild. (Stephen Ng)
[Updating a change that was previously not synchronized to CVS.]
-rw-r--r--doc/man/scons.14
-rw-r--r--src/engine/SCons/Environment.py12
-rw-r--r--src/engine/SCons/Node/NodeTests.py9
-rw-r--r--src/engine/SCons/Node/__init__.py5
-rw-r--r--src/engine/SCons/Sig/SigTests.py4
-rw-r--r--src/engine/SCons/Sig/__init__.py4
-rw-r--r--test/AlwaysBuild.py55
7 files changed, 92 insertions, 1 deletions
diff --git a/doc/man/scons.1 b/doc/man/scons.1
index 214401f..cdfc7d8 100644
--- a/doc/man/scons.1
+++ b/doc/man/scons.1
@@ -688,7 +688,9 @@ Walks up the directory structure until an
or
.I sconstruct
file is found, and uses that
-as the top of the directory tree. Only targets at or below the
+as the top of the directory tree.
+If no targets are specified on the command line,
+only targets at or below the
current directory will be built.
.TP
diff --git a/src/engine/SCons/Environment.py b/src/engine/SCons/Environment.py
index 0f5cb30..04452a9 100644
--- a/src/engine/SCons/Environment.py
+++ b/src/engine/SCons/Environment.py
@@ -338,6 +338,18 @@ class Environment:
tlist = tlist[0]
return tlist
+ def AlwaysBuild(self, *targets):
+ tlist = []
+ for t in targets:
+ tlist.extend(SCons.Node.arg2nodes(t, self.fs.File))
+
+ for t in tlist:
+ t.set_always_build()
+
+ if len(tlist) == 1:
+ tlist = tlist[0]
+ return tlist
+
def Precious(self, *targets):
tlist = []
for t in targets:
diff --git a/src/engine/SCons/Node/NodeTests.py b/src/engine/SCons/Node/NodeTests.py
index ff57871..f8593d7 100644
--- a/src/engine/SCons/Node/NodeTests.py
+++ b/src/engine/SCons/Node/NodeTests.py
@@ -381,6 +381,15 @@ class NodeTestCase(unittest.TestCase):
node = SCons.Node.Node()
node.store_timestamp()
+ def test_set_always_build(self):
+ """Test setting a Node's always_build value
+ """
+ node = SCons.Node.Node()
+ node.set_always_build()
+ assert node.always_build
+ node.set_always_build(3)
+ assert node.always_build == 3
+
def test_set_precious(self):
"""Test setting a Node's precious value
"""
diff --git a/src/engine/SCons/Node/__init__.py b/src/engine/SCons/Node/__init__.py
index 43ae7c5..0fc2365 100644
--- a/src/engine/SCons/Node/__init__.py
+++ b/src/engine/SCons/Node/__init__.py
@@ -107,6 +107,7 @@ class Node:
self.env = None
self.state = None
self.precious = None
+ self.always_build = None
self.found_includes = {}
self.includes = None
self.overrides = {} # construction variable overrides for building this node
@@ -521,6 +522,10 @@ class Node:
"""Set the Node's precious value."""
self.precious = precious
+ def set_always_build(self, always_build = 1):
+ """Set the Node's always_build value."""
+ self.always_build = always_build
+
def exists(self):
"""Does this node exists?"""
# All node exist by default:
diff --git a/src/engine/SCons/Sig/SigTests.py b/src/engine/SCons/Sig/SigTests.py
index bb3efb8..3010396 100644
--- a/src/engine/SCons/Sig/SigTests.py
+++ b/src/engine/SCons/Sig/SigTests.py
@@ -58,6 +58,7 @@ class DummyNode:
self.oldtime = 0
self.oldbsig = 0
self.oldcsig = 0
+ self.always_build = 0
def has_builder(self):
return self.builder
@@ -380,12 +381,15 @@ class CalcTestCase(unittest.TestCase):
def test_Calc_current(self):
class NN(self.nodeclass):
+ always_build = 0
def current(self):
return None
nn = NN('nn', 33, 34)
assert not self.calc.current(nn, 30)
assert self.calc.current(nn, 33)
+ nn.always_build = 1
+ assert not self.calc.current(nn, 33)
class SConsignEntryTestCase(unittest.TestCase):
diff --git a/src/engine/SCons/Sig/__init__.py b/src/engine/SCons/Sig/__init__.py
index 6f830b6..65fe807 100644
--- a/src/engine/SCons/Sig/__init__.py
+++ b/src/engine/SCons/Sig/__init__.py
@@ -344,6 +344,10 @@ class Calculator:
returns - 1 if the file is current with the specified signature,
0 if it isn't
"""
+
+ if node.always_build:
+ return 0
+
oldtime, oldbsig, oldcsig = node.get_prevsiginfo()
if not node.has_builder() and node.get_timestamp() == oldtime:
diff --git a/test/AlwaysBuild.py b/test/AlwaysBuild.py
new file mode 100644
index 0000000..f4126c1
--- /dev/null
+++ b/test/AlwaysBuild.py
@@ -0,0 +1,55 @@
+#!/usr/bin/env python
+#
+# __COPYRIGHT__
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+
+__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
+
+import os
+import sys
+import TestSCons
+
+test = TestSCons.TestSCons()
+
+test.write('SConstruct', """
+def bfunc(target, source, env):
+ import shutil
+ shutil.copyfile('f2.in', str(target[0]))
+
+B = Builder(action=bfunc)
+env = Environment(BUILDERS = { 'B' : B })
+env.B('f1.out', source='f1.in')
+env.AlwaysBuild('f1.out')
+""")
+
+test.write('f1.in', "f1.in\n")
+test.write('f2.in', "1")
+
+test.run(arguments = ".")
+test.fail_test(test.read('f1.out') != '1')
+
+test.write('f2.in', "2")
+test.run(arguments = ".")
+test.fail_test(test.read('f1.out') != '2')
+
+test.pass_test()