Give Value Nodes timestamps. (Chad Austin)
authorstevenknight <stevenknight@fdb21ef1-2011-0410-befe-b5e4ea1792b1>
Mon, 21 Jul 2003 13:44:04 +0000 (13:44 +0000)
committerstevenknight <stevenknight@fdb21ef1-2011-0410-befe-b5e4ea1792b1>
Mon, 21 Jul 2003 13:44:04 +0000 (13:44 +0000)
git-svn-id: http://scons.tigris.org/svn/scons/trunk@742 fdb21ef1-2011-0410-befe-b5e4ea1792b1

doc/man/scons.1
src/CHANGES.txt
src/engine/SCons/Node/Python.py
test/Value.py

index 7be2a37605e4709ca35fbea032b9c57f401bae65..b39db9310f06c8012644b528bd9ea29ce129e7e1 100644 (file)
@@ -4588,7 +4588,8 @@ calling
 .BR str( value )
 changes between SCons runs, any targets depending on
 .BR Value( value )
-will be rebuilt.
+will be rebuilt.  When using timestamp source signatures, Value nodes'
+timestamps are equal to the system time when the node is created.
 
 .ES
 def create(target, source, env):
index b7a050688fc3a8f22307631c0f1a44fab21c86d0..abbf744293d40a94823eac2c8765b61a13a24d05 100644 (file)
@@ -14,6 +14,9 @@ RELEASE 0.XX - XXX
 
   - Support specifying a list of tools when calling Environment.Copy().
 
+  - Give a Value Nodes a timestamp of the system time when they're
+    created, so they'll work when using timestamp-based signatures.
+
   From Steven Knight:
 
   - Tighten up the scons -H help output.
index 9348b83aa6f3293b4e2861cde98bd17b447f3049..312be5c4948ee2cc278c91d45175b4e753319038 100644 (file)
@@ -30,6 +30,7 @@ Python nodes.
 __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
 
 import SCons.Node
