buildframework/helium/tools/compile/coverity.ant.xml
changeset 628 7c4a911dc066
parent 587 85df38eb4012
child 645 b8d81fa19e7d
equal deleted inserted replaced
588:c7c26511138f 628:7c4a911dc066
    24     <description>
    24     <description>
    25         code-coverity measure.
    25         code-coverity measure.
    26     </description>
    26     </description>
    27     
    27     
    28     <!-- Coverity property declaration and types defination-->
    28     <!-- Coverity property declaration and types defination-->
    29     <!--* @property enabled.coverity
    29     <!--* @property coverity.enabled
    30     Value must be set to execute coverity targets.
    30     Value must be set to execute coverity targets.
    31     @type boolean
    31     @type boolean
    32     @editable required
    32     @editable required
    33     @scope public
    33     @scope public
    34     -->
    34     @since 11.0
    35     <!--* @property run.coverity
    35     -->
    36     Value will be set to if enabled.coverity set tot true.
    36     
    37     @type string
    37     <!--* @property internal.coverity.enabled
    38     @scope private
    38     To run coverity related targets if coverity.enabled set to true.
    39     -->
    39     @type boolean
       
    40     @scope private
       
    41     -->
       
    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     
    40     <!-- coverity output directory location
    89     <!-- coverity output directory location
    41     @type string
    90     @type string
    42     @scope private
    91     @scope private
    43     -->
    92     -->
    44     <property name="coverity.output.dir" location="${build.output.dir}/coverity"/>
    93     <property name="coverity.output.dir" location="${build.output.dir}/coverity"/>
    60     <!-- coverity analyze directory location
   109     <!-- coverity analyze directory location
    61     @type string
   110     @type string
    62     @scope private
   111     @scope private
    63     -->
   112     -->
    64     <property name="coverity.analyze.dir" value="${coverity.link.dir}/analyze"/>
   113     <property name="coverity.analyze.dir" value="${coverity.link.dir}/analyze"/>
    65     <!-- coverity intermidiate directory location
   114     <!-- coverity intermediate directory location
    66     @type string
   115     @type string
    67     @scope private
   116     @scope private
    68     -->
   117     -->
    69     <property name="coverity.inter.dir" value="${coverity.output.dir}/intermidiate"/>
   118     <property name="coverity.inter.dir" value="${coverity.output.dir}/intermediate"/>
    70     <!-- coverity report directory location
   119     <!-- coverity report directory location
    71     @type string
   120     @type string
    72     @scope private
   121     @scope private
    73     -->
   122     -->
    74     <property name="coverity.report.dir" value="${coverity.output.dir}/coverity_report_${build.id}"/>
   123     <property name="coverity.report.dir" value="${coverity.output.dir}/coverity_report_${build.id}"/>
    90     <!-- diamonds coverity report file name
   139     <!-- diamonds coverity report file name
    91     @type string
   140     @type string
    92     @scope private
   141     @scope private
    93     -->
   142     -->
    94     <property name="diamonds.coverity.report.file" value="${temp.build.dir}/${build.id}_coverity_build_report.xml"/>
   143     <property name="diamonds.coverity.report.file" value="${temp.build.dir}/${build.id}_coverity_build_report.xml"/>
       
   144     
       
   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>
    95     
   157     
    96     <if>
   158     <if>
    97         <isset property="env.NUMBER_OF_PROCESSORS"/>
   159         <isset property="env.NUMBER_OF_PROCESSORS"/>
    98         <then>
   160         <then>
    99             <math result="coverity.no.thread" operand1="${env.NUMBER_OF_PROCESSORS}" operation="*" operand2="2" datatype="int"/>
   161             <math result="coverity.no.thread" operand1="${env.NUMBER_OF_PROCESSORS}" operation="*" operand2="2" datatype="int"/>
   105             -->
   167             -->
   106             <property name="coverity.no.thread" value="2"/>
   168             <property name="coverity.no.thread" value="2"/>
   107         </else>
   169         </else>
   108     </if>
   170     </if>
   109     
   171     
   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 -->
   172     <!-- cov-build command options -->
   116     <hlm:coverityoptions id="coverity.build.options">
   173     <hlm:coverityoptions id="coverity.build.options">
   117         <arg name="--config" value="${coverity.config.dir}/coverity_config.xml"/>
   174         <arg name="--config" value="${coverity.config.dir}/coverity_config.xml"/>
   118         <arg name="--dir" value="${coverity.inter.dir}"/>
   175         <arg name="--dir" value="${coverity.inter.dir}"/>
   119         <arg name="--auto-diff" value=""/>
   176         <arg name="--auto-diff" value=""/>
   145         <hlm:arg name="--append" value=""/>
   202         <hlm:arg name="--append" value=""/>
   146         <hlm:arg name="--enable-callgraph-metrics" value=""/>
   203         <hlm:arg name="--enable-callgraph-metrics" value=""/>
   147     </hlm:coverityoptions>
   204     </hlm:coverityoptions>
   148 
   205 
   149     <!-- To run post coverity steps -->
   206     <!-- To run post coverity steps -->
   150     <target name="post-coverity" if="run.coverity">
   207     <target name="post-coverity" if="internal.coverity.enabled">
   151         
   208         <mkdir dir="${post.log.dir}"/>
   152         <!-- To emit the file into defect database -->
   209         <!-- To emit the file into defect database -->
   153         <antcall target="run-coverity-emit"/>
   210         <antcall target="run-coverity-emit"/>
   154         
   211         
   155         <!-- To analyze the sources file -->
   212         <!-- To analyze the sources file -->
   156         <antcall target="run-coverity-analyze"/>
   213         <antcall target="run-coverity-analyze"/>
   157         
   214         
   158         <!-- To generate the HTML error pages -->
   215         <!-- To generate the HTML error pages -->
   159         <antcall target="gen-coverity-report"/>
   216         <antcall target="gen-coverity-report"/>
   160     
   217         
   161     </target>
   218         <!-- To commit the defects into coverity defect manager. -->
   162     
   219         <antcall target="run-commit-defects"/>
   163     <!-- Run coverity configure if the enabled.coverity is set to true -->
   220         
   164     <target name="run-coverity-configure" if="run.coverity">
   221         <hlm:metadatarecord database="${metadata.dbfile}">
   165     
   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>
       
   234     
       
   235     <!-- Run coverity configure if the coverity.enabled is set to true -->
       
   236     <target name="run-coverity-configure" if="internal.coverity.enabled">
   166         <hlm:coverity command="cov-configure" dir="${build.drive}/">
   237         <hlm:coverity command="cov-configure" dir="${build.drive}/">
   167             <hlm:coverityoptions refid="coverity.config.options"/>
   238             <hlm:coverityoptions refid="coverity.config.options"/>
   168         </hlm:coverity >
   239         </hlm:coverity >
   169         
   240     </target>
   170     </target>
   241     
   171     
   242     <!-- Run coverity build with emit options if the coverity.enabled is set to true 
   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% 
   243      re-running the cov-build with replay option will reduce the build time by ~ 20% 
   174     -->
   244     -->
   175     <target name="run-coverity-emit" >
   245     <target name="run-coverity-emit" >
   176         
   246         <hlm:coverity command="cov-build" dir="${build.drive}/" error="${post.log.dir}/${build.id}_coverity_command_errors.log" >
   177         <hlm:coverity command="cov-build" dir="${build.drive}/">
       
   178             <hlm:coverityoptions refid="coverity.emit.options"/>
   247             <hlm:coverityoptions refid="coverity.emit.options"/>
   179         </hlm:coverity >
   248         </hlm:coverity >
   180         
   249     </target>
   181     </target>
   250     
   182     
   251     <!-- Run coverity-analyze if the coverity.enabled is set to true 
   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. 
   252      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. 
   253      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. 
   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. 
   187      
   255      
   188      and also
   256      and also
   191      
   259      
   192      So run the cov-link commands and analyze the database using cov-analyze command.
   260      So run the cov-link commands and analyze the database using cov-analyze command.
   193     
   261     
   194     -->
   262     -->
   195     <target name="run-coverity-analyze" >
   263     <target name="run-coverity-analyze" >
   196         
       
   197         <mkdir dir="${coverity.link.dir}"/>
   264         <mkdir dir="${coverity.link.dir}"/>
   198         
   265         <hlm:coverity command="cov-link" dir="${build.drive}/" error="${post.log.dir}/${build.id}_coverity_command_errors.log" append="true">
   199         <hlm:coverity command="cov-link" dir="${build.drive}/">
       
   200             <hlm:arg name="--dir" value="${coverity.inter.dir}"/>
   266             <hlm:arg name="--dir" value="${coverity.inter.dir}"/>
   201             <hlm:arg name="--collect" value=""/>
   267             <hlm:arg name="--collect" value=""/>
   202             <hlm:arg name="-of" value="${coverity.link.dir}/all.link"/>
   268             <hlm:arg name="-of" value="${coverity.link.dir}/all.link"/>
   203         </hlm:coverity >
   269         </hlm:coverity >
   204                 
   270         <hlm:coverity command="cov-link" dir="${build.drive}/" error="${post.log.dir}/${build.id}_coverity_command_errors.log" append="true">
   205         <hlm:coverity command="cov-link" dir="${build.drive}/">
       
   206             <hlm:arg name="--dir" value="${coverity.inter.dir}"/>
   271             <hlm:arg name="--dir" value="${coverity.inter.dir}"/>
   207             <hlm:arg name="--compile-arg" value="armv5"/>
   272             <hlm:arg name="--compile-arg" value="armv5"/>
   208             <hlm:arg name="-of" value="${coverity.link.dir}/armv5.link"/>
   273             <hlm:arg name="-of" value="${coverity.link.dir}/armv5.link"/>
   209             <hlm:arg name="${coverity.link.dir}/all.link" value=""/>
   274             <hlm:arg name="${coverity.link.dir}/all.link" value=""/>
   210         </hlm:coverity >
   275         </hlm:coverity >
   211              
   276         <hlm:coverity command="cov-link" dir="${build.drive}/" error="${post.log.dir}/${build.id}_coverity_command_errors.log" append="true">
   212         <hlm:coverity command="cov-link" dir="${build.drive}/">
       
   213             <hlm:arg name="--dir" value="${coverity.inter.dir}"/>
   277             <hlm:arg name="--dir" value="${coverity.inter.dir}"/>
   214             <hlm:arg name="--output-dir" value="${coverity.analyze.dir}"/>
   278             <hlm:arg name="--output-dir" value="${coverity.analyze.dir}"/>
   215             <hlm:arg name="${coverity.link.dir}/armv5.link" value=""/>
   279             <hlm:arg name="${coverity.link.dir}/armv5.link" value=""/>
   216         </hlm:coverity >
   280         </hlm:coverity >
   217                 
   281         <hlm:coverity command="cov-analyze" dir="${build.drive}/" error="${post.log.dir}/${build.id}_coverity_command_errors.log" append="true">
   218         <hlm:coverity command="cov-analyze" dir="${build.drive}/">
       
   219             <hlm:coverityoptions refid="coverity.analyze.options"/>
   282             <hlm:coverityoptions refid="coverity.analyze.options"/>
   220         </hlm:coverity >
   283         </hlm:coverity >
   221         
       
   222     </target>
   284     </target>
   223     
   285     
   224     
   286     
   225     <!-- Generate coverity report -->
   287     <!-- Generate coverity report -->
   226     <target name="gen-coverity-report">
   288     <target name="gen-coverity-report">
   227         
       
   228         <!-- Read the summary file generated by cov-analyze and generate html file -->
   289         <!-- 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"
   290         <fmpp sourceFile="${helium.dir}/tools/common/templates/coverity/coverity.summary.html.ftl"
   230               outputFile="${temp.build.dir}/${build.id}_coverity_build_summary.html">
   291               outputFile="${temp.build.dir}/${build.id}_coverity_build_summary.html">
   231             <data   expandProperties="yes">
   292             <data   expandProperties="yes">
   232                     ant: antProperties()
   293                     ant: antProperties()
   242                     covsummary: slicedText (${coverity.analyze.dir}/c/output/summary.txt)
   303                     covsummary: slicedText (${coverity.analyze.dir}/c/output/summary.txt)
   243             </data>
   304             </data>
   244         </fmpp>
   305         </fmpp>
   245         
   306         
   246         <!-- Run this to get the static html pages -->
   307         <!-- Run this to get the static html pages -->
   247         <hlm:coverity command="cov-format-errors" dir="${build.drive}/">
   308         <hlm:coverity command="cov-format-errors" dir="${build.drive}/" error="${post.log.dir}/${build.id}_coverity_command_errors.log" append="true">
   248             <hlm:arg name="--dir" value="${coverity.analyze.dir}"/>
   309             <hlm:arg name="--dir" value="${coverity.analyze.dir}"/>
   249             <hlm:arg name="--filesort" value=""/>
   310             <hlm:arg name="--filesort" value=""/>
   250             <hlm:arg name="--functionsort" value=""/>
   311             <hlm:arg name="--functionsort" value=""/>
   251         </hlm:coverity >
   312         </hlm:coverity >
   252         
   313         
   276         <!-- Concatinate all the html pages to get the final error report page -->
   337         <!-- Concatinate all the html pages to get the final error report page -->
   277         <concat destfile="${coverity.report.dir}/${coverity.report.file}">
   338         <concat destfile="${coverity.report.dir}/${coverity.report.file}">
   278             <fileset dir="${temp.build.dir}" includes="${build.id}_coverity_build_summary.html"/>
   339             <fileset dir="${temp.build.dir}" includes="${build.id}_coverity_build_summary.html"/>
   279             <fileset dir="${coverity.analyze.dir}/c/output/errors" includes="index.html"/>
   340             <fileset dir="${coverity.analyze.dir}/c/output/errors" includes="index.html"/>
   280         </concat>
   341         </concat>
   281         
       
   282     </target>
   342     </target>
   283     
   343     
   284     
   344     
   285     <!-- To get the SBS variable value -->
   345     <!-- To get the SBS variable value -->
   286     <macrodef name="getSBSVariableValue" uri="http://www.nokia.com/helium">
   346     <macrodef name="getSBSVariableValue" uri="http://www.nokia.com/helium">
   307                 ]]>
   367                 ]]>
   308             </script> 
   368             </script> 
   309         </sequential>
   369         </sequential>
   310     </macrodef>
   370     </macrodef>
   311     
   371     
   312 
   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     
   313 </project>
   412 </project>