From: stevenknight Date: Sat, 25 Jun 2005 16:03:54 +0000 (+0000) Subject: Add a --raw option to the sconsign script. X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=105ab2589ea977d50299926434960afba4d78055;p=scons.git Add a --raw option to the sconsign script. git-svn-id: http://scons.tigris.org/svn/scons/trunk@1313 fdb21ef1-2011-0410-befe-b5e4ea1792b1 --- diff --git a/doc/man/sconsign.1 b/doc/man/sconsign.1 index dc6d0cb5..7fc32ec2 100644 --- a/doc/man/sconsign.1 +++ b/doc/man/sconsign.1 @@ -161,6 +161,12 @@ Prints a help message and exits. Prints the list of cached implicit dependencies for all entries or the the specified entries. +.TP +--raw +Prints a pretty-printed representation +of the raw Python dictionary that holds +build information about an entry. + .TP -r, --readable Prints timestamps in a human-readable string, diff --git a/src/CHANGES.txt b/src/CHANGES.txt index 6a3e259b..545ef2ae 100644 --- a/src/CHANGES.txt +++ b/src/CHANGES.txt @@ -301,6 +301,9 @@ RELEASE 0.97 - XXX whether an RCS file exists for a missing source file; whether an SCCS file exists for a missing source file. + - Add a --raw argument to the sconsign script, so it can print a + raw representation of each entry's NodeInfo dictionary. + From Wayne Lee: - Avoid "maximum recursion limit" errors when removing $(-$) pairs diff --git a/src/script/sconsign.py b/src/script/sconsign.py index 6145ad66..56152e59 100644 --- a/src/script/sconsign.py +++ b/src/script/sconsign.py @@ -201,6 +201,7 @@ Print_Entries = [] Print_Flags = Flagger() Verbose = 0 Readable = 0 +Raw = 0 def default_mapper(entry, name): try: @@ -251,9 +252,20 @@ def field(name, entry, verbose=Verbose): val = name + ": " + val return val -def nodeinfo_string(name, entry, prefix=""): +def nodeinfo_raw(name, ninfo, prefix=""): + # This does essentially what the pprint module does, + # except that it sorts the keys for deterministic output. + d = ninfo.__dict__ + keys = d.keys() + keys.sort() + l = [] + for k in keys: + l.append('%s: %s' % (repr(k), repr(d[k]))) + return name + ': {' + string.join(l, ', ') + '}' + +def nodeinfo_string(name, ninfo, prefix=""): fieldlist = ["bsig", "csig", "timestamp", "size"] - f = lambda x, e=entry, v=Verbose: field(x, e, v) + f = lambda x, ni=ninfo, v=Verbose: field(x, ni, v) outlist = [name+":"] + filter(None, map(f, fieldlist)) if Verbose: sep = "\n " + prefix @@ -262,7 +274,10 @@ def nodeinfo_string(name, entry, prefix=""): return string.join(outlist, sep) def printfield(name, entry, prefix=""): - print nodeinfo_string(name, entry.ninfo, prefix) + if Raw: + print nodeinfo_raw(name, entry.ninfo, prefix) + else: + print nodeinfo_string(name, entry.ninfo, prefix) outlist = field("implicit", entry, 0) if outlist: @@ -371,6 +386,7 @@ Options: -h, --help Print this message and exit. -i, --implicit Print implicit dependency information. -r, --readable Print timestamps in human-readable form. + --raw Print raw Python object representations. -s, --size Print file sizes human-readable form. -t, --timestamp Print timestamp information. -v, --verbose Verbose, describe each field. @@ -379,7 +395,8 @@ Options: opts, args = getopt.getopt(sys.argv[1:], "bcd:e:f:hirstv", ['bsig', 'csig', 'dir=', 'entry=', 'format=', 'help', 'implicit', - 'readable', 'size', 'timestamp', 'verbose']) + 'raw', 'readable', + 'size', 'timestamp', 'verbose']) for o, a in opts: @@ -410,6 +427,8 @@ for o, a in opts: sys.exit(0) elif o in ('-i', '--implicit'): Print_Flags['implicit'] = 1 + elif o in ('--raw',): + Raw = 1 elif o in ('-r', '--readable'): Readable = 1 elif o in ('-s', '--size'): diff --git a/test/sconsign/script.py b/test/sconsign/script.py index 2c54e401..24bcc70c 100644 --- a/test/sconsign/script.py +++ b/test/sconsign/script.py @@ -111,7 +111,7 @@ test.write(['work1', 'sub2', 'inc2.h'], r"""\ #define STRING2 "inc2.h" """) -test.run(chdir = 'work1', arguments = '--debug=stacktrace --implicit-cache .') +test.run(chdir = 'work1', arguments = '--implicit-cache .') test.run_sconsign(arguments = "work1/sub1/.sconsign", stdout = """\ @@ -121,6 +121,14 @@ hello.obj: \S+ None \d+ \d+ hello.c: \S+ """) +test.run_sconsign(arguments = "--raw work1/sub1/.sconsign", + stdout = """\ +hello.exe: {'bsig': '\S+', 'size': \d+, 'timestamp': \d+} + hello.obj: \S+ +hello.obj: {'bsig': '\S+', 'size': \d+, 'timestamp': \d+} + hello.c: \S+ +""") + test.run_sconsign(arguments = "-v work1/sub1/.sconsign", stdout = """\ hello.exe: @@ -315,6 +323,22 @@ hello.obj: \S+ None \d+ \d+ inc2.h: \S+ """) +test.run_sconsign(arguments = "--raw work2/.sconsign", + stdout = """\ +=== sub1: +hello.exe: {'bsig': '\S+', 'size': \d+, 'timestamp': \d+} + hello.obj: \S+ +hello.obj: {'bsig': '\S+', 'size': \d+, 'timestamp': \d+} + hello.c: \S+ +=== sub2: +hello.exe: {'bsig': '\S+', 'size': \d+, 'timestamp': \d+} + hello.obj: \S+ +hello.obj: {'bsig': '\S+', 'size': \d+, 'timestamp': \d+} + hello.c: \S+ + inc1.h: \S+ + inc2.h: \S+ +""") + test.run_sconsign(arguments = "-v work2/.sconsign", stdout = """\ === sub1: @@ -477,11 +501,6 @@ time.sleep(1) test.run(chdir = 'work2', arguments = '. --max-drift=1') -expect = """\ -=== sub1: -hello.c: None \S+ \d+ \d+ -""" - test.run_sconsign(arguments = "-e hello.exe -e hello.obj -d sub1 -f dblite work2/my_sconsign", stdout = """\ === sub1: