author | raptorbot <raptorbot@systemstesthead.symbian.intra> |
Fri, 18 Dec 2009 19:57:42 +0000 | |
branch | wip |
changeset 117 | ecf683438dc6 |
parent 115 | 5869e06bf2ac |
child 125 | dc823469fda2 |
permissions | -rw-r--r-- |
3 | 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 |
# Filter class for doing --what and --check operations |
|
16 |
# |
|
17 |
||
18 |
import os |
|
19 |
import sys |
|
20 |
import re |
|
21 |
import filter_interface |
|
22 |
||
23 |
class FilterWhat(filter_interface.Filter): |
|
24 |
||
114
35ed82e9d574
Strip epocroot off whatcomp filter output.
timothy.murphy@nokia.com
parents:
100
diff
changeset
|
25 |
def __init__(self): |
35ed82e9d574
Strip epocroot off whatcomp filter output.
timothy.murphy@nokia.com
parents:
100
diff
changeset
|
26 |
super(filter_interface.Filter,self).__init__(self) |
35ed82e9d574
Strip epocroot off whatcomp filter output.
timothy.murphy@nokia.com
parents:
100
diff
changeset
|
27 |
self.path_prefix_to_strip = None |
115
5869e06bf2ac
Cause whatcomp output to use the incoming epocroot value. i.e. if epocroot is relative then so is the what output.
timothy.murphy@nokia.com
parents:
114
diff
changeset
|
28 |
self.path_prefix_to_add_on = None |
3 | 29 |
|
30 |
def print_file(self, line, start, end): |
|
31 |
"Ensure DOS slashes on Windows" |
|
32 |
||
33 |
"""Use chars between enclosing tags ("<>", "''", etc) |
|
34 |
start = opening tag, so the line we need |
|
35 |
actually starts at 'start + 1' """ |
|
36 |
if "win" in self.buildparameters.platform: |
|
37 |
filename = line[(start + 1):end].replace("/","\\") |
|
38 |
else: |
|
39 |
filename = line[(start + 1):end] |
|
114
35ed82e9d574
Strip epocroot off whatcomp filter output.
timothy.murphy@nokia.com
parents:
100
diff
changeset
|
40 |
|
35ed82e9d574
Strip epocroot off whatcomp filter output.
timothy.murphy@nokia.com
parents:
100
diff
changeset
|
41 |
if self.path_prefix_to_strip: |
35ed82e9d574
Strip epocroot off whatcomp filter output.
timothy.murphy@nokia.com
parents:
100
diff
changeset
|
42 |
if filename.startswith(self.path_prefix_to_strip): |
35ed82e9d574
Strip epocroot off whatcomp filter output.
timothy.murphy@nokia.com
parents:
100
diff
changeset
|
43 |
filename = filename[len(self.path_prefix_to_strip):] |
115
5869e06bf2ac
Cause whatcomp output to use the incoming epocroot value. i.e. if epocroot is relative then so is the what output.
timothy.murphy@nokia.com
parents:
114
diff
changeset
|
44 |
if self.path_prefix_to_add_on != None: |
117
ecf683438dc6
Don't mess around with EPOCROOT until actually entering raptor so we know what the original was
raptorbot <raptorbot@systemstesthead.symbian.intra>
parents:
115
diff
changeset
|
45 |
filename = self.path_prefix_to_add_on + filename |
3 | 46 |
|
47 |
if self.check: |
|
48 |
if not os.path.isfile(filename): |
|
49 |
print "MISSING:", filename |
|
50 |
self.ok = False |
|
51 |
else: |
|
52 |
self.outfile.write(filename+"\n") |
|
53 |
||
9 | 54 |
self.prints += 1 |
93
572b3909c72f
RELEASE NOTE: Added new launchers for the sbs_filter program so that there is no longer a need to manually set the HOSTPLATFORM variable
timothy.murphy@nokia.com
parents:
9
diff
changeset
|
55 |
|
572b3909c72f
RELEASE NOTE: Added new launchers for the sbs_filter program so that there is no longer a need to manually set the HOSTPLATFORM variable
timothy.murphy@nokia.com
parents:
9
diff
changeset
|
56 |
def start_bldinf(self, bldinf): |
572b3909c72f
RELEASE NOTE: Added new launchers for the sbs_filter program so that there is no longer a need to manually set the HOSTPLATFORM variable
timothy.murphy@nokia.com
parents:
9
diff
changeset
|
57 |
pass |
572b3909c72f
RELEASE NOTE: Added new launchers for the sbs_filter program so that there is no longer a need to manually set the HOSTPLATFORM variable
timothy.murphy@nokia.com
parents:
9
diff
changeset
|
58 |
|
572b3909c72f
RELEASE NOTE: Added new launchers for the sbs_filter program so that there is no longer a need to manually set the HOSTPLATFORM variable
timothy.murphy@nokia.com
parents:
9
diff
changeset
|
59 |
def end_bldinf(self): |
572b3909c72f
RELEASE NOTE: Added new launchers for the sbs_filter program so that there is no longer a need to manually set the HOSTPLATFORM variable
timothy.murphy@nokia.com
parents:
9
diff
changeset
|
60 |
pass |
9 | 61 |
|
3 | 62 |
|
63 |
def open(self, build_parameters): |
|
64 |
"initialise" |
|
65 |
||
66 |
self.buildparameters = build_parameters |
|
67 |
self.check = build_parameters.doCheck |
|
68 |
self.what = build_parameters.doWhat |
|
69 |
||
70 |
self.outfile = sys.stdout |
|
71 |
self.outfile_close = False |
|
72 |
||
73 |
if "FILTERWHAT_FILE" in os.environ: |
|
74 |
try: |
|
75 |
self.outfile = open(os.environ['FILTERWHAT_FILE'],"w+") |
|
76 |
self.outfile_close = True |
|
77 |
except Exception,e: |
|
78 |
raise Exception("The 'What Filter' could not open the output file specified in the FILTER_WHAT environment variable: " + os.environ['FILTERWHAT_FILE']) |
|
79 |
||
80 |
# repetitions is for tracking repeated lines in the output log |
|
81 |
# when --check and --what are called |
|
82 |
self.repetitions = {} |
|
83 |
||
84 |
"Regex for old what output" |
|
85 |
if "win" in self.buildparameters.platform: |
|
86 |
self.regex = re.compile("^[a-zA-Z]:\S+$") |
|
87 |
else: |
|
88 |
self.regex = re.compile("^/\S+$") |
|
89 |
||
90 |
"Regex for targets" |
|
91 |
self.target_regex = re.compile("^<(build|stringtable|resource|bitmap)>.*") |
|
92 |
||
93 |
"Regex for exports" |
|
94 |
self.export_regex = re.compile("^<export destination.*") |
|
95 |
||
96 |
"Regex for zip exports" |
|
97 |
self.zip_export_regex = re.compile("^<member>.*") |
|
93
572b3909c72f
RELEASE NOTE: Added new launchers for the sbs_filter program so that there is no longer a need to manually set the HOSTPLATFORM variable
timothy.murphy@nokia.com
parents:
9
diff
changeset
|
98 |
|
572b3909c72f
RELEASE NOTE: Added new launchers for the sbs_filter program so that there is no longer a need to manually set the HOSTPLATFORM variable
timothy.murphy@nokia.com
parents:
9
diff
changeset
|
99 |
"Regex for determining bld.inf name" |
572b3909c72f
RELEASE NOTE: Added new launchers for the sbs_filter program so that there is no longer a need to manually set the HOSTPLATFORM variable
timothy.murphy@nokia.com
parents:
9
diff
changeset
|
100 |
self.whatlog_regex = re.compile("^<whatlog *bldinf='(?P<bldinf>[^']*)'.*") |
572b3909c72f
RELEASE NOTE: Added new launchers for the sbs_filter program so that there is no longer a need to manually set the HOSTPLATFORM variable
timothy.murphy@nokia.com
parents:
9
diff
changeset
|
101 |
self.current_bldinf = '' |
3 | 102 |
|
9 | 103 |
self.prints = 0 |
3 | 104 |
self.ok = True |
105 |
return self.ok |
|
106 |
||
107 |
def write(self, text): |
|
108 |
"process some log text" |
|
109 |
||
110 |
for line in text.splitlines(): |
|
111 |
line = line.rstrip() |
|
112 |
||
9 | 113 |
# we are normally the ONLY filter running so we have to pass on |
114 |
# any errors and warnings that emerge |
|
115 |
# |
|
116 |
if line.startswith("<error"): |
|
117 |
sys.stderr.write(self.formatError(line)) |
|
118 |
self.ok = False |
|
119 |
continue |
|
120 |
if line.startswith("<warning"): |
|
121 |
sys.stderr.write(self.formatWarning(line)) |
|
122 |
continue |
|
123 |
||
3 | 124 |
if not line in self.repetitions: |
125 |
self.repetitions[line] = 0 |
|
126 |
||
127 |
if self.repetitions[line] == 0: |
|
93
572b3909c72f
RELEASE NOTE: Added new launchers for the sbs_filter program so that there is no longer a need to manually set the HOSTPLATFORM variable
timothy.murphy@nokia.com
parents:
9
diff
changeset
|
128 |
|
3 | 129 |
if self.regex.match(line) and (self.what or self.check): |
130 |
"Print the whole line" |
|
131 |
self.print_file(line, (-1), len(line)) |
|
132 |
||
133 |
if self.target_regex.match(line): |
|
134 |
"Grab the filename between <build> and </build>" |
|
135 |
start = line.find(">") |
|
136 |
end = line.rfind("<") |
|
137 |
||
138 |
self.print_file(line, start, end) |
|
139 |
||
140 |
elif self.export_regex.match(line): |
|
141 |
"Grab the filename between the first set of '' chars" |
|
142 |
start = line.find("'") |
|
143 |
end = line.find("'", (start + 1)) |
|
144 |
||
145 |
self.print_file(line, start, end) |
|
146 |
||
147 |
elif self.zip_export_regex.match(line): |
|
148 |
"Grab the filename between <member> and </member>" |
|
149 |
start = line.find(">") |
|
150 |
end = line.rfind("<") |
|
151 |
||
152 |
self.print_file(line, start, end) |
|
93
572b3909c72f
RELEASE NOTE: Added new launchers for the sbs_filter program so that there is no longer a need to manually set the HOSTPLATFORM variable
timothy.murphy@nokia.com
parents:
9
diff
changeset
|
153 |
|
572b3909c72f
RELEASE NOTE: Added new launchers for the sbs_filter program so that there is no longer a need to manually set the HOSTPLATFORM variable
timothy.murphy@nokia.com
parents:
9
diff
changeset
|
154 |
else: |
572b3909c72f
RELEASE NOTE: Added new launchers for the sbs_filter program so that there is no longer a need to manually set the HOSTPLATFORM variable
timothy.murphy@nokia.com
parents:
9
diff
changeset
|
155 |
"work out what the 'current' bldinf file is" |
572b3909c72f
RELEASE NOTE: Added new launchers for the sbs_filter program so that there is no longer a need to manually set the HOSTPLATFORM variable
timothy.murphy@nokia.com
parents:
9
diff
changeset
|
156 |
m = self.whatlog_regex.match(line) |
572b3909c72f
RELEASE NOTE: Added new launchers for the sbs_filter program so that there is no longer a need to manually set the HOSTPLATFORM variable
timothy.murphy@nokia.com
parents:
9
diff
changeset
|
157 |
if m: |
572b3909c72f
RELEASE NOTE: Added new launchers for the sbs_filter program so that there is no longer a need to manually set the HOSTPLATFORM variable
timothy.murphy@nokia.com
parents:
9
diff
changeset
|
158 |
bi = m.groupdict()['bldinf'] |
572b3909c72f
RELEASE NOTE: Added new launchers for the sbs_filter program so that there is no longer a need to manually set the HOSTPLATFORM variable
timothy.murphy@nokia.com
parents:
9
diff
changeset
|
159 |
if self.current_bldinf != bi: |
572b3909c72f
RELEASE NOTE: Added new launchers for the sbs_filter program so that there is no longer a need to manually set the HOSTPLATFORM variable
timothy.murphy@nokia.com
parents:
9
diff
changeset
|
160 |
if self.current_bldinf != '': |
572b3909c72f
RELEASE NOTE: Added new launchers for the sbs_filter program so that there is no longer a need to manually set the HOSTPLATFORM variable
timothy.murphy@nokia.com
parents:
9
diff
changeset
|
161 |
self.end_bldinf() |
572b3909c72f
RELEASE NOTE: Added new launchers for the sbs_filter program so that there is no longer a need to manually set the HOSTPLATFORM variable
timothy.murphy@nokia.com
parents:
9
diff
changeset
|
162 |
self.current_bldinf = bi |
100 | 163 |
if bi != '': |
164 |
self.start_bldinf(bi) |
|
93
572b3909c72f
RELEASE NOTE: Added new launchers for the sbs_filter program so that there is no longer a need to manually set the HOSTPLATFORM variable
timothy.murphy@nokia.com
parents:
9
diff
changeset
|
165 |
|
572b3909c72f
RELEASE NOTE: Added new launchers for the sbs_filter program so that there is no longer a need to manually set the HOSTPLATFORM variable
timothy.murphy@nokia.com
parents:
9
diff
changeset
|
166 |
|
3 | 167 |
|
168 |
self.repetitions[line] += 1 |
|
169 |
||
170 |
return self.ok |
|
171 |
||
9 | 172 |
def summary(self): |
173 |
if self.prints == 0: |
|
174 |
if self.what: |
|
175 |
message = "no WHAT information found" |
|
176 |
else: |
|
177 |
message = "no CHECK information found" |
|
178 |
||
179 |
sys.stderr.write(self.formatError(message)) |
|
180 |
self.ok = False |
|
181 |
return self.ok |
|
182 |
||
3 | 183 |
def close(self): |
184 |
if self.outfile_close: |
|
185 |
self.outfile.close() |
|
186 |
return self.ok |
|
187 |
||
188 |