sbsv2/raptor/bin/mkgetfailed.py
changeset 0 044383f39525
child 3 e1eecf4d390d
equal deleted inserted replaced
-1:000000000000 0:044383f39525
       
     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 
       
    23  File `fred.exe' does not exist.
       
    24   Considering target file `fred.in'.
       
    25    File `fred.in' does not exist.
       
    26     Considering target file `a.o'.
       
    27      File `a.o' does not exist.
       
    28       Considering target file `a.c'.
       
    29        Finished prerequisites of target file `a.c'.
       
    30       No need to remake target `a.c'.
       
    31       Pruning file `a.c'.
       
    32      Finished prerequisites of target file `a.o'.
       
    33     Must remake target `a.o'.
       
    34 cc    -c -o a.o a.c
       
    35     Successfully remade target file `a.o'.
       
    36     Considering target file `b.o'.
       
    37      File `b.o' does not exist.
       
    38       Considering target file `b.c'.
       
    39        Finished prerequisites of target file `b.c'.
       
    40       No need to remake target `b.c'.
       
    41       Pruning file `b.c'.
       
    42      Finished prerequisites of target file `b.o'.
       
    43     Must remake target `b.o'.
       
    44 cc    -c -o b.o b.c
       
    45     Successfully remade target file `b.o'.
       
    46    Finished prerequisites of target file `fred.in'.
       
    47   Must remake target `fred.in'.
       
    48   Successfully remade target file `fred.in'.
       
    49  Finished prerequisites of target file `fred.exe'.
       
    50 Must remake target `fred.exe'.
       
    51 Successfully remade target file `fred.exe'.
       
    52 """
       
    53 
       
    54 # The output is a filename followed by a number.  If the number is 0
       
    55 # Then the prerequisites that file now exist.
       
    56 # If > 0 then the prerequisites for that file could not be completed.
       
    57 
       
    58 import sys
       
    59 from  optparse import OptionParser
       
    60 import re
       
    61 import os
       
    62 from stat import *
       
    63 
       
    64 def genstats(file,showmissing):
       
    65 	filecount = {}
       
    66 	startre = re.compile("[\t ]*File `(?P<file>[^']*)' does not exist")
       
    67 	endre = re.compile("[\t ]*Finished prerequisites of target file `(?P<file>[^']*)'\..*")
       
    68 	for x in file.readlines():
       
    69 		g = startre.match(x)
       
    70 		if g is not None:
       
    71 			filename = g.group('file')
       
    72 			try:
       
    73 				filecount[filename] += 1
       
    74 			except KeyError:
       
    75 				filecount[filename] = 1
       
    76 		else:
       
    77 			g = endre.match(x)
       
    78 			if g is not None:
       
    79 				filename = g.group('file')
       
    80 				try:
       
    81 					filecount[filename] -= 1
       
    82 				except KeyError:
       
    83 					filecount[filename] = 0
       
    84 	
       
    85 	for k in filecount:
       
    86 		if showmissing:
       
    87 			if filecount[k] > 0:
       
    88 				print "%s: %i" % (k,filecount[k])
       
    89 		else:
       
    90 			print "%s: %i" % (k,filecount[k])
       
    91 
       
    92 
       
    93 parser = OptionParser(prog = "matchmade",
       
    94 	usage = "%prog [-h | options] logfile")
       
    95 
       
    96 parser.add_option("-m", "--missing-prerequistes", default = False,
       
    97 	 action="store_true", dest="missing", help="List those targets whose pre-requisites could not be found or made") 
       
    98 
       
    99 (options, args) = parser.parse_args()
       
   100 
       
   101 logname="stdin"
       
   102 if len(args) > 0:
       
   103 	logname=args[0]
       
   104 	file = open(logname,"r")
       
   105 else:
       
   106 	file = sys.stdin
       
   107 
       
   108 genstats(file,options.missing)
       
   109 
       
   110 if file != sys.stdin:
       
   111 	file.close()