217
|
1 |
<?xml version="1.0" encoding="UTF-8"?>
|
|
2 |
<!--
|
|
3 |
============================================================================
|
|
4 |
Name : logging.ant.xml
|
|
5 |
Part of : Helium
|
|
6 |
|
|
7 |
Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
|
8 |
All rights reserved.
|
|
9 |
This component and the accompanying materials are made available
|
|
10 |
under the terms of the License "Eclipse Public License v1.0"
|
|
11 |
which accompanies this distribution, and is available
|
|
12 |
at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
13 |
|
|
14 |
Initial Contributors:
|
|
15 |
Nokia Corporation - initial contribution.
|
|
16 |
|
|
17 |
Contributors:
|
|
18 |
|
|
19 |
Description:
|
|
20 |
|
|
21 |
============================================================================
|
|
22 |
-->
|
|
23 |
<!--* @package framework -->
|
|
24 |
<project name="logging" xmlns:hlm="http://www.nokia.com/helium">
|
|
25 |
<description>
|
628
|
26 |
Targets related to log parsing, rendering, upload to diamonds etc.
|
217
|
27 |
</description>
|
|
28 |
|
|
29 |
<!-- This is where the preparation build logs are stored.
|
|
30 |
@type string
|
|
31 |
@scope private
|
|
32 |
-->
|
|
33 |
<property name="prep.log.dir" location="${build.log.dir}/prep"/>
|
|
34 |
<!-- This is where the compile logs are stored.
|
|
35 |
@type string
|
|
36 |
@scope private
|
|
37 |
-->
|
|
38 |
<property name="compile.log.dir" location="${build.log.dir}/compile"/>
|
|
39 |
<!-- This is where the ats test logs are stored.
|
|
40 |
@type string
|
|
41 |
@scope private
|
|
42 |
-->
|
|
43 |
<property name="test.log.dir" location="${build.log.dir}/test"/>
|
|
44 |
<!-- This is where the archive logs are stored.
|
|
45 |
@type string
|
|
46 |
@scope private
|
|
47 |
-->
|
|
48 |
<property name="archive.log.dir" location="${build.log.dir}/archive"/>
|
|
49 |
<!-- This is where the roms logs are stored.
|
|
50 |
@type string
|
|
51 |
@scope private
|
|
52 |
-->
|
|
53 |
<property name="roms.log.dir" location="${build.log.dir}/roms"/>
|
|
54 |
<!-- This is where the post build logs are stored.
|
|
55 |
@type string
|
|
56 |
@scope private
|
|
57 |
-->
|
|
58 |
<property name="post.log.dir" location="${build.log.dir}/post"/>
|
|
59 |
<!-- This is where the localisation logs are stored.
|
|
60 |
@type string
|
|
61 |
@scope private
|
|
62 |
-->
|
|
63 |
<property name="localisation.log.dir" location="${build.log.dir}/localisation"/>
|
|
64 |
|
|
65 |
<!-- Macro to record content to a separate log file without recording in the main log. -->
|
|
66 |
<macrodef name="recordStartMacro" uri="http://www.nokia.com/helium">
|
|
67 |
<attribute name="name"/>
|
|
68 |
<attribute name="emacsmode" default="false"/>
|
|
69 |
<sequential>
|
|
70 |
<if>
|
|
71 |
<available file="${build.log.dir}" type="dir"/>
|
|
72 |
<then>
|
|
73 |
<hlm:record name="${build.log.dir}/@{name}" action="start" append="true" emacsmode="@{emacsmode}" loglevel="${ant.loglevel}"/>
|
|
74 |
</then>
|
|
75 |
</if>
|
|
76 |
</sequential>
|
|
77 |
</macrodef>
|
|
78 |
|
|
79 |
|
|
80 |
<!-- Macro to stop recording content to a separate log file without recording in the main log. -->
|
|
81 |
<macrodef name="recordStopMacro" uri="http://www.nokia.com/helium">
|
|
82 |
<attribute name="name"/>
|
|
83 |
<sequential>
|
|
84 |
<if>
|
|
85 |
<available file="${build.log.dir}/@{name}"/>
|
|
86 |
<then>
|
|
87 |
<hlm:record name="${build.log.dir}/@{name}" action="stop" append="true"/>
|
|
88 |
</then>
|
|
89 |
</if>
|
|
90 |
</sequential>
|
|
91 |
</macrodef>
|
|
92 |
|
|
93 |
|
|
94 |
<!--Macro to stop recording to the main log file (if present) and record to
|
|
95 |
a separate log file that is filtered after logging is stopped. -->
|
|
96 |
<macrodef name="filterRecordStartMacro" uri="http://www.nokia.com/helium">
|
|
97 |
<attribute name="pattern" default=""/>
|
|
98 |
<attribute name="category" default=""/>
|
|
99 |
<sequential>
|
|
100 |
<hlm:record name="${build.cache.log.dir}/temp_ant_build.log" action="start" loglevel="${ant.loglevel}">
|
|
101 |
<hlm:recordfilter category="@{category}" regexp="@{pattern}" />
|
|
102 |
</hlm:record>
|
|
103 |
</sequential>
|
|
104 |
</macrodef>
|
|
105 |
|
|
106 |
|
|
107 |
<!--Macro to stop recording the seperate filtered log file, filter the passwords
|
|
108 |
and start recording in main log file -->
|
|
109 |
<macrodef name="filterRecordStopMacro" uri="http://www.nokia.com/helium">
|
|
110 |
<attribute name="log" default="${build.log}"/>
|
|
111 |
<attribute name="append" default="true"/>
|
|
112 |
<sequential>
|
|
113 |
<hlm:record name="${build.cache.log.dir}/temp_ant_build.log" action="stop"/>
|
|
114 |
<concat destfile="@{log}" append="@{append}">
|
|
115 |
<filelist dir="${build.cache.log.dir}" files="temp_ant_build.log"/>
|
|
116 |
</concat>
|
|
117 |
<delete file="${build.cache.log.dir}/temp_ant_build.log" failonerror="false"/>
|
|
118 |
</sequential>
|
|
119 |
</macrodef>
|
|
120 |
|
|
121 |
|
|
122 |
<!-- Extract logs from text file and process error/warnings/components name etc
|
|
123 |
into xml file.
|
|
124 |
@deprecated Please consider using the metadata framework.
|
|
125 |
-->
|
|
126 |
<scriptdef name="logextract" language="jython" uri="http://www.nokia.com/helium">
|
|
127 |
<attribute name="file" />
|
|
128 |
<attribute name="outputfile" />
|
|
129 |
<element name="fileset" type="fileset"/>
|
|
130 |
<element name="logfilterset" classname="com.nokia.ant.types.LogFilterSet"/>
|
|
131 |
<![CDATA[
|
|
132 |
import os.path
|
|
133 |
import log2xml
|
|
134 |
import java.io
|
|
135 |
|
|
136 |
def convertFile(inputfile, outputfile, config):
|
|
137 |
if (outputfile != None):
|
|
138 |
print "output file not none"
|
|
139 |
print "output file: %s" % outputfile
|
|
140 |
targetfile = str(outputfile)
|
|
141 |
else:
|
|
142 |
#print "output file: %s" % outputfile
|
|
143 |
targetfile = "%s.xml" % inputfile
|
|
144 |
#print "targetFile %s" % targetfile
|
|
145 |
if not os.path.exists(targetfile) or \
|
|
146 |
(os.path.exists(targetfile) and os.path.getmtime(inputfile) > os.path.getmtime(targetfile)):
|
|
147 |
self.getProject().log("Converting %s..." % inputfile)
|
|
148 |
log2xml.convert(inputfile, targetfile, False, config)
|
|
149 |
else:
|
|
150 |
self.getProject().log("Extracted log is uptodate: %s" % inputfile)
|
|
151 |
|
|
152 |
config = log2xml.DEFAULT_CONFIGURATION
|
|
153 |
logfilterset = elements.get("logfilterset")
|
|
154 |
if logfilterset != None and logfilterset.size() > 0:
|
|
155 |
# if any logfilterset are dfined then
|
|
156 |
# it override the default configuration
|
|
157 |
config = {}
|
|
158 |
for filtersetid in range(logfilterset.size()):
|
|
159 |
filterset = logfilterset.get(filtersetid)
|
|
160 |
if filterset.isReference():
|
|
161 |
filterset = filterset.getRefid().getReferencedObject(project)
|
|
162 |
filters = filterset.getFilters()
|
|
163 |
for filterid in range(filters.size()):
|
|
164 |
if not filters.get(filterid).getCategory() in config:
|
|
165 |
config[filters.get(filterid).getCategory()] = []
|
|
166 |
config[filters.get(filterid).getCategory()].append(str(filters.get(filterid).getRegex()))
|
|
167 |
|
|
168 |
fileset = elements.get("fileset")
|
|
169 |
outputfile = attributes.get("outputfile")
|
|
170 |
if fileset != None and fileset.size() > 0:
|
|
171 |
for filesetid in range(fileset.size()):
|
|
172 |
dirscanner = fileset.get(filesetid).getDirectoryScanner(project)
|
|
173 |
for filename in dirscanner.getIncludedFiles():
|
|
174 |
inputfile = str(java.io.File(dirscanner.getBasedir(), str(filename)).getAbsolutePath())
|
|
175 |
convertFile(inputfile, outputfile, config)
|
|
176 |
elif attributes.get("file") != None:
|
|
177 |
inputfile = str(java.io.File(str(attributes.get("file"))).getAbsolutePath())
|
|
178 |
convertFile(inputfile, outputfile, config)
|
|
179 |
else:
|
|
180 |
self.log("No input specified.")
|
|
181 |
]]>
|
|
182 |
</scriptdef>
|
|
183 |
|
|
184 |
|
|
185 |
<!--Macro to stop recording to the main log file (if present) and record to
|
|
186 |
a separate log file into a temporary location (doesn't need the build aread to work). -->
|
|
187 |
<macrodef name="tempRecordStartMacro" uri="http://www.nokia.com/helium">
|
|
188 |
<attribute name="name"/>
|
|
189 |
<sequential>
|
|
190 |
<mkdir dir="${build.cache.log.dir}"/>
|
|
191 |
<hlm:record name="${build.cache.log.dir}/@{name}" action="start" loglevel="${ant.loglevel}"/>
|
|
192 |
</sequential>
|
|
193 |
</macrodef>
|
|
194 |
|
|
195 |
|
|
196 |
<!--Macro to restart the main log file (if present) and stop recording to
|
|
197 |
a separate log file into a temporary location the file is next xml summarized
|
|
198 |
and potentially copied to the build area (if exists). Else those files will get copied during the
|
|
199 |
build area preparation. -->
|
|
200 |
<macrodef name="tempRecordStopMacro" uri="http://www.nokia.com/helium">
|
|
201 |
<attribute name="name"/>
|
|
202 |
<attribute name="phase" default=""/>
|
|
203 |
<attribute name="database" default="${metadata.dbfile}"/>
|
|
204 |
<attribute name="filterref" default="filterset.temprecord"/>
|
|
205 |
<sequential>
|
|
206 |
<mkdir dir="${build.cache.log.dir}"/>
|
|
207 |
<mkdir dir="${build.log.dir}"/>
|
|
208 |
<mkdir dir="${build.cache.log.dir}/signals"/>
|
|
209 |
<hlm:record name="${build.cache.log.dir}/@{name}" action="stop" loglevel="${ant.loglevel}"/>
|
|
210 |
<!--Temporary solution, the logextract in general
|
|
211 |
needs to be handled in a better way (not all logs needs to be processed,
|
|
212 |
logextract / counting errors could be merged and logextract should be
|
|
213 |
executed on a need basis and not to process for all stopmacro.-->
|
|
214 |
<!-- Todo: metadata: replace logextract -->
|
|
215 |
<hlm:metadatarecord database="@{database}">
|
|
216 |
<hlm:antmetadatainput>
|
|
217 |
<fileset casesensitive="false" file="${build.cache.log.dir}/@{name}" />
|
|
218 |
<metadatafilterset refid="@{filterref}" />
|
|
219 |
</hlm:antmetadatainput>
|
|
220 |
</hlm:metadatarecord>
|
628
|
221 |
<hlm:generateBuildStatus dbfile="@{database}" output-dir="${build.cache.log.dir}/signals" file="${build.cache.log.dir}/@{name}" />
|
217
|
222 |
<if>
|
|
223 |
<isset property="@{phase}.log.dir" />
|
|
224 |
<then>
|
|
225 |
<mkdir dir="${@{phase}.log.dir}"/>
|
|
226 |
<copy todir="${@{phase}.log.dir}" failonerror="false">
|
|
227 |
<fileset casesensitive="false" file="${build.cache.log.dir}/@{name}" />
|
|
228 |
</copy>
|
|
229 |
</then>
|
|
230 |
<else>
|
|
231 |
<copy todir="${build.log.dir}" failonerror="false">
|
|
232 |
<fileset casesensitive="false" file="${build.cache.log.dir}/@{name}" />
|
|
233 |
</copy>
|
|
234 |
</else>
|
|
235 |
</if>
|
|
236 |
<copy todir="${build.signal.status.dir}" failonerror="false">
|
|
237 |
<fileset casesensitive="false" dir="${build.cache.log.dir}/signals" />
|
|
238 |
</copy>
|
|
239 |
</sequential>
|
|
240 |
</macrodef>
|
|
241 |
|
|
242 |
|
|
243 |
<!-- Macro to start logging to a separate log file.
|
|
244 |
|
|
245 |
This will stop logging to the main ant_build log file until stopSpecificLogMacro
|
|
246 |
is called. -->
|
|
247 |
<macrodef name="startSpecificLogMacro" uri="http://www.nokia.com/helium">
|
|
248 |
<attribute name="name"/>
|
|
249 |
<attribute name="regexp" default=""/>
|
|
250 |
<attribute name="backup" default="false"/>
|
|
251 |
<attribute name="phase" default=""/>
|
|
252 |
|
|
253 |
<sequential>
|
|
254 |
<if>
|
|
255 |
<isset property="@{phase}.log.dir" />
|
|
256 |
<then>
|
|
257 |
<mkdir dir="${@{phase}.log.dir}"/>
|
|
258 |
</then>
|
|
259 |
</if>
|
|
260 |
<mkdir dir="@{name}/.."/>
|
|
261 |
<hlm:record name="@{name}" action="start" loglevel="verbose" backup="@{backup}" backupProperty="backup.file.name">
|
|
262 |
<hlm:recordfilter category="@{phase}" regexp="@{regexp}" />
|
|
263 |
</hlm:record>
|
|
264 |
</sequential>
|
|
265 |
</macrodef>
|
|
266 |
|
|
267 |
|
|
268 |
<!--Macro to restart the main log file (if present) and stop recording to
|
|
269 |
a separate log file. -->
|
|
270 |
<macrodef name="stopSpecificLogMacro" uri="http://www.nokia.com/helium">
|
|
271 |
<attribute name="name"/>
|
|
272 |
<attribute name="phase" default=""/>
|
|
273 |
<sequential>
|
|
274 |
<hlm:record name="@{name}" action="stop" loglevel="verbose"/>
|
|
275 |
</sequential>
|
|
276 |
</macrodef>
|
|
277 |
|
|
278 |
<!-- Temp BMD macro -->
|
|
279 |
<macrodef name="bmdLogExtractMacro" uri="http://www.nokia.com/helium">
|
|
280 |
<attribute name="log"/>
|
|
281 |
<attribute name="metadatafilterset" default="common"/>
|
|
282 |
<sequential>
|
|
283 |
<hlm:metadatarecord database="${metadata.dbfile}">
|
|
284 |
<hlm:textmetadatainput>
|
|
285 |
<fileset casesensitive="false" file="@{log}"/>
|
|
286 |
<metadatafilterset refid="@{metadatafilterset}" />
|
|
287 |
</hlm:textmetadatainput>
|
|
288 |
</hlm:metadatarecord>
|
|
289 |
<!-- todo: check to add for usage and add genbuildstatus macro -->
|
|
290 |
<basename property="log.name" file="@{log}"/>
|
|
291 |
<fmpp sourceFile="${helium.dir}/tools/common/templates/db2xml.xml.ftl"
|
|
292 |
outputfile="@{log}.xml">
|
|
293 |
<data expandProperties="yes">
|
|
294 |
dbPath: ${metadata.dbfile}
|
|
295 |
log: ${log.name}
|
|
296 |
ant: antProperties()
|
|
297 |
</data>
|
|
298 |
</fmpp>
|
|
299 |
</sequential>
|
|
300 |
</macrodef>
|
|
301 |
|
|
302 |
|
|
303 |
<!-- Merges all XML log files ending in ".log2.xml" in the build log directory
|
|
304 |
into a single summary log file. -->
|
628
|
305 |
<target name="log-merge">
|
217
|
306 |
<mkdir dir="${build.log.dir}"/>
|
|
307 |
<dependset>
|
|
308 |
<srcfileset dir="${build.log.dir}" includes="**/${build.id}*.log.xml"/>
|
|
309 |
<targetfileset file="${build.summary.file}"/>
|
|
310 |
</dependset>
|
|
311 |
<if>
|
|
312 |
<not>
|
|
313 |
<available file="${build.summary.file}"/>
|
|
314 |
</not>
|
|
315 |
<then>
|
|
316 |
<echo>Merging all *.log.xml files</echo>
|
|
317 |
<mkdir dir="${build.log.dir}/summary"/>
|
|
318 |
<xmltask dest="${build.summary.file}">
|
|
319 |
<insert path="/" >
|
|
320 |
<![CDATA[
|
|
321 |
<logSummary/>
|
|
322 |
]]>
|
|
323 |
</insert>
|
|
324 |
</xmltask>
|
|
325 |
<for param="file">
|
|
326 |
<path>
|
|
327 |
<fileset dir="${build.log.dir}">
|
|
328 |
<include name="**/${build.id}*.log.xml"/>
|
|
329 |
</fileset>
|
|
330 |
<fileset dir="${temp.build.dir}">
|
|
331 |
<include name="**/${build.id}*.log.xml"/>
|
|
332 |
</fileset>
|
|
333 |
</path>
|
|
334 |
<sequential>
|
|
335 |
<echo>Inserting @{file} into summary.</echo>
|
|
336 |
<!--<xmltask source="${build.summary.file}"
|
|
337 |
dest="${build.summary.file}">
|
|
338 |
<insert path="/logSummary" file="@{file}" />
|
|
339 |
</xmltask>-->
|
|
340 |
<hlm:assertPropertySet property="build.summary.file" message="Property build.summary.file is not defined." />
|
|
341 |
<script language="jython" setbeans="false">
|
|
342 |
# Temporary solution
|
|
343 |
import log2xml
|
|
344 |
log2xml.append_summary(project.getProperty('build.summary.file'), r'@{file}')
|
|
345 |
</script>
|
|
346 |
</sequential>
|
|
347 |
</for>
|
|
348 |
</then>
|
|
349 |
<else>
|
|
350 |
<echo>Summary XML log file does not need updating.</echo>
|
|
351 |
</else>
|
|
352 |
</if>
|
|
353 |
</target>
|
|
354 |
|
|
355 |
|
|
356 |
<!-- Outputs an HTML readable version of the summary log. -->
|
|
357 |
<target name="render-log-summary">
|
|
358 |
<if>
|
|
359 |
<and>
|
|
360 |
<available file="${build.log.dir}/${build.id}_info.log.xml"/>
|
|
361 |
<available file="${metadata.dbfile}"/>
|
|
362 |
</and>
|
|
363 |
<then>
|
|
364 |
<fmpp sourceFile="${helium.dir}/tools/common/templates/log/summary_metadata_orm.html.ftl"
|
|
365 |
outputfile="${build.log.dir}/${build.id}_summary.html">
|
|
366 |
<freemarkerLinks expandProperties="yes">
|
|
367 |
macro: ${helium.dir}/tools/common/templates/macro
|
|
368 |
</freemarkerLinks>
|
|
369 |
<data expandProperties="yes">
|
|
370 |
dbPath: ${metadata.dbfile}
|
|
371 |
loginfo: xml(${build.log.dir}/${build.id}_info.log.xml)
|
|
372 |
ant: antProperties()
|
|
373 |
</data>
|
|
374 |
</fmpp>
|
|
375 |
<if>
|
|
376 |
<not>
|
|
377 |
<available file="${build.log.dir}/${build.id}_summary.html"/>
|
|
378 |
</not>
|
|
379 |
<then>
|
|
380 |
<echo message="Error: failed to generate Summary file" />
|
|
381 |
</then>
|
|
382 |
</if>
|
|
383 |
</then>
|
|
384 |
</if>
|
|
385 |
</target>
|
|
386 |
|
|
387 |
<!-- Prepare email for build summary -->
|
|
388 |
<target name="logger-email" depends="log-merge">
|
|
389 |
<fmpp sourceRoot="${helium.dir}/tools/common/templates/log" includes="email.html.ftl" outputRoot="${build.log.dir}/summary"
|
|
390 |
replaceExtension="html.ftl, html">
|
|
391 |
<data expandProperties="yes">
|
|
392 |
doc: xml(${build.summary.file})
|
|
393 |
ant: antProperties()
|
|
394 |
</data>
|
|
395 |
</fmpp>
|
|
396 |
</target>
|
|
397 |
|
|
398 |
|
|
399 |
<!-- Test target to show how Diamond metadata could be rendered. -->
|
|
400 |
<target name="render-diamonds-data" depends="log-merge">
|
|
401 |
<mkdir dir="${build.log.dir}/summary/diamonds"/>
|
|
402 |
<fmpp sourceRoot="${helium.dir}/tools/common/templates/diamonds"
|
|
403 |
outputRoot="${build.log.dir}/summary/diamonds" includes="diamonds.xml.ftl"
|
|
404 |
replaceExtension="xml.ftl, xml">
|
|
405 |
<data expandProperties="yes">
|
|
406 |
doc: xml(${build.summary.file})
|
|
407 |
ant: antProperties()
|
|
408 |
</data>
|
|
409 |
</fmpp>
|
|
410 |
</target>
|
|
411 |
|
|
412 |
|
|
413 |
<!-- Render the CC dashboad summary. -->
|
|
414 |
<target name="render-cc-summary" depends="log-merge">
|
|
415 |
<mkdir dir="${build.log.dir}/summary"/>
|
|
416 |
<fmpp sourceFile="${helium.dir}/tools/common/templates/log/cc_summary_metadata_orm.html.ftl"
|
|
417 |
outputfile="${build.log.dir}/summary/${build.id}_cc_summary.html">
|
|
418 |
<data expandProperties="yes">
|
|
419 |
dbPath: ${metadata.dbfile}
|
|
420 |
ant: antProperties()
|
|
421 |
</data>
|
|
422 |
</fmpp>
|
|
423 |
</target>
|
|
424 |
|
|
425 |
|
|
426 |
<!-- Creates a full summary log from all the build logs. -->
|
|
427 |
<target name="build-log-summary" depends="render-log-summary"/>
|
|
428 |
|
|
429 |
<!-- Test target to check signal. -->
|
|
430 |
<target name="check-signal" />
|
|
431 |
|
|
432 |
<!-- Starting the main ant_build log -->
|
|
433 |
<target name="start-ant-log" >
|
|
434 |
<hlm:triggerlogger/>
|
|
435 |
</target>
|
|
436 |
|
|
437 |
|
|
438 |
|
|
439 |
|
|
440 |
</project> |