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-->
|
587
|
29 |
<!--* @property enabled.coverity
|
|
30 |
Value must be set to execute coverity targets.
|
|
31 |
@type boolean
|
|
32 |
@editable required
|
|
33 |
@scope public
|
|
34 |
-->
|
|
35 |
<!--* @property run.coverity
|
|
36 |
Value will be set to if enabled.coverity set tot true.
|
|
37 |
@type string
|
|
38 |
@scope private
|
|
39 |
-->
|
217
|
40 |
<!-- coverity output directory location
|
|
41 |
@type string
|
|
42 |
@scope private
|
|
43 |
-->
|
|
44 |
<property name="coverity.output.dir" location="${build.output.dir}/coverity"/>
|
|
45 |
<!-- coverity log directory location
|
|
46 |
@type string
|
|
47 |
@scope private
|
|
48 |
-->
|
|
49 |
<property name="coverity.log.dir" location="${build.log.dir}/coverity"/>
|
|
50 |
<!-- coverity link directory location
|
|
51 |
@type string
|
|
52 |
@scope private
|
|
53 |
-->
|
|
54 |
<property name="coverity.link.dir" value="${coverity.output.dir}/coveritylink"/>
|
|
55 |
<!-- coverity config directory location
|
|
56 |
@type string
|
|
57 |
@scope private
|
|
58 |
-->
|
|
59 |
<property name="coverity.config.dir" value="${coverity.output.dir}/config"/>
|
|
60 |
<!-- coverity analyze directory location
|
|
61 |
@type string
|
|
62 |
@scope private
|
|
63 |
-->
|
|
64 |
<property name="coverity.analyze.dir" value="${coverity.link.dir}/analyze"/>
|
|
65 |
<!-- coverity intermidiate directory location
|
|
66 |
@type string
|
|
67 |
@scope private
|
|
68 |
-->
|
|
69 |
<property name="coverity.inter.dir" value="${coverity.output.dir}/intermidiate"/>
|
|
70 |
<!-- coverity report directory location
|
|
71 |
@type string
|
|
72 |
@scope private
|
|
73 |
-->
|
|
74 |
<property name="coverity.report.dir" value="${coverity.output.dir}/coverity_report_${build.id}"/>
|
|
75 |
<!-- coverity report file name
|
|
76 |
@type string
|
|
77 |
@scope private
|
|
78 |
-->
|
|
79 |
<property name="coverity.report.file" value="${build.id}_coverity_build_report.html"/>
|
|
80 |
<!-- coverity summary XML file name
|
|
81 |
@type string
|
|
82 |
@scope private
|
|
83 |
-->
|
|
84 |
<property name="coverity.summary.xml.file" value="${temp.build.dir}/${build.id}_coverity_build_summary.xml"/>
|
|
85 |
<!-- coverity checkers XML file name
|
|
86 |
@type string
|
|
87 |
@scope private
|
|
88 |
-->
|
|
89 |
<property name="coverity.checkers.xml.file" value="${temp.build.dir}/${build.id}_coverity_build_checkers.xml"/>
|
|
90 |
<!-- diamonds coverity report file name
|
|
91 |
@type string
|
|
92 |
@scope private
|
|
93 |
-->
|
|
94 |
<property name="diamonds.coverity.report.file" value="${temp.build.dir}/${build.id}_coverity_build_report.xml"/>
|
|
95 |
|
|
96 |
<if>
|
|
97 |
<isset property="env.NUMBER_OF_PROCESSORS"/>
|
|
98 |
<then>
|
|
99 |
<math result="coverity.no.thread" operand1="${env.NUMBER_OF_PROCESSORS}" operation="*" operand2="2" datatype="int"/>
|
|
100 |
</then>
|
|
101 |
<else>
|
|
102 |
<!-- Number of parallel coverity emit threads can run.
|
|
103 |
@type string
|
|
104 |
@scope private
|
|
105 |
-->
|
|
106 |
<property name="coverity.no.thread" value="2"/>
|
|
107 |
</else>
|
|
108 |
</if>
|
|
109 |
|
|
110 |
<!-- set property if coverity is enabled -->
|
|
111 |
<condition property="run.coverity">
|
|
112 |
<istrue value="${enabled.coverity}" />
|
|
113 |
</condition>
|
|
114 |
|
|
115 |
<!-- cov-build command options -->
|
|
116 |
<hlm:coverityoptions id="coverity.build.options">
|
|
117 |
<arg name="--config" value="${coverity.config.dir}/coverity_config.xml"/>
|
|
118 |
<arg name="--dir" value="${coverity.inter.dir}"/>
|
|
119 |
<arg name="--auto-diff" value=""/>
|
|
120 |
<arg name="--preprocess-first" value=""/>
|
|
121 |
<arg name="--record-only" value=""/>
|
|
122 |
</hlm:coverityoptions>
|
|
123 |
|
|
124 |
<!-- cov-build emit command options -->
|
|
125 |
<hlm:coverityoptions id="coverity.emit.options">
|
|
126 |
<arg name="--config" value="${coverity.config.dir}/coverity_config.xml"/>
|
|
127 |
<arg name="--dir" value="${coverity.inter.dir}"/>
|
|
128 |
<arg name="--replay" value=""/>
|
|
129 |
<arg name="--replay-processes" value="${coverity.no.thread}"/>
|
|
130 |
</hlm:coverityoptions>
|
|
131 |
|
|
132 |
<!-- cov-config command options -->
|
|
133 |
<hlm:coverityoptions id="coverity.config.options">
|
|
134 |
<hlm:arg name="--config" value="${coverity.config.dir}/coverity_config.xml"/>
|
|
135 |
<hlm:arg name="--template" value=""/>
|
|
136 |
<hlm:arg name="--comptype" value="armcc"/>
|
|
137 |
<hlm:arg name="--compiler" value="armcc.exe"/>
|
|
138 |
</hlm:coverityoptions>
|
|
139 |
|
|
140 |
<!-- cov-analyze command options -->
|
|
141 |
<hlm:coverityoptions id="coverity.analyze.options">
|
|
142 |
<hlm:arg name="--dir" value="${coverity.analyze.dir}"/>
|
|
143 |
<hlm:arg name="--all" value=""/>
|
|
144 |
<hlm:arg name="--symbian" value=""/>
|
|
145 |
<hlm:arg name="--append" value=""/>
|
|
146 |
<hlm:arg name="--enable-callgraph-metrics" value=""/>
|
|
147 |
</hlm:coverityoptions>
|
|
148 |
|
|
149 |
<!-- To run post coverity steps -->
|
|
150 |
<target name="post-coverity" if="run.coverity">
|
|
151 |
|
|
152 |
<!-- To emit the file into defect database -->
|
|
153 |
<antcall target="run-coverity-emit"/>
|
|
154 |
|
|
155 |
<!-- To analyze the sources file -->
|
|
156 |
<antcall target="run-coverity-analyze"/>
|
|
157 |
|
|
158 |
<!-- To generate the HTML error pages -->
|
|
159 |
<antcall target="gen-coverity-report"/>
|
|
160 |
|
|
161 |
</target>
|
|
162 |
|
|
163 |
<!-- Run coverity configure if the enabled.coverity is set to true -->
|
|
164 |
<target name="run-coverity-configure" if="run.coverity">
|
|
165 |
|
|
166 |
<hlm:coverity command="cov-configure" dir="${build.drive}/">
|
|
167 |
<hlm:coverityoptions refid="coverity.config.options"/>
|
|
168 |
</hlm:coverity >
|
|
169 |
|
|
170 |
</target>
|
|
171 |
|
|
172 |
<!-- Run coverity build with emit options if the enabled.coverity is set to true
|
|
173 |
re-running the cov-build with replay option will reduce the build time by ~ 20%
|
|
174 |
-->
|
|
175 |
<target name="run-coverity-emit" >
|
|
176 |
|
|
177 |
<hlm:coverity command="cov-build" dir="${build.drive}/">
|
|
178 |
<hlm:coverityoptions refid="coverity.emit.options"/>
|
|
179 |
</hlm:coverity >
|
|
180 |
|
|
181 |
</target>
|
|
182 |
|
|
183 |
<!-- Run coverity-analyze if the enabled.coverity is set to true
|
|
184 |
Sometimes the same file is compiled several times with different command-line options.
|
|
185 |
Due to the inherent difficulty of tracking linkage information, the cov-analyze command cannot automatically determine which files are linked together.
|
|
186 |
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.
|
|
187 |
|
|
188 |
and also
|
|
189 |
|
|
190 |
working with link files is faster than collecting data from the intermediate directory multiple times
|
|
191 |
|
|
192 |
So run the cov-link commands and analyze the database using cov-analyze command.
|
|
193 |
|
|
194 |
-->
|
|
195 |
<target name="run-coverity-analyze" >
|
|
196 |
|
|
197 |
<mkdir dir="${coverity.link.dir}"/>
|
|
198 |
|
|
199 |
<hlm:coverity command="cov-link" dir="${build.drive}/">
|
|
200 |
<hlm:arg name="--dir" value="${coverity.inter.dir}"/>
|
|
201 |
<hlm:arg name="--collect" value=""/>
|
|
202 |
<hlm:arg name="-of" value="${coverity.link.dir}/all.link"/>
|
|
203 |
</hlm:coverity >
|
|
204 |
|
|
205 |
<hlm:coverity command="cov-link" dir="${build.drive}/">
|
|
206 |
<hlm:arg name="--dir" value="${coverity.inter.dir}"/>
|
|
207 |
<hlm:arg name="--compile-arg" value="armv5"/>
|
|
208 |
<hlm:arg name="-of" value="${coverity.link.dir}/armv5.link"/>
|
|
209 |
<hlm:arg name="${coverity.link.dir}/all.link" value=""/>
|
|
210 |
</hlm:coverity >
|
|
211 |
|
|
212 |
<hlm:coverity command="cov-link" dir="${build.drive}/">
|
|
213 |
<hlm:arg name="--dir" value="${coverity.inter.dir}"/>
|
|
214 |
<hlm:arg name="--output-dir" value="${coverity.analyze.dir}"/>
|
|
215 |
<hlm:arg name="${coverity.link.dir}/armv5.link" value=""/>
|
|
216 |
</hlm:coverity >
|
|
217 |
|
|
218 |
<hlm:coverity command="cov-analyze" dir="${build.drive}/">
|
|
219 |
<hlm:coverityoptions refid="coverity.analyze.options"/>
|
|
220 |
</hlm:coverity >
|
|
221 |
|
|
222 |
</target>
|
|
223 |
|
|
224 |
|
|
225 |
<!-- Generate coverity report -->
|
|
226 |
<target name="gen-coverity-report">
|
|
227 |
|
|
228 |
<!-- Read the summary file generated by cov-analyze and generate html file -->
|
|
229 |
<fmpp sourceFile="${helium.dir}/tools/common/templates/coverity/coverity.summary.html.ftl"
|
|
230 |
outputFile="${temp.build.dir}/${build.id}_coverity_build_summary.html">
|
|
231 |
<data expandProperties="yes">
|
|
232 |
ant: antProperties()
|
|
233 |
covsummary: slicedText (${coverity.analyze.dir}/c/output/summary.txt)
|
|
234 |
</data>
|
|
235 |
</fmpp>
|
|
236 |
|
|
237 |
<!-- To generate summary file for diamonds -->
|
|
238 |
<fmpp sourceFile="${helium.dir}/tools/common/templates/coverity/coverity.summary.xml.ftl"
|
|
239 |
outputFile="${coverity.summary.xml.file}">
|
|
240 |
<data expandProperties="yes">
|
|
241 |
ant: antProperties()
|
|
242 |
covsummary: slicedText (${coverity.analyze.dir}/c/output/summary.txt)
|
|
243 |
</data>
|
|
244 |
</fmpp>
|
|
245 |
|
|
246 |
<!-- Run this to get the static html pages -->
|
|
247 |
<hlm:coverity command="cov-format-errors" dir="${build.drive}/">
|
|
248 |
<hlm:arg name="--dir" value="${coverity.analyze.dir}"/>
|
|
249 |
<hlm:arg name="--filesort" value=""/>
|
|
250 |
<hlm:arg name="--functionsort" value=""/>
|
|
251 |
</hlm:coverity >
|
|
252 |
|
|
253 |
<!-- Copy the summary file to resolve the xml load error -->
|
|
254 |
<copy file="${coverity.analyze.dir}/c/output/errors/summary.xml" tofile="${coverity.checkers.xml.file}" overwrite="true" failonerror="false">
|
|
255 |
<filterchain>
|
|
256 |
<linecontains negate="true">
|
|
257 |
<contains value="config.dtd"/>
|
|
258 |
</linecontains>
|
|
259 |
</filterchain>
|
|
260 |
</copy>
|
|
261 |
|
|
262 |
<!-- Insert summary tags into checkers file -->
|
|
263 |
<xmltask source="${coverity.checkers.xml.file}" dest="${diamonds.coverity.report.file}" report="false">
|
|
264 |
<insert path="/coverity" file="${coverity.summary.xml.file}"/>
|
|
265 |
</xmltask>
|
|
266 |
|
|
267 |
<!-- collect all the html files into folder -->
|
|
268 |
<copy todir="${coverity.report.dir}" overwrite="true" failonerror="false">
|
|
269 |
<fileset dir="${coverity.analyze.dir}/c/output/errors">
|
|
270 |
<exclude name="index.html"/>
|
|
271 |
<exclude name="**/*.xml"/>
|
|
272 |
<exclude name="summary.html"/>
|
|
273 |
</fileset>
|
|
274 |
</copy>
|
|
275 |
|
|
276 |
<!-- Concatinate all the html pages to get the final error report page -->
|
|
277 |
<concat destfile="${coverity.report.dir}/${coverity.report.file}">
|
|
278 |
<fileset dir="${temp.build.dir}" includes="${build.id}_coverity_build_summary.html"/>
|
|
279 |
<fileset dir="${coverity.analyze.dir}/c/output/errors" includes="index.html"/>
|
|
280 |
</concat>
|
|
281 |
|
|
282 |
</target>
|
|
283 |
|
|
284 |
|
|
285 |
<!-- To get the SBS variable value -->
|
|
286 |
<macrodef name="getSBSVariableValue" uri="http://www.nokia.com/helium">
|
|
287 |
<attribute name="variablename"/>
|
|
288 |
<attribute name="outputvar"/>
|
|
289 |
<attribute name="sbsinput"/>
|
|
290 |
<sequential>
|
|
291 |
<var name="output.var" unset="true"/>
|
|
292 |
<hlm:getVariableValue name="@{variablename}" property="output.var">
|
|
293 |
<hlm:sbsinput refid="@{sbsinput}" />
|
|
294 |
</hlm:getVariableValue>
|
|
295 |
<if>
|
|
296 |
<and>
|
|
297 |
<isset property="output.var"/>
|
|
298 |
<matches string="${output.var}" pattern="arm.*"/>
|
|
299 |
</and>
|
|
300 |
<then>
|
|
301 |
<antcall target="set-arm-version"/>
|
|
302 |
</then>
|
|
303 |
</if>
|
|
304 |
<script language="beanshell"> <![CDATA[
|
|
305 |
curVal=project.getProperty("output.var");
|
|
306 |
project.setProperty("@{outputvar}",curVal);
|
|
307 |
]]>
|
|
308 |
</script>
|
|
309 |
</sequential>
|
|
310 |
</macrodef>
|
|
311 |
|
|
312 |
|
|
313 |
</project>
|