New sconsign script fixes: print timestamp values correctly (Chad Austin); add a...
authorstevenknight <stevenknight@fdb21ef1-2011-0410-befe-b5e4ea1792b1>
Sun, 20 Jul 2003 15:10:26 +0000 (15:10 +0000)
committerstevenknight <stevenknight@fdb21ef1-2011-0410-befe-b5e4ea1792b1>
Sun, 20 Jul 2003 15:10:26 +0000 (15:10 +0000)
git-svn-id: http://scons.tigris.org/svn/scons/trunk@737 fdb21ef1-2011-0410-befe-b5e4ea1792b1

doc/man/sconsign.1
src/script/sconsign.py
test/sconsign-script.py

index cb0e38ee6917bd1c63acab9d46a09bac18a316b3..d5f71407d174a0d39218dfb8d40b03be1a9b077d 100644 (file)
@@ -61,7 +61,8 @@ Each entry is printed in the following format:
             implicit_dependency_2
 
 If the entry has no timestamp, bsig, or csig, a dash
-(\fR\-\fP) is printed instead.
+.B None
+is printed.
 If the entry has no implicit dependencies,
 the lines are simply omitted.
 
@@ -102,6 +103,11 @@ Prints a help message and exits.
 Prints the list of cached implicit dependencies
 for all entries or the the specified entries.
 
+.TP
+-r, --readable
+Prints timestamps in a human-readable string,
+enclosed in single quotes.
+
 .TP
 -t, --timestamp
 Prints the timestamp information
index 7b5daf8b9cfa5dd4cd71566f1f6ea7998dbb644e..d70f02b7953a2c5faa8ed5585ffbbb1d24237a5c 100644 (file)
@@ -39,6 +39,7 @@ __developer__ = "__DEVELOPER__"
 import os
 import os.path
 import sys
+import time
 
 ##############################################################################
 # BEGIN STANDARD SCons SCRIPT HEADER
@@ -143,13 +144,14 @@ Options:
   -e, --entry ENTRY           Print only info about ENTRY.
   -h, --help                  Print this message and exit.
   -i, --implicit              Print implicit dependency information.
+  -r, --readable              Print timestamps in human-readable form.
   -t, --timestamp             Print timestamp information.
   -v, --verbose               Verbose, describe each field.
 """
 
-opts, args = getopt.getopt(sys.argv[1:], "bce:hitv",
+opts, args = getopt.getopt(sys.argv[1:], "bce:hirtv",
                             ['bsig', 'csig', 'entry=', 'help', 'implicit',
-                             'timestamp', 'verbose'])
+                             'readable', 'timestamp', 'verbose'])
 
 pf_bsig      = 0x1
 pf_csig      = 0x2
@@ -160,6 +162,7 @@ pf_all       = pf_bsig | pf_csig | pf_timestamp | pf_implicit
 entries = []
 printflags = 0
 verbose = 0
+readable = 0
 
 for o, a in opts:
     if o in ('-b', '--bsig'):
@@ -168,11 +171,13 @@ for o, a in opts:
         printflags = printflags | pf_csig
     elif o in ('-e', '--entry'):
         entries.append(a)
-    elif o in ('-h', o == '--help'):
+    elif o in ('-h', '--help'):
         print helpstr
         sys.exit(0)
     elif o in ('-i', '--implicit'):
         printflags = printflags | pf_implicit
+    elif o in ('-r', '--readable'):
+        readable = 1
     elif o in ('-t', '--timestamp'):
         printflags = printflags | pf_timestamp
     elif o in ('-v', '--verbose'):
@@ -187,12 +192,16 @@ def field(name, pf, val):
             sep = "\n    " + name + ": "
         else:
             sep = " "
-        return sep + (val or '-')
+        return sep + str(val)
     else:
         return ""
 
 def printfield(name, entry):
-    timestamp = field("timestamp", pf_timestamp, entry.timestamp)
+    if readable and entry.timestamp:
+        ts = "'" + time.ctime(entry.timestamp) + "'"
+    else:
+        ts = entry.timestamp
+    timestamp = field("timestamp", pf_timestamp, ts)
     bsig = field("bsig", pf_bsig, entry.bsig)
     csig = field("csig", pf_csig, entry.csig)
     print name + ":" + timestamp + bsig + csig
index 006f41496794400393e70b7785abb3283be55597..1966c2791964132a27a6e160cd118991b31805d0 100644 (file)
@@ -77,8 +77,8 @@ test.run(interpreter = TestSCons.python,
          program = "sconsign",
          arguments = "sub1/.sconsign",
          stdout = """\
