diff -r 7c4a911dc066 -r 541af5ee3ed9 sbsv2/raptor/bin/buildstats.py --- a/sbsv2/raptor/bin/buildstats.py Fri Aug 13 14:59:05 2010 +0300 +++ b/sbsv2/raptor/bin/buildstats.py Wed Aug 18 17:23:33 2010 +0300 @@ -1,120 +1,120 @@ -# -# Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). -# All rights reserved. -# This component and the accompanying materials are made available -# under the terms of the License "Eclipse Public License v1.0" -# which accompanies this distribution, and is available -# at the URL "http://www.eclipse.org/legal/epl-v10.html". -# -# Initial Contributors: -# Nokia Corporation - initial contribution. -# -# Contributors: -# -# Description: -# Generate some useful statistics from a Raptor build log -# - -import sys -from optparse import OptionParser -from raptorlog import * -import os -from stat import * -import time - -def genstats(file, logitems, logdate): - bytecount=0.0 - lastbytecount=0.0 - print """ - - """ - - if S_ISREG(os.stat(file.name)[ST_MODE]) > 0: - totalbytes = os.stat(file.name)[ST_SIZE]+0.0 - else: - totalbytes=0.0 - - print "" % (file.name,totalbytes,logdate) - for l in file.xreadlines(): - if totalbytes > 0.0: - bytecount += len(l) - if (bytecount-lastbytecount)/totalbytes > 0.05: - lastbytecount = bytecount - sys.stderr.write("%3.0f %%" % ((bytecount/totalbytes)*100.0)) - - for i in logitems: - i.match(l) - - for i in logitems: - print i.xml()+"\n" - - print "" - print "" - - - -## Command Line Interface #################################################### - -parser = OptionParser(prog = "buildstats", - usage = "%prog [-h | options] []") - -parser.add_option("-k", "--keep", default = False, - action="store_true", dest="keep", help="Retain matched log lines and display them.") -parser.add_option("-d", "--logdate", default = None, - action="store", dest="logdate", help="Specify the date on which the log was started (yyyymmdd).") - -(options, args) = parser.parse_args() - -logname="stdin" -if len(args) > 0: - logname=args[0] - file = open(logname,"r") - if options.logdate != None: - logdate = options.logdate - else: - logdate = time.strftime("%Y%m%d",time.localtime(os.stat(file.name)[ST_CTIME])) -else: - file = sys.stdin - logdate = time.strftime("%Y%m%d") - - -if options.keep != False: - LogItem.keep = True - - - -logitems = [ - LogItem("compile attempt", ""), - LogItem("compile success", ""), - LogItem("compile fail", ""), - LogItem('link attempt',''), - LogItem("link success", ""), - LogItem("link fail", ""), - LogItem('postlink attempt',''), - LogItem("postlink success", ""), - LogItem("postlink fail", ""), - LogItem('flmcalls', '"), - #LogItem('bldinf_processed', "Processing bld.inf:"), - LogItem('armar','armar'), - LogItem("failed stringtable export", ""), - LogItem("failed template extension makefile", ""), - LogItem("make error",'^make: \*\*\*.*$', True), - LogItem("make no rule",'^make: \*\*\*.* No rule to make target.*$', True), - LogItem("raptor error",'^ERROR: raptor:*$', True), - LogItem("armcc/armcpp error",'^.*line [0-9]+:.*Error: *#[0-9]+.*$', True), - LogItem("gcc/gcc-cpp error",'^[^ \t]+:[0-9]+:[0-9]+ .+:.+$', True), - LogItem("armlink error",'^Error: *L[0-9A-F]+:.*$', True), - LogItem("Resource File error",'[\t ]*Error:.*cannot open source input file.*\.[Rr][Ss][Gg]\".*$', True), - LogItem("String Table error",'[\t ]*Error:.*cannot open source input file.*[Ss]tr[^ ]*\.h\".*$', True), - LogItem("Armcc license fail",'^.*Error: C3397E: Cannot obtain license for Compiler.*'), - LogItem("Armlink license fail",'^.*Error: ......: Cannot obtain license for .*ink.*') - ] - -genstats(file,logitems,logdate) - -if file != sys.stdin: - file.close() +# +# Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). +# All rights reserved. +# This component and the accompanying materials are made available +# under the terms of the License "Eclipse Public License v1.0" +# which accompanies this distribution, and is available +# at the URL "http://www.eclipse.org/legal/epl-v10.html". +# +# Initial Contributors: +# Nokia Corporation - initial contribution. +# +# Contributors: +# +# Description: +# Generate some useful statistics from a Raptor build log +# + +import sys +from optparse import OptionParser +from raptorlog import * +import os +from stat import * +import time + +def genstats(file, logitems, logdate): + bytecount=0.0 + lastbytecount=0.0 + print """ + + """ + + if S_ISREG(os.stat(file.name)[ST_MODE]) > 0: + totalbytes = os.stat(file.name)[ST_SIZE]+0.0 + else: + totalbytes=0.0 + + print "" % (file.name,totalbytes,logdate) + for l in file.xreadlines(): + if totalbytes > 0.0: + bytecount += len(l) + if (bytecount-lastbytecount)/totalbytes > 0.05: + lastbytecount = bytecount + sys.stderr.write("%3.0f %%" % ((bytecount/totalbytes)*100.0)) + + for i in logitems: + i.match(l) + + for i in logitems: + print i.xml()+"\n" + + print "" + print "" + + + +## Command Line Interface #################################################### + +parser = OptionParser(prog = "buildstats", + usage = "%prog [-h | options] []") + +parser.add_option("-k", "--keep", default = False, + action="store_true", dest="keep", help="Retain matched log lines and display them.") +parser.add_option("-d", "--logdate", default = None, + action="store", dest="logdate", help="Specify the date on which the log was started (yyyymmdd).") + +(options, args) = parser.parse_args() + +logname="stdin" +if len(args) > 0: + logname=args[0] + file = open(logname,"r") + if options.logdate != None: + logdate = options.logdate + else: + logdate = time.strftime("%Y%m%d",time.localtime(os.stat(file.name)[ST_CTIME])) +else: + file = sys.stdin + logdate = time.strftime("%Y%m%d") + + +if options.keep != False: + LogItem.keep = True + + + +logitems = [ + LogItem("compile attempt", ""), + LogItem("compile success", ""), + LogItem("compile fail", ""), + LogItem('link attempt',''), + LogItem("link success", ""), + LogItem("link fail", ""), + LogItem('postlink attempt',''), + LogItem("postlink success", ""), + LogItem("postlink fail", ""), + LogItem('flmcalls', '"), + #LogItem('bldinf_processed', "Processing bld.inf:"), + LogItem('armar','armar'), + LogItem("failed stringtable export", ""), + LogItem("failed template extension makefile", ""), + LogItem("make error",'^make: \*\*\*.*$', True), + LogItem("make no rule",'^make: \*\*\*.* No rule to make target.*$', True), + LogItem("raptor error",'^ERROR: raptor:*$', True), + LogItem("armcc/armcpp error",'^.*line [0-9]+:.*Error: *#[0-9]+.*$', True), + LogItem("gcc/gcc-cpp error",'^[^ \t]+:[0-9]+:[0-9]+ .+:.+$', True), + LogItem("armlink error",'^Error: *L[0-9A-F]+:.*$', True), + LogItem("Resource File error",'[\t ]*Error:.*cannot open source input file.*\.[Rr][Ss][Gg]\".*$', True), + LogItem("String Table error",'[\t ]*Error:.*cannot open source input file.*[Ss]tr[^ ]*\.h\".*$', True), + LogItem("Armcc license fail",'^.*Error: C3397E: Cannot obtain license for Compiler.*'), + LogItem("Armlink license fail",'^.*Error: ......: Cannot obtain license for .*ink.*') + ] + +genstats(file,logitems,logdate) + +if file != sys.stdin: + file.close()