Team Fortress 2 Source Code as on 22/4/2020
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

59 lines
1.7 KiB

  1. import sys, re, os, stat
  2. from ctypes import *
  3. if len( sys.argv ) < 3:
  4. print 'p4debugscan.py scans for debug DLLs in the last N revisions of a file in Perforce'
  5. print 'usage: p4debugscan.py filename N'
  6. print 'alt : p4debugscan.py filename -1 (will only look at filename on disk)'
  7. print 'ex : p4debugscan.py //valvegames/rel/hl2/game/bin/engine.dll 10'
  8. print ' (looks for debug versions in the past 10 revisions of engine.dll)'
  9. sys.exit( 1 )
  10. filename = sys.argv[1]
  11. nRevisions = sys.argv[2]
  12. if nRevisions == '-1':
  13. hdll = windll.kernel32.LoadLibraryA( filename )
  14. fn_addr = windll.kernel32.GetProcAddress( hdll, "BuiltDebug" )
  15. windll.kernel32.FreeLibrary( hdll )
  16. if fn_addr == 0:
  17. print '%s: RELEASE' % (filename)
  18. else:
  19. print '%s: DEBUG' % (filename)
  20. else:
  21. # Get the revisions list.
  22. f = os.popen( 'p4 changes -m %s %s' % (nRevisions, filename) )
  23. str = f.read()
  24. f.close()
  25. changelistNumbers = []
  26. myRE = re.compile( r'change (?P<num>\d+?) on (?P<date>.+?) ', re.IGNORECASE )
  27. while 1:
  28. m = myRE.search( str )
  29. if m:
  30. str = str[m.end():]
  31. changelistNumbers.append( [m.group('num'), m.group('date')] )
  32. else:
  33. break
  34. testDLLFilename = 'p4debugscan_test.dll'
  35. for x in changelistNumbers:
  36. os.system( 'p4 print -q -o %s %s@%s' % (testDLLFilename, filename, x[0]) )
  37. hdll = windll.kernel32.LoadLibraryA( testDLLFilename )
  38. fn_addr = windll.kernel32.GetProcAddress( hdll, "BuiltDebug" )
  39. windll.kernel32.FreeLibrary( hdll )
  40. if fn_addr == 0:
  41. print '%s: %s@%s - RELEASE' % (x[1], filename, x[0])
  42. else:
  43. print '%s: %s@%s - DEBUG' % (x[1], filename, x[0])
  44. os.chmod( testDLLFilename, stat.S_IWRITE | stat.S_IREAD )
  45. os.unlink( testDLLFilename )