summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteven Knight <knight@baldmt.com>2003-07-20 15:10:26 (GMT)
committerSteven Knight <knight@baldmt.com>2003-07-20 15:10:26 (GMT)
commit819abe6e6861c13d8baa5dd964849654def5fe74 (patch)
tree5fdb2921481a604aa8a205fd015515568c2d1bcf
parenta7405b2115ba873ade35ebf16ade8736548b9a99 (diff)
downloadSCons-819abe6e6861c13d8baa5dd964849654def5fe74.zip
SCons-819abe6e6861c13d8baa5dd964849654def5fe74.tar.gz
SCons-819abe6e6861c13d8baa5dd964849654def5fe74.tar.bz2
New sconsign script fixes: print timestamp values correctly (Chad Austin); add a -r option to print timestamps in human-readable form (Gary Oberbrunner); print None instead of -.
-rw-r--r--doc/man/sconsign.18
-rw-r--r--src/script/sconsign.py19
-rw-r--r--test/sconsign-script.py68
3 files changed, 71 insertions, 24 deletions
diff --git a/doc/man/sconsign.1 b/doc/man/sconsign.1
index cb0e38e..d5f7140 100644
--- a/doc/man/sconsign.1
+++ b/doc/man/sconsign.1
@@ -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.
@@ -103,6 +104,11 @@ 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
for all entries or the specified entries.
diff --git a/src/script/sconsign.py b/src/script/sconsign.py
index 7b5daf8..d70f02b 100644
--- a/src/script/sconsign.py
+++ b/src/script/sconsign.py
@@ -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
diff --git a/test/sconsign-script.py b/test/sconsign-script.py
index 006f414..1966c27 100644
--- a/test/sconsign-script.py
+++ b/test/sconsign-script.py
@@ -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()