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