-hello.exe: - \S+ -
-hello.obj: - \S+ -
+hello.exe: None \S+ None
+hello.obj: None \S+ None
 """)
 
 test.run(interpreter = TestSCons.python,
@@ -86,13 +86,13 @@ test.run(interpreter = TestSCons.python,
          arguments = "-v sub1/.sconsign",
          stdout = """\
 hello.exe:
-    timestamp: -
+    timestamp: None
     bsig: \S+
-    csig: -
+    csig: None
 hello.obj:
-    timestamp: -
+    timestamp: None
     bsig: \S+
-    csig: -
+    csig: None
 """)
 
 test.run(interpreter = TestSCons.python,
@@ -110,33 +110,33 @@ test.run(interpreter = TestSCons.python,
          arguments = "-c -v sub1/.sconsign",
          stdout = """\
 hello.exe:
-    csig: -
+    csig: None
 hello.obj:
-    csig: -
+    csig: None
 """)
 
 test.run(interpreter = TestSCons.python,
          program = "sconsign",
          arguments = "-e hello.obj sub1/.sconsign",
          stdout = """\
-hello.obj: - \S+ -
+hello.obj: None \S+ None
 """)
 
 test.run(interpreter = TestSCons.python,
          program = "sconsign",
          arguments = "-e hello.obj -e hello.exe -e hello.obj sub1/.sconsign",
          stdout = """\
-hello.obj: - \S+ -
-hello.exe: - \S+ -
-hello.obj: - \S+ -
+hello.obj: None \S+ None
+hello.exe: None \S+ None
+hello.obj: None \S+ None
 """)
 
 test.run(interpreter = TestSCons.python,
          program = "sconsign",
          arguments = "sub2/.sconsign",
          stdout = """\
-hello.exe: - \S+ -
-hello.obj: - \S+ -
+hello.exe: None \S+ None
+hello.obj: None \S+ None
         %s
         %s
 """ % (string.replace(os.path.join('sub2', 'inc1.h'), '\\', '\\\\'),
@@ -154,17 +154,49 @@ hello.obj:
 """ % (string.replace(os.path.join('sub2', 'inc1.h'), '\\', '\\\\'),
        string.replace(os.path.join('sub2', 'inc2.h'), '\\', '\\\\')))
 
-test.pass_test()
-
 test.run(interpreter = TestSCons.python,
          program = "sconsign",
          arguments = "-e hello.obj sub2/.sconsign sub1/.sconsign",
          stdout = """\
-hello.obj: - \S+ -
+hello.obj: None \S+ None
         %s
         %s
-hello.obj: - \S+ -
+hello.obj: None \S+ None
 """ % (string.replace(os.path.join('sub2', 'inc1.h'), '\\', '\\\\'),
        string.replace(os.path.join('sub2', 'inc2.h'), '\\', '\\\\')))
 
+test.run(arguments = '--clean .')
+
+test.write('SConstruct', """
+SourceSignatures('timestamp')
+TargetSignatures('content')
+env1 = Environment(PROGSUFFIX = '.exe', OBJSUFFIX = '.obj')
+env1.Program('sub1/hello.c')
+env2 = env1.Copy(CPPPATH = ['sub2'])
+env2.Program('sub2/hello.c')
+""")
+
+import time
+time.sleep(1)
+
+test.run(arguments = '. --max-drift=1')
+
+test.run(interpreter = TestSCons.python,
+         program = "sconsign",
+         arguments = "sub1/.sconsign",
+         stdout = """\
+hello.exe: None \S+ None
+hello.c: \d+ None \d+
+hello.obj: None \S+ None
+""")
+
+test.run(interpreter = TestSCons.python,
+         program = "sconsign",
+         arguments = "-r sub1/.sconsign",
+         stdout = """\
+hello.exe: None \S+ None
+hello.c: '\S+ \S+ \d+ \d\d:\d\d:\d\d \d\d\d\d' None \d+
+hello.obj: None \S+ None
+""")
+
 test.pass_test()