whatsource.py 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. #
  2. # Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
  3. # All rights reserved.
  4. # This component and the accompanying materials are made available
  5. # under the terms of the License "Eclipse Public License v1.0"
  6. # which accompanies this distribution, and is available
  7. # at the URL "http://www.eclipse.org/legal/epl-v10.html".
  8. #
  9. # Initial Contributors:
  10. # Nokia Corporation - initial contribution.
  11. #
  12. # Contributors:
  13. #
  14. # Description:
  15. #
  16. #!/bin/env python
  17. # What source files did the build try to build?
  18. import sys
  19. import re
  20. from optparse import OptionParser
  21. from raptorlog import *
  22. def genstats(file, logitems):
  23. linecount=0
  24. print "<source>"
  25. for l in file.xreadlines():
  26. for i in logitems:
  27. i.match(l)
  28. print "</source>"
  29. ## Command Line Interface ####################################################
  30. parser = OptionParser(prog = "whatsource",
  31. usage = "%prog [-h | options] logfile\nFind out what source files the compiler tried to build")
  32. (options, args) = parser.parse_args()
  33. logname="stdin"
  34. if len(args) > 0:
  35. logname=args[0]
  36. file = open(logname,"r")
  37. else:
  38. file = sys.stdin
  39. compiler_invocations = [
  40. LogItem("armcc usage",'\+ .*armcc.*-c', True, '[A-Za-z0-9_/\-\.]+\.cpp'),
  41. ]
  42. genstats(file, compiler_invocations)
  43. if file != sys.stdin:
  44. file.close()