sbsv2/raptor/bin/whatsource.py
changeset 0 044383f39525
child 3 e1eecf4d390d
equal deleted inserted replaced
-1:000000000000 0:044383f39525
       
     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 
       
    17 #!/bin/env python
       
    18 # What source files did the build try to build?
       
    19 
       
    20 import sys
       
    21 import re
       
    22 from  optparse import OptionParser
       
    23 from raptorlog import *
       
    24 
       
    25 
       
    26 def genstats(file, logitems):
       
    27 	linecount=0
       
    28 	print "<source>"
       
    29 	for l in file.xreadlines():
       
    30 		for i in logitems:
       
    31 			i.match(l)
       
    32 	print "</source>"
       
    33 
       
    34 
       
    35 ## Command Line Interface ####################################################
       
    36 
       
    37 parser = OptionParser(prog = "whatsource",
       
    38 	usage = "%prog [-h | options] logfile\nFind out what source files the compiler tried to build")
       
    39 
       
    40 (options, args) = parser.parse_args()
       
    41 
       
    42 logname="stdin"
       
    43 if len(args) > 0:
       
    44 	logname=args[0]
       
    45 	file = open(logname,"r")
       
    46 else:
       
    47 	file = sys.stdin
       
    48 
       
    49 
       
    50 compiler_invocations = [ 
       
    51 	LogItem("armcc usage",'\+ .*armcc.*-c', True, '[A-Za-z0-9_/\-\.]+\.cpp'),
       
    52 	] 
       
    53 
       
    54 genstats(file, compiler_invocations)
       
    55 
       
    56 if file != sys.stdin:
       
    57 	file.close()