217
|
1 |
<?xml version="1.0" encoding="UTF-8"?>
|
|
2 |
<!--
|
|
3 |
============================================================================
|
|
4 |
Name : coverity.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 |
<project name="compile.coverity" xmlns:hlm="http://www.nokia.com/helium">
|
|
24 |
<description>
|
|
25 |
code-coverity measure.
|
|
26 |
</description>
|
|
27 |
|
|
28 |
<!-- Coverity property declaration and types defination-->
|
628
|
29 |
<!--* @property coverity.enabled
|
587
|
30 |
Value must be set to execute coverity targets.
|
|
31 |
@type boolean
|
|
32 |
@editable required
|
|
33 |
@scope public
|
628
|
34 |
@since 11.0
|
587
|
35 |
-->
|
628
|
36 |
|
|
37 |
<!--* @property internal.coverity.enabled
|
|
38 |
To run coverity related targets if coverity.enabled set to true.
|
|
39 |
@type boolean
|
587
|
40 |
@scope private
|
|
41 |
-->
|
628
|
42 |
|
|
43 |
<!--* @property enabled.coverity
|
|
44 |
Value must be set to execute coverity targets. - deprecated: Start using coverity.enabled property.
|
|
45 |
@type boolean
|
|
46 |
@editable required
|
|
47 |
@scope public
|
|
48 |
@deprecated since 11.0
|
|
49 |
-->
|
|
50 |
|
|
51 |
<!--* @property coverity.commit.defects.enabled
|
|
52 |
Set to true to commit the defects into coverity database.
|
|
53 |
@type boolean
|
|
54 |
@editable required
|
|
55 |
@scope public
|
|
56 |
@since 11.0
|
|
57 |
-->
|
|
58 |
|
|
59 |
<!--* @property internal.coverity.commit.defects.enabled
|
|
60 |
Run the targets to commit the defects into database if coverity.commit.defects.enabled set to true.
|
|
61 |
@type boolean
|
|
62 |
@scope private
|
|
63 |
-->
|
|
64 |
|
|
65 |
<!--* @property coverity.defect.manager.server
|
|
66 |
Coverity defect manager server name or ip address.
|
|
67 |
@type string
|
|
68 |
@editable required
|
|
69 |
@scope public
|
|
70 |
@since 11.0
|
|
71 |
-->
|
|
72 |
|
|
73 |
<!--* @property coverity.defect.manager.port
|
|
74 |
Coverity defect manager server HTTP port or listener port number.
|
|
75 |
@type string
|
|
76 |
@editable required
|
|
77 |
@scope public
|
|
78 |
@since 11.0
|
|
79 |
-->
|
|
80 |
|
|
81 |
<!--* @property coverity.defect.manager.product
|
|
82 |
Coverity defect manager product name to submit the coverity errors.
|
|
83 |
@type string
|
|
84 |
@editable required
|
|
85 |
@scope public
|
|
86 |
@since 11.0
|
|
87 |
-->
|
|
88 |
|
217
|
89 |
<!-- coverity output directory location
|
|
90 |
@type string
|
|
91 |
@scope private
|
|
92 |
-->
|
|
93 |
<property name="coverity.output.dir" location="${build.output.dir}/coverity"/>
|
|
94 |
<!-- coverity log directory location
|
|
95 |
@type string
|
|
96 |
@scope private
|
|
97 |
-->
|
|
98 |
<property name="coverity.log.dir" location="${build.log.dir}/coverity"/>
|
|
99 |
<!-- coverity link directory location
|
|
100 |
@type string
|
|
101 |
@scope private
|
|
102 |
-->
|
|
103 |
<property name="coverity.link.dir" value="${coverity.output.dir}/coveritylink"/>
|
|
104 |
<!-- coverity config directory location
|
|
105 |
@type string
|
|
106 |
@scope private
|
|
107 |
-->
|
|
108 |
<property name="coverity.config.dir" value="${coverity.output.dir}/config"/>
|
|
109 |
<!-- coverity analyze directory location
|
|
110 |
@type string
|
|
111 |
@scope private
|
|
112 |
-->
|
|
113 |
<property name="coverity.analyze.dir" value="${coverity.link.dir}/analyze"/>
|
628
|
114 |
<!-- coverity intermediate directory location
|
217
|
115 |
@type string
|
|
116 |
@scope private
|
|
117 |
-->
|
628
|
118 |
<property name="coverity.inter.dir" value="${coverity.output.dir}/intermediate"/>
|
217
|
119 |
<!-- coverity report directory location
|
|
120 |
@type string
|
|
121 |
@scope private
|
|
122 |
-->
|
|
123 |
<property name="coverity.report.dir" value="${coverity.output.dir}/coverity_report_${build.id}"/>
|
|
124 |
<!-- coverity report file name
|
|
125 |
@type string
|
|
126 |
@scope private
|
|
127 |
-->
|
|
128 |
<property name="coverity.report.file" value="${build.id}_coverity_build_report.html"/>
|
|
129 |
<!-- coverity summary XML file name
|
|
130 |
@type string
|
|
131 |
@scope private
|
|
132 |
-->
|
|
133 |
<property name="coverity.summary.xml.file" value="${temp.build.dir}/${build.id}_coverity_build_summary.xml"/>
|
|
134 |
<!-- coverity checkers XML file name
|
|
135 |
@type string
|
|
136 |
@scope private
|
|
137 |
-->
|
|
138 |
<property name="coverity.checkers.xml.file" value="${temp.build.dir}/${build.id}_coverity_build_checkers.xml"/>
|
|
139 |
<!-- diamonds coverity report file name
|
|
140 |
@type string
|
|
141 |
@scope private
|
|
142 |
-->
|
|
143 |
<property name="diamonds.coverity.report.file" value="${temp.build.dir}/${build.id}_coverity_build_report.xml"/>
|
|
144 |
|
628
|
145 |
<!-- set property if coverity is enabled -->
|
|
146 |
<condition property="internal.coverity.enabled">
|
|
147 |
<or>
|
|
148 |
<istrue value="${coverity.enabled}" />
|
|
149 |
<istrue value="${enabled.coverity}"/>
|
|
150 |
</or>
|
|
151 |
</condition>
|
|
152 |
|
|
153 |
<!-- set property if coverity.commit.defects.enabled is enabled -->
|
|
154 |
<condition property="internal.coverity.commit.defects.enabled">
|
|
155 |
<istrue value="${coverity.commit.defects.enabled}" />
|
|
156 |
</condition>
|
|
157 |
|
217
|
158 |
<if>
|
|
159 |
<isset property="env.NUMBER_OF_PROCESSORS"/>
|
|
160 |
<then>
|
|
161 |
<math result="coverity.no.thread" operand1="${env.NUMBER_OF_PROCESSORS}" operation="*" operand2="2" datatype="int"/>
|
|
162 |
</then>
|
|
163 |
<else>
|
|
164 |
<!-- Number of parallel coverity emit threads can run.
|
|
165 |
@type string
|
|
166 |
@scope private
|
|
167 |
-->
|
|
168 |
<property name="coverity.no.thread" value="2"/>
|
|
169 |
</else>
|
|
170 |
</if>
|
|
171 |
|
|
172 |
<!-- cov-build command options -->
|
|
173 |
<hlm:coverityoptions id="coverity.build.options">
|
|
174 |
<arg name="--config" value="${coverity.config.dir}/coverity_config.xml"/>
|
|
175 |
<arg name="--dir" value="${coverity.inter.dir}"/>
|
|
176 |
<arg name="--auto-diff" value=""/>
|
|
177 |
<arg name="--preprocess-first" value=""/>
|
|
178 |
<arg name="--record-only" value=""/>
|
|
179 |
</hlm:coverityoptions>
|
|
180 |
|
|
181 |
<!-- cov-build emit command options -->
|
|
182 |
<hlm:coverityoptions id="coverity.emit.options">
|
|
183 |
<arg name="--config" value="${coverity.config.dir}/coverity_config.xml"/>
|
|
184 |
<arg name="--dir" value="${coverity.inter.dir}"/>
|
|
185 |
<arg name="--replay" value=""/>
|
|
186 |
<arg name="--replay-processes" value="${coverity.no.thread}"/>
|
|
187 |
</hlm:coverityoptions>
|
|
188 |
|
|
189 |
<!-- cov-config command options -->
|
|
190 |
<hlm:coverityoptions id="coverity.config.options">
|
|
191 |
<hlm:arg name="--config" value="${coverity.config.dir}/coverity_config.xml"/>
|
|
192 |
<hlm:arg name="--template" value=""/>
|
|
193 |
<hlm:arg name="--comptype" value="armcc"/>
|
|
194 |
<hlm:arg name="--compiler" value="armcc.exe"/>
|
|
195 |
</hlm:coverityoptions>
|
|
196 |
|
|
197 |
<!-- cov-analyze command options -->
|
|
198 |
<hlm:coverityoptions id="coverity.analyze.options">
|
|
199 |
<hlm:arg name="--dir" value="${coverity.analyze.dir}"/>
|
|
200 |
<hlm:arg name="--all" value=""/>
|
|
201 |
<hlm:arg name="--symbian" value=""/>
|
|
202 |
<hlm:arg name="--append" value=""/>
|
|
203 |
<hlm:arg name="--enable-callgraph-metrics" value=""/>
|
|
204 |
</hlm:coverityoptions>
|
|
205 |
|
|
206 |
<!-- To run post coverity steps -->
|
628
|
207 |
<target name="post-coverity" if="internal.coverity.enabled">
|
|
208 |
<mkdir dir="${post.log.dir}"/>
|
217
|
209 |
<!-- To emit the file into defect database -->
|
|
210 |
<antcall target="run-coverity-emit"/>
|
|
211 |
|
|
212 |
<!-- To analyze the sources file -->
|
|
213 |
<antcall target="run-coverity-analyze"/>
|
|
214 |
|
|
215 |
<!-- To generate the HTML error pages -->
|
|
216 |
<antcall target="gen-coverity-report"/>
|
628
|
217 |
|
|
218 |
<!-- To commit the defects into coverity defect manager. -->
|
|
219 |
<antcall target="run-commit-defects"/>
|
|
220 |
|
|
221 |
<hlm:metadatarecord database="${metadata.dbfile}">
|
|
222 |
<hlm:textmetadatainput>
|
|
223 |
<fileset casesensitive="false" file="${post.log.dir}/${build.id}_coverity_command_errors.log" />
|
|
224 |
<metadatafilterset>
|
|
225 |
<metadatafilter priority="error" regex=".*" description="coverity error" />
|
|
226 |
</metadatafilterset>
|
|
227 |
</hlm:textmetadatainput>
|
|
228 |
</hlm:metadatarecord>
|
|
229 |
<hlm:metadataCountSeverity severity="ERROR" log="${post.log.dir}/${build.id}_coverity_command_errors.log" database="${metadata.dbfile}" property="coverity.error.total"/>
|
|
230 |
<echo>Coverity command errors: ${coverity.error.total}</echo>
|
|
231 |
<hlm:generateBuildStatus file="${post.log.dir}/${build.id}_coverity_command_errors.log" />
|
|
232 |
<hlm:signalMacro logfile="${post.log.dir}/${build.id}_coverity_command_errors.log" phase="post" signal.input="coveritySignalInput" />
|
217
|
233 |
</target>
|
|
234 |
|
628
|
235 |
<!-- Run coverity configure if the coverity.enabled is set to true -->
|
|
236 |
<target name="run-coverity-configure" if="internal.coverity.enabled">
|
217
|
237 |
<hlm:coverity command="cov-configure" dir="${build.drive}/">
|
|
238 |
<hlm:coverityoptions refid="coverity.config.options"/>
|
|
239 |
</hlm:coverity >
|
|
240 |
</target>
|
|
241 |
|
628
|
242 |
<!-- Run coverity build with emit options if the coverity.enabled is set to true
|
217
|
243 |
re-running the cov-build with replay option will reduce the build time by ~ 20%
|
|
244 |
-->
|
|
245 |
<target name="run-coverity-emit" >
|
628
|
246 |
<hlm:coverity command="cov-build" dir="${build.drive}/" error="${post.log.dir}/${build.id}_coverity_command_errors.log" >
|
217
|
247 |
<hlm:coverityoptions refid="coverity.emit.options"/>
|
|
248 |
</hlm:coverity >
|
|
249 |
</target>
|
|
250 |
|
628
|
251 |
<!-- Run coverity-analyze if the coverity.enabled is set to true
|
217
|
252 |
Sometimes the same file is compiled several times with different command-line options.
|
|
253 |
Due to the inherent difficulty of tracking linkage information, the cov-analyze command cannot automatically determine which files are linked together.
|
|
254 |
To avoid errors in function call resolution (especially in C code, which doesn't have any name mangling), use the cov-link command to get this information.
|
|
255 |
|
|
256 |
and also
|
|
257 |
|
|
258 |
working with link files is faster than collecting data from the intermediate directory multiple times
|
|
259 |
|
|
260 |
So run the cov-link commands and analyze the database using cov-analyze command.
|
|
261 |
|
|
262 |
-->
|
|
263 |
<target name="run-coverity-analyze" >
|
|
264 |
<mkdir dir="${coverity.link.dir}"/>
|
628
|
265 |
<hlm:coverity command="cov-link" dir="${build.drive}/" error="${post.log.dir}/${build.id}_coverity_command_errors.log" append="true">
|
217
|
266 |
<hlm:arg name="--dir" value="${coverity.inter.dir}"/>
|
|
267 |
<hlm:arg name="--collect" value=""/>
|
|
268 |
<hlm:arg name="-of" value="${coverity.link.dir}/all.link"/>
|
|
269 |
</hlm:coverity >
|
628
|
270 |
<hlm:coverity command="cov-link" dir="${build.drive}/" error="${post.log.dir}/${build.id}_coverity_command_errors.log" append="true">
|
217
|
271 |
<hlm:arg name="--dir" value="${coverity.inter.dir}"/>
|
|
272 |
<hlm:arg name="--compile-arg" value="armv5"/>
|
|
273 |
<hlm:arg name="-of" value="${coverity.link.dir}/armv5.link"/>
|
|
274 |
<hlm:arg name="${coverity.link.dir}/all.link" value=""/>
|
|
275 |
</hlm:coverity >
|
628
|
276 |
<hlm:coverity command="cov-link" dir="${build.drive}/" error="${post.log.dir}/${build.id}_coverity_command_errors.log" append="true">
|
217
|
277 |
<hlm:arg name="--dir" value="${coverity.inter.dir}"/>
|
|
278 |
<hlm:arg name="--output-dir" value="${coverity.analyze.dir}"/>
|
|
279 |
<hlm:arg name="${coverity.link.dir}/armv5.link" value=""/>
|
|
280 |
</hlm:coverity >
|
628
|
281 |
<hlm:coverity command="cov-analyze" dir="${build.drive}/" error="${post.log.dir}/${build.id}_coverity_command_errors.log" append="true">
|
217
|
282 |
<hlm:coverityoptions refid="coverity.analyze.options"/>
|
|
283 |
</hlm:coverity >
|
|
284 |
</target>
|
|
285 |
|
|
286 |
|
|
287 |
<!-- Generate coverity report -->
|
|
288 |
<target name="gen-coverity-report">
|
|
289 |
<!-- Read the summary file generated by cov-analyze and generate html file -->
|
|
290 |
<fmpp sourceFile="${helium.dir}/tools/common/templates/coverity/coverity.summary.html.ftl"
|
|
291 |
outputFile="${temp.build.dir}/${build.id}_coverity_build_summary.html">
|
|
292 |
<data expandProperties="yes">
|
|
293 |
ant: antProperties()
|
|
294 |
covsummary: slicedText (${coverity.analyze.dir}/c/output/summary.txt)
|
|
295 |
</data>
|
|
296 |
</fmpp>
|
|
297 |
|
|
298 |
<!-- To generate summary file for diamonds -->
|
|
299 |
<fmpp sourceFile="${helium.dir}/tools/common/templates/coverity/coverity.summary.xml.ftl"
|
|
300 |
outputFile="${coverity.summary.xml.file}">
|
|
301 |
<data expandProperties="yes">
|
|
302 |
ant: antProperties()
|
|
303 |
covsummary: slicedText (${coverity.analyze.dir}/c/output/summary.txt)
|
|
304 |
</data>
|
|
305 |
</fmpp>
|
|
306 |
|
|
307 |
<!-- Run this to get the static html pages -->
|
628
|
308 |
<hlm:coverity command="cov-format-errors" dir="${build.drive}/" error="${post.log.dir}/${build.id}_coverity_command_errors.log" append="true">
|
217
|
309 |
<hlm:arg name="--dir" value="${coverity.analyze.dir}"/>
|
|
310 |
<hlm:arg name="--filesort" value=""/>
|
|
311 |
<hlm:arg name="--functionsort" value=""/>
|
|
312 |
</hlm:coverity >
|
|
313 |
|
|
314 |
<!-- Copy the summary file to resolve the xml load error -->
|
|
315 |
<copy file="${coverity.analyze.dir}/c/output/errors/summary.xml" tofile="${coverity.checkers.xml.file}" overwrite="true" failonerror="false">
|
|
316 |
<filterchain>
|
|
317 |
<linecontains negate="true">
|
|
318 |
<contains value="config.dtd"/>
|
|
319 |
</linecontains>
|
|
320 |
</filterchain>
|
|
321 |
</copy>
|
|
322 |
|
|
323 |
<!-- Insert summary tags into checkers file -->
|
|
324 |
<xmltask source="${coverity.checkers.xml.file}" dest="${diamonds.coverity.report.file}" report="false">
|
|
325 |
<insert path="/coverity" file="${coverity.summary.xml.file}"/>
|
|
326 |
</xmltask>
|
|
327 |
|
|
328 |
<!-- collect all the html files into folder -->
|
|
329 |
<copy todir="${coverity.report.dir}" overwrite="true" failonerror="false">
|
|
330 |
<fileset dir="${coverity.analyze.dir}/c/output/errors">
|
|
331 |
<exclude name="index.html"/>
|
|
332 |
<exclude name="**/*.xml"/>
|
|
333 |
<exclude name="summary.html"/>
|
|
334 |
</fileset>
|
|
335 |
</copy>
|
|
336 |
|
|
337 |
<!-- Concatinate all the html pages to get the final error report page -->
|
|
338 |
<concat destfile="${coverity.report.dir}/${coverity.report.file}">
|
|
339 |
<fileset dir="${temp.build.dir}" includes="${build.id}_coverity_build_summary.html"/>
|
|
340 |
<fileset dir="${coverity.analyze.dir}/c/output/errors" includes="index.html"/>
|
|
341 |
</concat>
|
|
342 |
</target>
|
|
343 |
|
|
344 |
|
|
345 |
<!-- To get the SBS variable value -->
|
|
346 |
<macrodef name="getSBSVariableValue" uri="http://www.nokia.com/helium">
|
|
347 |
<attribute name="variablename"/>
|
|
348 |
<attribute name="outputvar"/>
|
|
349 |
<attribute name="sbsinput"/>
|
|
350 |
<sequential>
|
|
351 |
<var name="output.var" unset="true"/>
|
|
352 |
<hlm:getVariableValue name="@{variablename}" property="output.var">
|
|
353 |
<hlm:sbsinput refid="@{sbsinput}" />
|
|
354 |
</hlm:getVariableValue>
|
|
355 |
<if>
|
|
356 |
<and>
|
|
357 |
<isset property="output.var"/>
|
|
358 |
<matches string="${output.var}" pattern="arm.*"/>
|
|
359 |
</and>
|
|
360 |
<then>
|
|
361 |
<antcall target="set-arm-version"/>
|
|
362 |
</then>
|
|
363 |
</if>
|
|
364 |
<script language="beanshell"> <![CDATA[
|
|
365 |
curVal=project.getProperty("output.var");
|
|
366 |
project.setProperty("@{outputvar}",curVal);
|
|
367 |
]]>
|
|
368 |
</script>
|
|
369 |
</sequential>
|
|
370 |
</macrodef>
|
|
371 |
|
628
|
372 |
<!-- To commit the coverity defects into coverity defect manager -->
|
|
373 |
<target name="run-commit-defects" depends="coverity-username,coverity-password" if="internal.coverity.commit.defects.enabled">
|
|
374 |
|
|
375 |
<!-- Check is the coverity defect manager server and port numbers are set -->
|
|
376 |
<fail message="FAILED: Coverity defect manager server/IP address is not set. Please set 'coverity.defect.manager.server'. Ex: server.domain.extension or 100.220.530.101"
|
|
377 |
unless="coverity.defect.manager.server"/>
|
|
378 |
<fail message="FAILED: Coverity defect manager HTTP port number is not set. Please set 'coverity.defect.manager.port'."
|
|
379 |
unless="coverity.defect.manager.port"/>
|
|
380 |
<!-- Check is the coverity defect manager server product is set to submit the coverity errors.-->
|
|
381 |
<fail message="FAILED: Coverity defect manager product name is not set. Please set 'coverity.defect.manager.product'."
|
|
382 |
unless="coverity.defect.manager.product"/>
|
|
383 |
|
|
384 |
<!-- cov-commit-defects command options -->
|
|
385 |
<hlm:coverityoptions id="coverity.commit.defects.options">
|
|
386 |
<hlm:arg name="--config" value="${coverity.config.dir}/coverity_config.xml"/>
|
|
387 |
<hlm:arg name="--remote" value="${coverity.defect.manager.server}"/>
|
|
388 |
<hlm:arg name="--port" value="${coverity.defect.manager.port}"/>
|
|
389 |
<hlm:arg name="--user" value="${coverity.username}"/>
|
|
390 |
<hlm:arg name="--password" value="${coverity.password}"/>
|
|
391 |
<hlm:arg name="--dir" value="${coverity.analyze.dir}"/>
|
|
392 |
<hlm:arg name="--product" value="${coverity.defect.manager.product}"/>
|
|
393 |
</hlm:coverityoptions>
|
|
394 |
|
|
395 |
<!-- Run the coverity commit defects command to submit the errors into defect manager -->
|
|
396 |
<hlm:coverity command="cov-commit-defects" dir="${build.drive}/" error="${post.log.dir}/${build.id}_coverity_command_errors.log" append="true">
|
|
397 |
<hlm:coverityoptions refid="coverity.commit.defects.options"/>
|
|
398 |
</hlm:coverity >
|
|
399 |
</target>
|
|
400 |
|
|
401 |
<!-- Retrieve the coverity password from the .netrc file and store it into coverity.password property. -->
|
|
402 |
<target name="coverity-password" if="internal.coverity.commit.defects.enabled">
|
|
403 |
<hlm:netrcPasswordMacro output-prop="coverity.password" result-prop="coverity.password.available" type="coverity"/>
|
|
404 |
<hlm:logreplace regexp="coverity.password"/>
|
|
405 |
</target>
|
|
406 |
|
|
407 |
<!-- Retrieve the coverity username from the .netrc file and store it into coverity.username property. -->
|
|
408 |
<target name="coverity-username" if="internal.coverity.commit.defects.enabled">
|
|
409 |
<hlm:netrcUsernameMacro output-prop="coverity.username" result-prop="coverity.username.available" type="coverity"/>
|
|
410 |
</target>
|
|
411 |
|
217
|
412 |
</project>
|