+import time
 
 class Value(SCons.Node.Node):
     """A class for Python variables, typically passed on the command line 
@@ -38,6 +39,7 @@ class Value(SCons.Node.Node):
     def __init__(self, value):
         SCons.Node.Node.__init__(self)
         self.value = value
+        self.timestamp = time.time()
 
     def __str__(self):
         return repr(self.value)
@@ -74,3 +76,6 @@ class Value(SCons.Node.Node):
         for kid in self.children(None):
             contents = contents + kid.get_contents()
         return contents
+
+    def get_timestamp(self):
+        return self.timestamp
index f3df6fea2530633f47dfe2a532ad8ca5fee4b0e2..11fb72a32d92b361a714b6d96ff79e57b27f5ab2 100644 (file)
@@ -33,7 +33,13 @@ import TestCmd
 
 test = TestSCons.TestSCons(match=TestCmd.match_re)
 
-test.write('SConstruct', """
+for source_signature in ['MD5', 'timestamp']:
+
+    print "Testing Value node with source signatures:", source_signature
+
+    test.write('SConstruct', """
+SourceSignatures(r'%s')
+
 class Custom:
     def __init__(self, value):  self.value = value
     def __str__(self):          return "C=" + str(self.value)
@@ -50,54 +56,68 @@ env['BUILDERS']['B'] = Builder(action = create)
 env.B('f1.out', Value(P))
 env.B('f2.out', Value(L))
 env.B('f3.out', Value(C))
-""")
-
-
-test.run()
-out1 = """create("f1.out", "'/usr/local'")"""
-out2 = """create("f2.out", "10")"""
-out3 = """create\\("f3.out", "<.*.Custom instance at """
-test.fail_test(string.find(test.stdout(), out1) == -1)
-test.fail_test(string.find(test.stdout(), out2) == -1)
-test.fail_test(re.search(out3, test.stdout()) == None)
-
-test.fail_test(not os.path.exists(test.workpath('f1.out')))
-test.fail_test(open(test.workpath('f1.out'), 'rb').read() != '/usr/local')
-test.fail_test(not os.path.exists(test.workpath('f2.out')))
-test.fail_test(open(test.workpath('f2.out'), 'rb').read() != '10')
-test.fail_test(not os.path.exists(test.workpath('f3.out')))
-test.fail_test(open(test.workpath('f3.out'), 'rb').read() != 'C=/usr/local')
-
-test.up_to_date(arguments = ".")
-
-test.run(arguments = 'prefix=/usr')
-out4 = """create("f1.out", "'/usr'")"""
-out5 = """create("f2.out", "4")"""
-out6 = """create\\("f3.out", "<.*.Custom instance at """
-test.fail_test(string.find(test.stdout(), out4) == -1)
-test.fail_test(string.find(test.stdout(), out5) == -1)
-test.fail_test(re.search(out6, test.stdout()) == None)
-
-test.fail_test(not os.path.exists(test.workpath('f1.out')))
-test.fail_test(open(test.workpath('f1.out'), 'rb').read() != '/usr')
-test.fail_test(not os.path.exists(test.workpath('f2.out')))
-test.fail_test(open(test.workpath('f2.out'), 'rb').read() != '4')
-test.fail_test(not os.path.exists(test.workpath('f3.out')))
-test.fail_test(open(test.workpath('f3.out'), 'rb').read() != 'C=/usr')
-
-test.unlink('f3.out')
-
-test.run(arguments = 'prefix=/var')
-out4 = """create("f1.out", "'/var'")"""
-test.fail_test(string.find(test.stdout(), out4) == -1)
-test.fail_test(string.find(test.stdout(), out5) != -1)
-test.fail_test(re.search(out6, test.stdout()) == None)
-
-test.fail_test(not os.path.exists(test.workpath('f1.out')))
-test.fail_test(open(test.workpath('f1.out'), 'rb').read() != '/var')
-test.fail_test(not os.path.exists(test.workpath('f2.out')))
-test.fail_test(open(test.workpath('f2.out'), 'rb').read() != '4')
-test.fail_test(not os.path.exists(test.workpath('f3.out')))
-test.fail_test(open(test.workpath('f3.out'), 'rb').read() != 'C=/var')
+""" % source_signature)
+
+    test.run(arguments='-c')
+    test.run()
+
+    out1 = """create("f1.out", "'/usr/local'")"""
+    out2 = """create("f2.out", "10")"""
+    out3 = """create\\("f3.out", "<.*.Custom instance at """
+    #" <- unconfuses emacs syntax highlighting
+    test.fail_test(string.find(test.stdout(), out1) == -1)
+    test.fail_test(string.find(test.stdout(), out2) == -1)
+    test.fail_test(re.search(out3, test.stdout()) == None)
+
+    test.fail_test(not os.path.exists(test.workpath('f1.out')))
+    test.fail_test(open(test.workpath('f1.out'), 'rb').read() != '/usr/local')
+    test.fail_test(not os.path.exists(test.workpath('f2.out')))
+    test.fail_test(open(test.workpath('f2.out'), 'rb').read() != '10')
+    test.fail_test(not os.path.exists(test.workpath('f3.out')))
+    test.fail_test(open(test.workpath('f3.out'), 'rb').read() != 'C=/usr/local')
+
+    if source_signature == 'MD5':
+        test.up_to_date(arguments='.')
+
+    test.run(arguments='prefix=/usr')
+    out4 = """create("f1.out", "'/usr'")"""
+    out5 = """create("f2.out", "4")"""
+    out6 = """create\\("f3.out", "<.*.Custom instance at """
+    #" <- unconfuses emacs syntax highlighting
+    test.fail_test(string.find(test.stdout(), out4) == -1)
+    test.fail_test(string.find(test.stdout(), out5) == -1)
+    test.fail_test(re.search(out6, test.stdout()) == None)
+
+    test.fail_test(not os.path.exists(test.workpath('f1.out')))
+    test.fail_test(open(test.workpath('f1.out'), 'rb').read() != '/usr')
+    test.fail_test(not os.path.exists(test.workpath('f2.out')))
+    test.fail_test(open(test.workpath('f2.out'), 'rb').read() != '4')
+    test.fail_test(not os.path.exists(test.workpath('f3.out')))
+    test.fail_test(open(test.workpath('f3.out'), 'rb').read() != 'C=/usr')
+
+    if source_signature == 'MD5':
+        test.up_to_date('prefix=/usr', '.')
+
+    test.unlink('f3.out')
+
+    test.run(arguments='prefix=/var')
+    out4 = """create("f1.out", "'/var'")"""
+
+    test.fail_test(string.find(test.stdout(), out4) == -1)
+    if source_signature == 'MD5':
+        test.fail_test(string.find(test.stdout(), out5) != -1)
+    else:
+        test.fail_test(string.find(test.stdout(), out5) == -1)
+    test.fail_test(re.search(out6, test.stdout()) == None)
+
+    if source_signature == 'MD5':
+        test.up_to_date('prefix=/var', '.')
+
+    test.fail_test(not os.path.exists(test.workpath('f1.out')))
+    test.fail_test(open(test.workpath('f1.out'), 'rb').read() != '/var')
+    test.fail_test(not os.path.exists(test.workpath('f2.out')))
+    test.fail_test(open(test.workpath('f2.out'), 'rb').read() != '4')
+    test.fail_test(not os.path.exists(test.workpath('f3.out')))
+    test.fail_test(open(test.workpath('f3.out'), 'rb').read() != 'C=/var')
 
 test.pass_test()