failedstats.py 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  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. """
  53. Considering target file `/var/local/net/smb/tmurphy/pf/mcloverlay/common/generic/COMMS-INFRAS/ESOCK/commsdataobjects/src/provinfoqueryset.cpp'.
  54. Finished prerequisites of target file `/var/local/net/smb/tmurphy/pf/mcloverlay/common/generic/COMMS-INFRAS/ESOC
  55. K/commsdataobjects/src/provinfoqueryset.cpp'.
  56. """
  57. # The output is a filename followed by a number. If the number is 0
  58. # Then the prerequisites that file now exist.
  59. # If > 0 then the prerequisites for that file could not be completed.
  60. import sys
  61. from optparse import OptionParser
  62. import re
  63. import os
  64. from stat import *
  65. def findfailed(file):
  66. """ Find unbuilt files and prioritise them.
  67. Higher numbers go to files that didn't fail because
  68. of prerequisites.
  69. Rationale: files that failed because their prerequisites
  70. failed are worth knowing about but cannot themselves be addressed.
  71. """
  72. filecount = {}
  73. extre = re.compile(".*\.(?P<ext>[^'\/\"]+)$", re.I)
  74. startre = re.compile("[\t ]*File `(?P<file>[^']*)\' does not exist.*", re.I)
  75. zerore = re.compile("[\t ]*Successfully remade target file `(?P<file>[^']*)'\..*", re.I)
  76. #endre = re.compile("[\t ]*Finished prerequisites of target file `(?P<file>[^']*)'\..*", re.I)
  77. endre = re.compile("[\t ]*Giving up on target file `(?P<file>[^']*)'\..*", re.I)
  78. for x in file.readlines():
  79. g = startre.match(x)
  80. if g is not None:
  81. filename = g.group('file').strip('"')
  82. eg = extre.match(filename)
  83. if eg is not None:
  84. filecount[filename] = [1, eg.group('ext')]
  85. else:
  86. filecount[filename] = [1, "none"]
  87. else:
  88. g = zerore.match(x)
  89. if g is not None:
  90. # Complete success - not interesting.
  91. filename = g.group('file').strip('"')
  92. if filename in filecount:
  93. del filecount[filename]
  94. else:
  95. g = endre.match(x)
  96. if g is not None:
  97. # did manage to make the prerequisites, perhaps not the file
  98. filename = g.group('file').strip('"')
  99. if filename in filecount:
  100. filecount[filename][0] = 2
  101. return filecount
  102. def showtargets(targets,prereq):
  103. output=[]
  104. for k in targets:
  105. l = "%s\t%i\t%s" % (targets[k][1], targets[k][0], k)
  106. if prereq:
  107. if targets[k][0] == 2:
  108. # There were missing pre-requisites
  109. output.append(l)
  110. else:
  111. output.append(l)
  112. output.sort()
  113. for o in output:
  114. sys.stdout.write("%s\n" % o)
  115. def readmake(file):
  116. rule = re.compile("^[^ :$]*:[^=]", re.I)
  117. for x in file.readlines():
  118. g = startre.match(x)
  119. if g is not None:
  120. filename = g.group('file').strip('"')
  121. eg = extre.match(filename)
  122. if eg is not None:
  123. ext = eg.group('ext')
  124. else:
  125. ext = "none"
  126. parser = OptionParser(prog = "matchmade",
  127. usage = "%prog [-h | options] [ -d make database filename ] logfile")
  128. parser.add_option("-m", "--missing-prerequistes", default = False,
  129. action="store_true", dest="missing", help="List those targets whose pre-requisites could not be found or made")
  130. parser.add_option("-d","--make-db",action="store",dest="makedb",
  131. help="name of make database")
  132. (options, args) = parser.parse_args()
  133. logname="stdin"
  134. if len(args) > 0:
  135. logname=args[0]
  136. file = open(logname,"r")
  137. else:
  138. file = sys.stdin
  139. showtargets(findfailed(file),options.missing)
  140. #assistmake(file,options.missing)
  141. if file != sys.stdin:
  142. file.close()