buildframework/helium/tools/compile/coverity.ant.xml
changeset 648 d5a8d436d33b
parent 645 b8d81fa19e7d
equal deleted inserted replaced
647:53d1ab72f5bc 648:d5a8d436d33b
    54     @editable required
    54     @editable required
    55     @scope public
    55     @scope public
    56     @since 11.0
    56     @since 11.0
    57     -->
    57     -->
    58     
    58     
       
    59     <!--* @property post.coverity.steps.enabled
       
    60     Set to true to run post coverity steps.
       
    61     @type boolean
       
    62     @scope private
       
    63     @since 11.0.4
       
    64     -->
       
    65     
       
    66     <!--* @property is.zero.coverity.errors
       
    67     Set to true if coverity error file contains zero errors.
       
    68     @type boolean
       
    69     @scope private
       
    70     @since 11.0.4
       
    71     -->
       
    72     
       
    73     <!--* @property is.zero.coverity.output.errors
       
    74     Set to true if coverity output file contains zero fatal errors.
       
    75     @type boolean
       
    76     @scope private
       
    77     @since 11.0.4
       
    78     -->
       
    79     
    59     <!--* @property internal.coverity.commit.defects.enabled
    80     <!--* @property internal.coverity.commit.defects.enabled
    60     Run the targets to commit the defects into database if coverity.commit.defects.enabled set to true.
    81     Run the targets to commit the defects into database if coverity.commit.defects.enabled set to true.
    61     @type boolean
    82     @type boolean
    62     @scope private
    83     @scope private
    63     -->
    84     -->
   143     <property name="diamonds.coverity.report.file" value="${temp.build.dir}/${build.id}_coverity_build_report.xml"/>
   164     <property name="diamonds.coverity.report.file" value="${temp.build.dir}/${build.id}_coverity_build_report.xml"/>
   144     
   165     
   145     <!-- set property if coverity is enabled -->
   166     <!-- set property if coverity is enabled -->
   146     <condition property="internal.coverity.enabled">
   167     <condition property="internal.coverity.enabled">
   147         <or>
   168         <or>
   148             <istrue value="${coverity.enabled}" />
   169             <istrue value="${coverity.enabled}"/>
   149             <istrue value="${enabled.coverity}"/>
   170             <istrue value="${enabled.coverity}"/>
   150         </or>
   171         </or>
   151     </condition>
   172     </condition>
   152     
   173     
   153     <!-- set property if coverity.commit.defects.enabled is enabled -->
   174     <!-- set property if coverity.commit.defects.enabled is enabled -->
   154     <condition property="internal.coverity.commit.defects.enabled">
   175     <condition property="internal.coverity.commit.defects.enabled">
   155         <istrue value="${coverity.commit.defects.enabled}" />
   176         <istrue value="${coverity.commit.defects.enabled}"/>
   156     </condition>
   177     </condition>
   157     
   178     
   158     <if>
   179     <if>
   159         <isset property="env.NUMBER_OF_PROCESSORS"/>
   180         <isset property="env.NUMBER_OF_PROCESSORS"/>
   160         <then>
   181         <then>
   176         <arg name="--auto-diff" value=""/>
   197         <arg name="--auto-diff" value=""/>
   177         <arg name="--preprocess-first" value=""/>
   198         <arg name="--preprocess-first" value=""/>
   178         <arg name="--record-only" value=""/>
   199         <arg name="--record-only" value=""/>
   179     </hlm:coverityoptions>
   200     </hlm:coverityoptions>
   180     
   201     
   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 -->
   202     <!-- To run post coverity steps -->
   207     <target name="post-coverity" if="internal.coverity.enabled">
   203     <target name="post-coverity" if="internal.coverity.enabled">
   208         <mkdir dir="${post.log.dir}"/>
   204         <mkdir dir="${post.log.dir}"/>
       
   205         
   209         <!-- To emit the file into defect database -->
   206         <!-- To emit the file into defect database -->
   210         <antcall target="run-coverity-emit"/>
   207         <runtarget target="run-coverity-emit"/>
       
   208         
       
   209         <!-- To collect linkage information on all files -->
       
   210         <runtarget target="run-coverity-link"/>
   211         
   211         
   212         <!-- To analyze the sources file -->
   212         <!-- To analyze the sources file -->
   213         <antcall target="run-coverity-analyze"/>
   213         <runtarget target="run-coverity-analyze"/>
   214         
   214         
   215         <!-- To generate the HTML error pages -->
   215         <!-- To generate the HTML error pages -->
   216         <antcall target="gen-coverity-report"/>
   216         <runtarget target="gen-coverity-report"/>
   217         
   217         
   218         <!-- To commit the defects into coverity defect manager. -->
   218         <!-- To commit the defects into coverity defect manager. -->
   219         <antcall target="run-commit-defects"/>
   219         <runtarget 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" />
       
   233     </target>
   220     </target>
   234     
   221     
   235     <!-- Run coverity configure if the coverity.enabled is set to true -->
   222     <!-- Run coverity configure if the coverity.enabled is set to true -->
   236     <target name="run-coverity-configure" if="internal.coverity.enabled">
   223     <target name="run-coverity-configure" if="internal.coverity.enabled">
   237         <hlm:coverity command="cov-configure" dir="${build.drive}/">
   224         <mkdir dir="${compile.log.dir}"/>
   238             <hlm:coverityoptions refid="coverity.config.options"/>
   225         <!-- cov-config command options -->
   239         </hlm:coverity >
   226         <hlm:coverityoptions id="coverity.config.options">
       
   227             <hlm:arg name="--config" value="${coverity.config.dir}/coverity_config.xml"/>
       
   228             <hlm:arg name="--template" value=""/>
       
   229             <hlm:arg name="--comptype" value="armcc"/>
       
   230             <hlm:arg name="--compiler" value="armcc.exe"/>
       
   231         </hlm:coverityoptions>
       
   232         <hlm:runCoverityCommand errorlog="${compile.log.dir}/${build.id}_coverity_configure_errors.log"
       
   233             command="cov-configure"
       
   234             options="coverity.config.options"
       
   235             outputlog="${compile.log.dir}/${build.id}_coverity_configure_output.log"
       
   236         />
   240     </target>
   237     </target>
   241     
   238     
   242     <!-- Run coverity build with emit options if the coverity.enabled is set to true 
   239     <!-- Run coverity build with emit options if the coverity.enabled is set to true 
   243      re-running the cov-build with replay option will reduce the build time by ~ 20% 
   240      re-running the cov-build with replay option will reduce the build time by ~ 20% 
   244     -->
   241     -->
   245     <target name="run-coverity-emit" >
   242     <target name="run-coverity-emit">
   246         <hlm:coverity command="cov-build" dir="${build.drive}/" error="${post.log.dir}/${build.id}_coverity_command_errors.log" >
   243         <!-- cov-build emit command options -->
   247             <hlm:coverityoptions refid="coverity.emit.options"/>
   244         <hlm:coverityoptions id="coverity.emit.options">
   248         </hlm:coverity >
   245             <arg name="--config" value="${coverity.config.dir}/coverity_config.xml"/>
       
   246             <arg name="--dir" value="${coverity.inter.dir}"/>
       
   247             <arg name="--replay" value=""/>
       
   248             <arg name="--replay-processes" value="${coverity.no.thread}"/>
       
   249         </hlm:coverityoptions>
       
   250         <hlm:runCoverityCommand errorlog="${post.log.dir}/${build.id}_coverity_emit_errors.log"
       
   251             command="cov-build"
       
   252             options="coverity.emit.options"
       
   253             outputlog="${post.log.dir}/${build.id}_coverity_emit_output.log"
       
   254         />
   249     </target>
   255     </target>
   250     
   256     
   251     <!-- Run coverity-analyze if the coverity.enabled is set to true 
   257     <!-- Run coverity-analyze if the coverity.enabled is set to true 
   252      Sometimes the same file is compiled several times with different command-line options. 
   258      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. 
   259      Due to the inherent difficulty of tracking linkage information, the cov-analyze command cannot automatically determine which files are linked together. 
   258      working with link files is faster than collecting data from the intermediate directory multiple times
   264      working with link files is faster than collecting data from the intermediate directory multiple times
   259      
   265      
   260      So run the cov-link commands and analyze the database using cov-analyze command.
   266      So run the cov-link commands and analyze the database using cov-analyze command.
   261     
   267     
   262     -->
   268     -->
   263     <target name="run-coverity-analyze" >
   269     <target name="run-coverity-link" if="post.coverity.steps.enabled">
   264         <mkdir dir="${coverity.link.dir}"/>
   270         <mkdir dir="${coverity.link.dir}"/>
   265         <hlm:coverity command="cov-link" dir="${build.drive}/" error="${post.log.dir}/${build.id}_coverity_command_errors.log" append="true">
   271         
       
   272         <!-- Run cov-link with the -co and -of options to collect linkage information on all files compiled in an emit directory.-->        
       
   273         <hlm:coverityoptions id="coverity.link.all.options">
   266             <hlm:arg name="--dir" value="${coverity.inter.dir}"/>
   274             <hlm:arg name="--dir" value="${coverity.inter.dir}"/>
   267             <hlm:arg name="--collect" value=""/>
   275             <hlm:arg name="--collect" value=""/>
   268             <hlm:arg name="-of" value="${coverity.link.dir}/all.link"/>
   276             <hlm:arg name="-of" value="${coverity.link.dir}/all.link"/>
   269         </hlm:coverity >
   277         </hlm:coverityoptions>
   270         <hlm:coverity command="cov-link" dir="${build.drive}/" error="${post.log.dir}/${build.id}_coverity_command_errors.log" append="true">
   278         <hlm:runCoverityCommand errorlog="${post.log.dir}/${build.id}_coverity_link_errors.log" 
       
   279             command="cov-link" 
       
   280             options="coverity.link.all.options"
       
   281             outputlog="${post.log.dir}/${build.id}_coverity_link_output.log"
       
   282         />
       
   283         
       
   284         <!--Create one or more additional link files by filtering information using either an argument or a portion 
       
   285         of the pathname that was used during command-line compilation-->
       
   286         <hlm:coverityoptions id="coverity.link.options">
   271             <hlm:arg name="--dir" value="${coverity.inter.dir}"/>
   287             <hlm:arg name="--dir" value="${coverity.inter.dir}"/>
   272             <hlm:arg name="--compile-arg" value="armv5"/>
   288             <hlm:arg name="--compile-arg" value="armv5"/>
   273             <hlm:arg name="-of" value="${coverity.link.dir}/armv5.link"/>
   289             <hlm:arg name="-of" value="${coverity.link.dir}/armv5.link"/>
   274             <hlm:arg name="${coverity.link.dir}/all.link" value=""/>
   290             <hlm:arg name="${coverity.link.dir}/all.link" value=""/>
   275         </hlm:coverity >
   291         </hlm:coverityoptions>
   276         <hlm:coverity command="cov-link" dir="${build.drive}/" error="${post.log.dir}/${build.id}_coverity_command_errors.log" append="true">
   292         <hlm:runCoverityCommand errorlog="${post.log.dir}/${build.id}_coverity_link_errors.log"
       
   293             append="true"
       
   294             command="cov-link" 
       
   295             options="coverity.link.options"
       
   296             outputlog="${post.log.dir}/${build.id}_coverity_link_output.log"
       
   297         />
       
   298         
       
   299         <!--Use the link files created in the previous steps, and the emit repository in the original intermediate directory, to create a new 
       
   300         intermediate directory with an emit repository with resolved function calls -->
       
   301         <hlm:coverityoptions id="coverity.link.extract.options">
   277             <hlm:arg name="--dir" value="${coverity.inter.dir}"/>
   302             <hlm:arg name="--dir" value="${coverity.inter.dir}"/>
   278             <hlm:arg name="--output-dir" value="${coverity.analyze.dir}"/>
   303             <hlm:arg name="--output-dir" value="${coverity.analyze.dir}"/>
   279             <hlm:arg name="${coverity.link.dir}/armv5.link" value=""/>
   304             <hlm:arg name="${coverity.link.dir}/armv5.link" value=""/>
   280         </hlm:coverity >
   305         </hlm:coverityoptions>
   281         <hlm:coverity command="cov-analyze" dir="${build.drive}/" error="${post.log.dir}/${build.id}_coverity_command_errors.log" append="true">
   306         <hlm:runCoverityCommand errorlog="${post.log.dir}/${build.id}_coverity_link_errors.log" 
   282             <hlm:coverityoptions refid="coverity.analyze.options"/>
   307             append="true" 
   283         </hlm:coverity >
   308             command="cov-link" 
       
   309             options="coverity.link.extract.options"
       
   310             outputlog="${post.log.dir}/${build.id}_coverity_link_output.log"
       
   311         />
       
   312     </target>
       
   313     
       
   314     <!-- To analyze the sources file -->
       
   315     <target name="run-coverity-analyze" if="post.coverity.steps.enabled">
       
   316         
       
   317         <!-- cov-analyze command options -->
       
   318         <hlm:coverityoptions id="coverity.analyze.options">
       
   319             <hlm:arg name="--dir" value="${coverity.analyze.dir}"/>
       
   320             <hlm:arg name="--all" value=""/>
       
   321             <hlm:arg name="--symbian" value=""/>
       
   322             <hlm:arg name="--append" value=""/>
       
   323             <hlm:arg name="--enable-callgraph-metrics" value=""/>
       
   324         </hlm:coverityoptions>
       
   325         <hlm:runCoverityCommand errorlog="${post.log.dir}/${build.id}_coverity_analyze_errors.log" 
       
   326             command="cov-analyze" 
       
   327             options="coverity.analyze.options"
       
   328             outputlog="${post.log.dir}/${build.id}_coverity_analyze_output.log"
       
   329         />
       
   330         
   284     </target>
   331     </target>
   285     
   332     
   286     
   333     
   287     <!-- Generate coverity report -->
   334     <!-- Generate coverity report -->
   288     <target name="gen-coverity-report">
   335     <target name="gen-coverity-report" if="post.coverity.steps.enabled">
   289         <!-- Read the summary file generated by cov-analyze and generate html file -->
   336         <!-- 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"
   337         <fmpp sourceFile="${helium.dir}/tools/compile/templates/coverity.summary.html.ftl"
   291               outputFile="${temp.build.dir}/${build.id}_coverity_build_summary.html">
   338               outputFile="${temp.build.dir}/${build.id}_coverity_build_summary.html">
   292             <data   expandProperties="yes">
   339             <data   expandProperties="yes">
   293                     ant: antProperties()
   340                     ant: antProperties()
   294                     covsummary: slicedText (${coverity.analyze.dir}/c/output/summary.txt)
   341                     covsummary: slicedText (${coverity.analyze.dir}/c/output/summary.txt)
   295             </data>
   342             </data>
   296         </fmpp>
   343         </fmpp>
   297         
   344         
   298         <!-- To generate summary file for diamonds -->
   345         <!-- To generate summary file for diamonds -->
   299         <fmpp sourceFile="${helium.dir}/tools/common/templates/coverity/coverity.summary.xml.ftl"
   346         <fmpp sourceFile="${helium.dir}/tools/compile/templates/coverity.summary.xml.ftl"
   300               outputFile="${coverity.summary.xml.file}">
   347               outputFile="${coverity.summary.xml.file}">
   301             <data   expandProperties="yes">
   348             <data   expandProperties="yes">
   302                     ant: antProperties()
   349                     ant: antProperties()
   303                     covsummary: slicedText (${coverity.analyze.dir}/c/output/summary.txt)
   350                     covsummary: slicedText (${coverity.analyze.dir}/c/output/summary.txt)
   304             </data>
   351             </data>
   305         </fmpp>
   352         </fmpp>
   306         
   353         
   307         <!-- Run this to get the static html pages -->
   354         <!-- Run this to get the static html pages -->
   308         <hlm:coverity command="cov-format-errors" dir="${build.drive}/" error="${post.log.dir}/${build.id}_coverity_command_errors.log" append="true">
   355         <hlm:coverityoptions id="coverity.format.errors.options">
   309             <hlm:arg name="--dir" value="${coverity.analyze.dir}"/>
   356             <hlm:arg name="--dir" value="${coverity.analyze.dir}"/>
   310             <hlm:arg name="--filesort" value=""/>
   357             <hlm:arg name="--filesort" value=""/>
   311             <hlm:arg name="--functionsort" value=""/>
   358             <hlm:arg name="--functionsort" value=""/>
   312         </hlm:coverity >
   359         </hlm:coverityoptions>
       
   360         <hlm:runCoverityCommand errorlog="${post.log.dir}/${build.id}_coverity_format_errors.log" 
       
   361             command="cov-format-errors" 
       
   362             options="coverity.format.errors.options"
       
   363             outputlog="${post.log.dir}/${build.id}_coverity_format_ouput.log"
       
   364         />
   313         
   365         
   314         <!-- Copy the summary file to resolve the xml load error -->
   366         <!-- 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">
   367         <copy file="${coverity.analyze.dir}/c/output/errors/summary.xml" tofile="${coverity.checkers.xml.file}" overwrite="true" failonerror="false">
   316             <filterchain>
   368             <filterchain>
   317                 <linecontains negate="true">
   369                 <linecontains negate="true">
   339             <fileset dir="${temp.build.dir}" includes="${build.id}_coverity_build_summary.html"/>
   391             <fileset dir="${temp.build.dir}" includes="${build.id}_coverity_build_summary.html"/>
   340             <fileset dir="${coverity.analyze.dir}/c/output/errors" includes="index.html"/>
   392             <fileset dir="${coverity.analyze.dir}/c/output/errors" includes="index.html"/>
   341         </concat>
   393         </concat>
   342     </target>
   394     </target>
   343     
   395     
   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     
       
   372     <!-- To commit the coverity defects into coverity defect manager --> 
   396     <!-- 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">
   397     <target name="run-commit-defects" depends="coverity-username,coverity-password" if="internal.coverity.commit.defects.enabled">
   374         
   398         <if>
   375         <!-- Check is the coverity defect manager server and port numbers are set -->
   399             <istrue value="${post.coverity.steps.enabled}"/>
   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" 
   400             <then>
   377             unless="coverity.defect.manager.server"/>
   401                 <mkdir dir="${post.log.dir}"/>
   378         <fail message="FAILED: Coverity defect manager HTTP port number is not set. Please set 'coverity.defect.manager.port'." 
   402                 <!-- Check is the coverity defect manager server and port numbers are set -->
   379             unless="coverity.defect.manager.port"/>        
   403                 <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" 
   380         <!-- Check is the coverity defect manager server product is set to submit the coverity errors.-->
   404                     unless="coverity.defect.manager.server"/>
   381         <fail message="FAILED: Coverity defect manager product name is not set. Please set 'coverity.defect.manager.product'." 
   405                 <fail message="FAILED: Coverity defect manager HTTP port number is not set. Please set 'coverity.defect.manager.port'." 
   382             unless="coverity.defect.manager.product"/>
   406                     unless="coverity.defect.manager.port"/>        
   383         
   407                 <!-- Check is the coverity defect manager server product is set to submit the coverity errors.-->
   384         <!-- cov-commit-defects command options -->
   408                 <fail message="FAILED: Coverity defect manager product name is not set. Please set 'coverity.defect.manager.product'." 
   385         <hlm:coverityoptions id="coverity.commit.defects.options">
   409                     unless="coverity.defect.manager.product"/>
   386             <hlm:arg name="--config" value="${coverity.config.dir}/coverity_config.xml"/>
   410                 
   387             <hlm:arg name="--remote" value="${coverity.defect.manager.server}"/>
   411                 <!-- cov-commit-defects command options -->
   388             <hlm:arg name="--port" value="${coverity.defect.manager.port}"/>
   412                 <hlm:coverityoptions id="coverity.commit.defects.options">
   389             <hlm:arg name="--user" value="${coverity.username}"/>
   413                     <hlm:arg name="--config" value="${coverity.config.dir}/coverity_config.xml"/>
   390             <hlm:arg name="--password" value="${coverity.password}"/>
   414                     <hlm:arg name="--remote" value="${coverity.defect.manager.server}"/>
   391             <hlm:arg name="--dir" value="${coverity.analyze.dir}"/>
   415                     <hlm:arg name="--port" value="${coverity.defect.manager.port}"/>
   392             <hlm:arg name="--product" value="${coverity.defect.manager.product}"/>
   416                     <hlm:arg name="--user" value="${coverity.username}"/>
   393         </hlm:coverityoptions>
   417                     <hlm:arg name="--password" value="${coverity.password}"/>
   394         
   418                     <hlm:arg name="--dir" value="${coverity.analyze.dir}"/>
   395         <!-- Run the coverity commit defects command to submit the errors into defect manager -->
   419                     <hlm:arg name="--product" value="${coverity.defect.manager.product}"/>
   396         <hlm:coverity command="cov-commit-defects" dir="${build.drive}/" error="${post.log.dir}/${build.id}_coverity_command_errors.log" append="true">
   420                 </hlm:coverityoptions>
   397             <hlm:coverityoptions refid="coverity.commit.defects.options"/>
   421                 
   398         </hlm:coverity >
   422                 <!-- Run the coverity commit defects command to submit the errors into defect manager -->
       
   423                 <hlm:runCoverityCommand errorlog="${post.log.dir}/${build.id}_coverity_commit_defects_errors.log" 
       
   424                     command="cov-commit-defects" 
       
   425                     options="coverity.commit.defects.options"
       
   426                     outputlog="${post.log.dir}/${build.id}_coverity_commit_defects_ouput.log"
       
   427                 />
       
   428             </then>
       
   429         </if>
   399     </target>
   430     </target>
   400     
   431     
   401     <!-- Retrieve the coverity password from the .netrc file and store it into coverity.password property. -->
   432     <!-- 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">
   433     <target name="coverity-password" if="internal.coverity.commit.defects.enabled">
   403         <hlm:netrcPasswordMacro output-prop="coverity.password" result-prop="coverity.password.available" type="coverity"/>
   434         <hlm:netrcPasswordMacro output-prop="coverity.password" result-prop="coverity.password.available" type="coverity"/>
   407     <!-- Retrieve the coverity username from the .netrc file and store it into coverity.username property. -->
   438     <!-- 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">
   439     <target name="coverity-username" if="internal.coverity.commit.defects.enabled">
   409         <hlm:netrcUsernameMacro output-prop="coverity.username" result-prop="coverity.username.available" type="coverity"/>
   440         <hlm:netrcUsernameMacro output-prop="coverity.username" result-prop="coverity.username.available" type="coverity"/>
   410     </target>
   441     </target>
   411     
   442     
       
   443     
       
   444     <!-- To run coverity command and to check errors thrown by coverity commands -->
       
   445     <macrodef name="runCoverityCommand" uri="http://www.nokia.com/helium">
       
   446         <attribute name="errorlog"/>
       
   447         <attribute name="outputlog"/>
       
   448         <attribute name="command"/>
       
   449         <attribute name="append" default="false"/>
       
   450         <attribute name="options"/>
       
   451         <sequential>
       
   452             <var name="is.zero.coverity.errors" unset="true"/>
       
   453             <var name="is.zero.coverity.output.errors" unset="true"/>
       
   454             <var name="post.coverity.steps.enabled" unset="true"/>
       
   455             <var name="total.coverity.errors" unset="true"/>
       
   456             <var name="total.coverity.output.errors" unset="true"/>
       
   457             <hlm:coverity command="@{command}" dir="${build.drive}/" error="@{errorlog}" append="@{append}" output="@{outputlog}">
       
   458                 <hlm:coverityoptions refid="@{options}"/>
       
   459             </hlm:coverity>
       
   460             <hlm:metadatarecord database="${metadata.dbfile}">
       
   461                 <hlm:coveritymetadatainput>
       
   462                     <fileset casesensitive="false" file="@{errorlog}"/>
       
   463                     <metadatafilterset refid="filterset.coverity.error.cli"/>
       
   464                 </hlm:coveritymetadatainput>
       
   465             </hlm:metadatarecord>
       
   466             <hlm:metadataCountSeverity severity="ERROR" log="@{errorlog}" database="${metadata.dbfile}" property="total.coverity.errors"/>
       
   467             <echo>Coverity command '@{command}' errors: ${total.coverity.errors}</echo>
       
   468             <condition property="is.zero.coverity.errors">
       
   469                 <equals arg1="${total.coverity.errors}" arg2="0"/>
       
   470             </condition>
       
   471             <hlm:generateBuildStatus file="@{errorlog}"/>
       
   472             <hlm:signalMacro logfile="@{errorlog}" phase="post" signal.input="coveritySignalInput"/>
       
   473             <if>
       
   474                 <available file="@{outputlog}" />
       
   475                 <then>
       
   476                     <hlm:metadatarecord database="${metadata.dbfile}">
       
   477                         <hlm:coveritymetadatainput>
       
   478                             <fileset casesensitive="false" file="@{outputlog}"/>
       
   479                             <metadatafilterset refid="filterset.coverity.output.cli"/>
       
   480                         </hlm:coveritymetadatainput>
       
   481                     </hlm:metadatarecord>
       
   482                     <hlm:metadataCountSeverity severity="ERROR" log="@{outputlog}" database="${metadata.dbfile}" property="total.coverity.output.errors"/>
       
   483                     <echo>Coverity command '@{command}' errors: ${total.coverity.output.errors}</echo>
       
   484                     <condition property="is.zero.coverity.output.errors">
       
   485                         <equals arg1="${total.coverity.output.errors}" arg2="0"/>
       
   486                     </condition>
       
   487                     <hlm:generateBuildStatus file="@{outputlog}"/>
       
   488                     <hlm:signalMacro logfile="@{outputlog}" phase="post" signal.input="coveritySignalInput"/>
       
   489                 </then>
       
   490             </if>
       
   491             <condition property="post.coverity.steps.enabled">
       
   492                 <and>
       
   493                     <istrue value="${is.zero.coverity.errors}"/>
       
   494                     <istrue value="${is.zero.coverity.output.errors}"/>
       
   495                 </and>
       
   496             </condition>
       
   497         </sequential>
       
   498     </macrodef>
   412 </project>
   499 </project>