mkgetfailed.py 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. #
  2. # Copyright (c) 2007-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. # Generate some useful statistics from a Raptor build log
  16. # Work out what was specified to make but not built even if
  17. # it was not mentioned in the make error output because some
  18. # child's dependency was not satisfied.
  19. # Needs raptor --tracking option to set make to use -debug=v
  20. # An example bit of make output that can be analysed:
  21. #
  22. File `fred.exe' does not exist.
  23. Considering target file `fred.in'.
  24. File `fred.in' does not exist.
  25. Considering target file `a.o'.
  26. File `a.o' does not exist.
  27. Considering target file `a.c'.
  28. Finished prerequisites of target file `a.c'.
  29. No need to remake target `a.c'.
  30. Pruning file `a.c'.
  31. Finished prerequisites of target file `a.o'.
  32. Must remake target `a.o'.
  33. cc -c -o a.o a.c
  34. Successfully remade target file `a.o'.
  35. Considering target file `b.o'.
  36. File `b.o' does not exist.
  37. Considering target file `b.c'.
  38. Finished prerequisites of target file `b.c'.
  39. No need to remake target `b.c'.
  40. Pruning file `b.c'.
  41. Finished prerequisites of target file `b.o'.
  42. Must remake target `b.o'.
  43. cc -c -o b.o b.c
  44. Successfully remade target file `b.o'.
  45. Finished prerequisites of target file `fred.in'.
  46. Must remake target `fred.in'.
  47. Successfully remade target file `fred.in'.
  48. Finished prerequisites of target file `fred.exe'.
  49. Must remake target `fred.exe'.
  50. Successfully remade target file `fred.exe'.
  51. """
  52. # The output is a filename followed by a number. If the number is 0
  53. # Then the prerequisites that file now exist.
  54. # If > 0 then the prerequisites for that file could not be completed.
  55. import sys
  56. from optparse import OptionParser
  57. import re
  58. import os
  59. from stat import *
  60. def genstats(file,showmissing):
  61. filecount = {}
  62. startre = re.compile("[\t ]*File `(?P<file>[^']*)' does not exist")
  63. endre = re.compile("[\t ]*Finished prerequisites of target file `(?P<file>[^']*)'\..*")
  64. for x in file.readlines():
  65. g = startre.match(x)
  66. if g is not None:
  67. filename = g.group('file')
  68. try:
  69. filecount[filename] += 1
  70. except KeyError:
  71. filecount[filename] = 1
  72. else:
  73. g = endre.match(x)
  74. if g is not None:
  75. filename = g.group('file')
  76. try:
  77. filecount[filename] -= 1
  78. except KeyError:
  79. filecount[filename] = 0
  80. for k in filecount:
  81. if showmissing:
  82. if filecount[k] > 0:
  83. print "%s: %i" % (k,filecount[k])
  84. else:
  85. print "%s: %i" % (k,filecount[k])
  86. parser = OptionParser(prog = "matchmade",
  87. usage = "%prog [-h | options] logfile")
  88. parser.add_option("-m", "--missing-prerequistes", default = False,
  89. action="store_true", dest="missing", help="List those targets whose pre-requisites could not be found or made")
  90. (options, args) = parser.parse_args()
  91. logname="stdin"
  92. if len(args) > 0:
  93. logname=args[0]
  94. file = open(logname,"r")
  95. else:
  96. file = sys.stdin
  97. genstats(file,options.missing)
  98. if file != sys.stdin:
  99. file.close()