Changeset 829 for trunk/ithildin/build/sconsign.py
- Timestamp:
- 12/21/08 16:04:24 (3 years ago)
- File:
-
- 1 edited
-
trunk/ithildin/build/sconsign.py (modified) (18 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ithildin/build/sconsign.py
r805 r829 3 3 # SCons - a Software Constructor 4 4 # 5 # Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007 The SCons Foundation5 # Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 The SCons Foundation 6 6 # 7 7 # Permission is hereby granted, free of charge, to any person obtaining … … 25 25 # 26 26 27 __revision__ = " /home/scons/scons/branch.0/baseline/src/script/sconsign.py 0.97.D001 2007/05/17 11:35:19 knight"28 29 __version__ = " 0.97"30 31 __build__ = " D001"32 33 __buildsys__ = " roxbury"34 35 __date__ = "200 7/05/17 11:35:19"36 37 __developer__ = " knight"27 __revision__ = "src/script/sconsign.py 3842 2008/12/20 22:59:52 scons" 28 29 __version__ = "1.2.0" 30 31 __build__ = "r3842" 32 33 __buildsys__ = "scons-dev" 34 35 __date__ = "2008/12/20 22:59:52" 36 37 __developer__ = "scons" 38 38 39 39 import os … … 68 68 libs.append(os.environ["SCONS_LIB_DIR"]) 69 69 70 local = 'scons-local-' + __version__ 70 local_version = 'scons-local-' + __version__ 71 local = 'scons-local' 71 72 if script_dir: 73 local_version = os.path.join(script_dir, local_version) 72 74 local = os.path.join(script_dir, local) 75 libs.append(os.path.abspath(local_version)) 73 76 libs.append(os.path.abspath(local)) 74 77 … … 139 142 pass 140 143 else: 141 while libpath: 142 libpath, tail = os.path.split(libpath) 143 if tail[:6] == "python": 144 break 145 if libpath: 146 # Python library is in /usr/libfoo/python*; 147 # check /usr/libfoo/scons*. 148 prefs.append(libpath) 144 # Split /usr/libfoo/python*/os.py to /usr/libfoo/python*. 145 libpath, tail = os.path.split(libpath) 146 # Split /usr/libfoo/python* to /usr/libfoo 147 libpath, tail = os.path.split(libpath) 148 # Check /usr/libfoo/scons*. 149 prefs.append(libpath) 149 150 150 151 # Look first for 'scons-__version__' in all of our preference libs, … … 204 205 Verbose = 0 205 206 Readable = 0 206 Raw = 0207 207 208 208 def default_mapper(entry, name): … … 212 212 val = None 213 213 return str(val) 214 215 def map_action(entry, name): 216 try: 217 bact = entry.bact 218 bactsig = entry.bactsig 219 except AttributeError: 220 return None 221 return '%s [%s]' % (bactsig, bact) 214 222 215 223 def map_timestamp(entry, name): … … 231 239 result = [] 232 240 for i in xrange(len(bkids)): 233 result.append( "%s: %s" % (bkids[i], bkidsigs[i]))241 result.append(nodeinfo_string(bkids[i], bkidsigs[i], " ")) 234 242 if result == []: 235 243 return None … … 237 245 238 246 map_field = { 247 'action' : map_action, 239 248 'timestamp' : map_timestamp, 240 249 'bkids' : map_bkids, … … 256 265 257 266 def nodeinfo_raw(name, ninfo, prefix=""): 258 # This does essentially what the pprint module does,259 # except that it sorts the keysfor deterministic output.267 # This just formats the dictionary, which we would normally use str() 268 # to do, except that we want the keys sorted for deterministic output. 260 269 d = ninfo.__dict__ 261 keys = d.keys() 262 keys.sort() 270 try: 271 keys = ninfo.field_list + ['_version_id'] 272 except AttributeError: 273 keys = d.keys() 274 keys.sort() 263 275 l = [] 264 276 for k in keys: 265 l.append('%s: %s' % (repr(k), repr(d[k]))) 277 l.append('%s: %s' % (repr(k), repr(d.get(k)))) 278 if '\n' in name: 279 name = repr(name) 266 280 return name + ': {' + string.join(l, ', ') + '}' 267 281 268 def nodeinfo_string(name, ninfo, prefix=""): 269 fieldlist = ["bsig", "csig", "timestamp", "size"] 282 def nodeinfo_cooked(name, ninfo, prefix=""): 283 try: 284 field_list = ninfo.field_list 285 except AttributeError: 286 field_list = [] 270 287 f = lambda x, ni=ninfo, v=Verbose: field(x, ni, v) 271 outlist = [name+":"] + filter(None, map(f, fieldlist)) 288 if '\n' in name: 289 name = repr(name) 290 outlist = [name+':'] + filter(None, map(f, field_list)) 272 291 if Verbose: 273 sep = "\n "+ prefix274 else: 275 sep = " "292 sep = '\n ' + prefix 293 else: 294 sep = ' ' 276 295 return string.join(outlist, sep) 277 296 297 nodeinfo_string = nodeinfo_cooked 298 278 299 def printfield(name, entry, prefix=""): 279 if Raw:280 print nodeinfo_raw(name, entry.ninfo, prefix)281 else:282 print nodeinfo_string(name, entry.ninfo, prefix)283 284 300 outlist = field("implicit", entry, 0) 285 301 if outlist: … … 287 303 print " implicit:" 288 304 print " " + outlist 289 290 def printentries(entries): 305 outact = field("action", entry, 0) 306 if outact: 307 if Verbose: 308 print " action: " + outact 309 else: 310 print " " + outact 311 312 def printentries(entries, location): 291 313 if Print_Entries: 292 314 for name in Print_Entries: … … 294 316 entry = entries[name] 295 317 except KeyError: 296 sys.stderr.write("sconsign: no entry `%s' in `%s'\n" % (name, args[0]))318 sys.stderr.write("sconsign: no entry `%s' in `%s'\n" % (name, location)) 297 319 else: 298 printfield(name, entry) 320 try: 321 ninfo = entry.ninfo 322 except AttributeError: 323 print name + ":" 324 else: 325 print nodeinfo_string(name, entry.ninfo) 326 printfield(name, entry.binfo) 299 327 else: 300 328 names = entries.keys() 301 329 names.sort() 302 330 for name in names: 303 printfield(name, entries[name]) 331 entry = entries[name] 332 try: 333 ninfo = entry.ninfo 334 except AttributeError: 335 print name + ":" 336 else: 337 print nodeinfo_string(name, entry.ninfo) 338 printfield(name, entry.binfo) 304 339 305 340 class Do_SConsignDB: … … 339 374 sys.stderr.write("sconsign: %s\n" % (print_e)) 340 375 return 341 except: 376 except KeyboardInterrupt: 377 raise 378 except cPickle.UnpicklingError: 342 379 sys.stderr.write("sconsign: ignoring invalid `%s' file `%s'\n" % (self.dbm_name, fname)) 380 return 381 except Exception, e: 382 sys.stderr.write("sconsign: ignoring invalid `%s' file `%s': %s\n" % (self.dbm_name, fname, e)) 343 383 return 344 384 … … 359 399 def printentries(self, dir, val): 360 400 print '=== ' + dir + ':' 361 printentries(cPickle.loads(val) )401 printentries(cPickle.loads(val), dir) 362 402 363 403 def Do_SConsignDir(name): … … 369 409 try: 370 410 sconsign = SCons.SConsign.Dir(fp) 371 except: 372 sys.stderr.write("sconsign: ignoring invalid .sconsign file `%s'\n" % name) 411 except KeyboardInterrupt: 412 raise 413 except cPickle.UnpicklingError: 414 sys.stderr.write("sconsign: ignoring invalid .sconsign file `%s'\n" % (name)) 373 415 return 374 printentries(sconsign.entries) 416 except Exception, e: 417 sys.stderr.write("sconsign: ignoring invalid .sconsign file `%s': %s\n" % (name, e)) 418 return 419 printentries(sconsign.entries, args[0]) 375 420 376 421 ############################################################################## … … 381 426 Usage: sconsign [OPTIONS] FILE [...] 382 427 Options: 383 - b, --bsig Print build signatureinformation.428 -a, --act, --action Print build action information. 384 429 -c, --csig Print content signature information. 385 430 -d DIR, --dir=DIR Print only info about DIR. … … 395 440 """ 396 441 397 opts, args = getopt.getopt(sys.argv[1:], "bcd:e:f:hirstv", 398 ['bsig', 'csig', 'dir=', 'entry=', 442 opts, args = getopt.getopt(sys.argv[1:], "acd:e:f:hirstv", 443 ['act', 'action', 444 'csig', 'dir=', 'entry=', 399 445 'format=', 'help', 'implicit', 400 446 'raw', 'readable', … … 403 449 404 450 for o, a in opts: 405 if o in ('- b', '--bsig'):406 Print_Flags[' bsig'] = 1451 if o in ('-a', '--act', '--action'): 452 Print_Flags['action'] = 1 407 453 elif o in ('-c', '--csig'): 408 454 Print_Flags['csig'] = 1 … … 431 477 Print_Flags['implicit'] = 1 432 478 elif o in ('--raw',): 433 Raw = 1479 nodeinfo_string = nodeinfo_raw 434 480 elif o in ('-r', '--readable'): 435 481 Readable = 1
Note: See TracChangeset
for help on using the changeset viewer.
