From: stevenknight Date: Sun, 20 Jul 2003 15:10:26 +0000 (+0000) Subject: New sconsign script fixes: print timestamp values correctly (Chad Austin); add a... X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=dc17d498e039eca73610e5da76ef507e4a4c37d2;p=scons.git 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 -. git-svn-id: http://scons.tigris.org/svn/scons/trunk@737 fdb21ef1-2011-0410-befe-b5e4ea1792b1 --- diff --git a/doc/man/sconsign.1 b/doc/man/sconsign.1 index cb0e38ee..d5f71407 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. @@ -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 diff --git a/src/script/sconsign.py b/src/script/sconsign.py index 7b5daf8b..d70f02b7 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 006f4149..1966c279 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()