buildframework/helium/tools/compile/compile.ant.xml
changeset 179 d8ac696cc51f
parent 1 be27ed110b50
child 217 0f5e3a7fb6af
child 593 4367a1b2db65
equal deleted inserted replaced
1:be27ed110b50 179:d8ac696cc51f
    28 
    28 
    29     <!-- Property declaration -->
    29     <!-- Property declaration -->
    30     <property name="genxml.output.file.suffix" value="genxml" />
    30     <property name="genxml.output.file.suffix" value="genxml" />
    31     <property name="compile.sysdef.dtd.stub" location="${helium.dir}/tools/common/dtd/sysdef_dtd_1_4_0.xml" />
    31     <property name="compile.sysdef.dtd.stub" location="${helium.dir}/tools/common/dtd/sysdef_dtd_1_4_0.xml" />
    32     <property name="compile.signal.input" value="compileSignalInput" />
    32     <property name="compile.signal.input" value="compileSignalInput" />
    33     <property name="diamonds.compile.summary" location="${build.log.dir}/${build.id}_compile_diamonds.xml" />
    33     <property name="diamonds.compile.summary" location="${compile.log.dir}/${build.id}_compile_diamonds.xml" />
    34 
    34 
    35 
    35 
    36     <!-- including common compilation macros -->
    36     <!-- including common compilation macros -->
    37     <hlm:typedef file="${helium.dir}/tools/compile/compile.antlib.xml" uri="http://www.nokia.com/helium"/>
    37     <hlm:typedef file="${helium.dir}/tools/compile/compile.antlib.xml" uri="http://www.nokia.com/helium"/>
    38     <import file="cmaker.ant.xml" />
    38     <import file="cmaker.ant.xml" />
    55     <!-- Does all the necessary steps before starting the component build -->
    55     <!-- Does all the necessary steps before starting the component build -->
    56     <target name="precompile" depends="record-compile-start-time,create-canonical-sysdef-file,precompile-ec"/>
    56     <target name="precompile" depends="record-compile-start-time,create-canonical-sysdef-file,precompile-ec"/>
    57 
    57 
    58     <!-- post operation for EC builds, submits the compile time and lists all the built components-->
    58     <!-- post operation for EC builds, submits the compile time and lists all the built components-->
    59     <target name="postcompile" depends="postcompile-ec,render-build-duplicates" unless="env.HLM_SUBCON">
    59     <target name="postcompile" depends="postcompile-ec,render-build-duplicates" unless="env.HLM_SUBCON">
    60         <antcall target="submit-compile-time"/>
    60         <runtarget target="submit-compile-time"/>
    61     </target>
    61     </target>
    62     
    62     
    63     <!-- Pre-processes all System Definition input files.
    63     <!-- Pre-processes all System Definition input files.
    64 
    64 
    65     Any Ant properties used in the files will be replaced by their values.
    65     Any Ant properties used in the files will be replaced by their values.
    79         </fail>
    79         </fail>
    80 
    80 
    81         <for param="file">
    81         <for param="file">
    82             <resources refid="system.definition.files"/>
    82             <resources refid="system.definition.files"/>
    83             <sequential>
    83             <sequential>
    84                 <copy todir="${build.output.dir}/build/input"  verbose="true">
    84                 <copy todir="${build.output.dir}/build/input" verbose="true">
    85                     <fileset file="@{file}"/>
    85                     <fileset file="@{file}"/>
    86                     <filterchain>
    86                     <filterchain>
    87                         <replaceregex pattern="bldFile=&quot;common" replace="bldFile=&quot;src\\\\common" flags="gi"/>
    87                         <replaceregex pattern="bldFile=&quot;common" replace="bldFile=&quot;src\\\\common" flags="gi"/>
    88                         <replaceregex pattern="mrp=&quot;common" replace="mrp=&quot;src\\\\common" flags="gi"/>
    88                         <replaceregex pattern="mrp=&quot;common" replace="mrp=&quot;src\\\\common" flags="gi"/>
    89                         <replaceregex pattern="bldFile=&quot;cedar" replace="bldFile=&quot;src\\\\cedar" flags="gi"/>
    89                         <replaceregex pattern="bldFile=&quot;cedar" replace="bldFile=&quot;src\\\\cedar" flags="gi"/>
    90                         <replaceregex pattern="mrp=&quot;cedar" replace="mrp=&quot;src\\\\cedar" flags="gi"/>
    90                         <replaceregex pattern="mrp=&quot;cedar" replace="mrp=&quot;src\\\\cedar" flags="gi"/>
    91                         <expandproperties/>
    91                         <expandproperties/>
    92                     </filterchain>
    92                     </filterchain>
    93                     <mapper>
    93                     <mapper>
    94                         <scriptmapper language="beanshell">
    94                         <scriptmapper language="jython">
    95 <![CDATA[
    95 <![CDATA[
    96 import java.io.File;
    96 import os
    97 String counter = project.getProperty(".unique.counter");
    97 (drive, _) = os.path.splitdrive(r'@{file}')
    98 int count;
    98 path = r'@{file}'.replace(drive + os.sep, "", 1)
    99 if (counter == null){
    99 self.addMappedName(path)
   100     count = 0;
       
   101 }else{
       
   102     count = Integer.valueOf(counter) + 1;
       
   103 }
       
   104 project.setProperty(".unique.counter", ""+count);
       
   105 targetname = (String.format("%016d",count) + "_"+new File(source).getName());
       
   106 self.addMappedName(targetname);
       
   107 ]]>
   100 ]]>
   108                         </scriptmapper>
   101                         </scriptmapper>
   109                     </mapper>
   102                     </mapper>
   110                 </copy>
   103                 </copy>
   111             </sequential>
   104             </sequential>
   113     </target>
   106     </target>
   114 
   107 
   115 
   108 
   116     <!-- Merges all preprocessed System Definition files into one combined file. -->
   109     <!-- Merges all preprocessed System Definition files into one combined file. -->
   117     <target name="create-canonical-sysdef-file" depends="preprocess-sysdef-files">
   110     <target name="create-canonical-sysdef-file" depends="preprocess-sysdef-files">
   118         <pathconvert pathsep=" " property="system.definition.files.list">
   111         <if>
   119             <fileset dir="${build.output.dir}/build/input/" includes="*"/>
   112             <istrue value="${schema.new}" />
   120             <chainedmapper>
   113             <then>
   121                 <globmapper from="*" to="-x *" casesensitive="no"/>
   114                 <echo message="system model file: ${system.model.file}" />
   122             </chainedmapper>
   115                 <copy file="${system.model.file}" tofile="${build.drive}/sf/os/deviceplatformrelease/foundation_system/system_model/system_model.xml"/> 
   123         </pathconvert>
   116                 <hlm:joinSysdef epocroot="${build.drive}" srcfile="${build.drive}/sf/os/deviceplatformrelease/foundation_system/system_model/system_model.xml" 
   124         <hlm:compileGenxmlMergeMacro input="-x ${compile.sysdef.dtd.stub} ${system.definition.files.list}"
   117                     destfile="${canonical.sysdef.file}.join.xml" />
   125                                     output="${canonical.sysdef.file}"/>
   118                 <!-- <hlm:mergeSysdef epocroot="${epocroot}" destfile="${canonical.sysdef.file}" srcfile="${canonical.sysdef.file}.join.xml" downstreamfile="${epocroot}/layer2.sysdef.xml" /> -->
       
   119                 <hlm:downgradeSysdef epocroot="${build.drive}" srcfile="${canonical.sysdef.file}.join.xml" 
       
   120                     destfile="${canonical.sysdef.file}"/>
       
   121             </then>
       
   122             <else>
       
   123                 <pathconvert pathsep=" " property="system.definition.files.list">
       
   124                     <fileset dir="${build.output.dir}/build/input/" includes="**"/>
       
   125                     <chainedmapper>
       
   126                         <globmapper from="*" to="-x *" casesensitive="no"/>
       
   127                     </chainedmapper>
       
   128                 </pathconvert>
       
   129                 <hlm:compileGenxmlMergeMacro input="-x ${compile.sysdef.dtd.stub} ${system.definition.files.list}"
       
   130                                             output="${canonical.sysdef.file}" logfile="${compile.log.dir}/${build.id}.sysdef_GenxmlMerge.log"/>
       
   131             </else>
       
   132         </if>
   126     </target>
   133     </target>
   127 
   134 
   128     <!--
   135     <!--
   129       Supports a cleaning of binaries before starting compilation, based on a SysDef configuration.
   136       Supports a cleaning of binaries before starting compilation, based on a SysDef configuration.
   130       <deprecated>Please consider using ido-prep-clean target.</deprecated>
   137       <deprecated>Please consider using ido-prep-clean target.</deprecated>
   148             </or>
   155             </or>
   149             <then>
   156             <then>
   150                 <hlm:compileGenxmlMacro input="-x ${canonical.sysdef.file}"
   157                 <hlm:compileGenxmlMacro input="-x ${canonical.sysdef.file}"
   151                                         configuration="${sysdef.configuration}"
   158                                         configuration="${sysdef.configuration}"
   152                                         output="${genxml.output.file}"
   159                                         output="${genxml.output.file}"
   153                                         log="${build.log.dir}/${build.id}.${sysdef.configuration}_${genxml.output.file.suffix}.log" />
   160                                         log="${compile.log.dir}/${build.id}.${sysdef.configuration}_${genxml.output.file.suffix}.log" />
   154             </then>
   161             </then>
   155         </if>
   162         </if>
   156     </target>
   163     </target>
   157 
   164 
   158 
   165 
   219                 <if>
   226                 <if>
   220                     <not>
   227                     <not>
   221                         <isfalse value="${compile.discard.result}"/>
   228                         <isfalse value="${compile.discard.result}"/>
   222                     </not>
   229                     </not>
   223                     <then>
   230                     <then>
   224                         <delete file="${build.log.dir}/${build.id}.${sysdef.configuration}_compile.log.xml" failonerror="false"/>
   231                         <delete file="${compile.log.dir}/${build.id}.${sysdef.configuration}_compile.log.xml" failonerror="false"/>
   225                     </then>
   232                     </then>
   226                 </if>
   233                 </if>
   227             </then>
   234             </then>
   228             <else>
   235             <else>
   229                 <exec executable="perl" dir="${build.drive}/" output="${build.log.dir}/${build.id}.${sysdef.configuration}_scan1.log" failonerror="${failonerror}">
   236                 <exec executable="perl" dir="${build.drive}/" output="${compile.log.dir}/${build.id}.${sysdef.configuration}_scan1.log" failonerror="${failonerror}">
   230                     <arg value="${epocroot}epoc32/tools/scanlog.pl"/>
   237                     <arg value="${epocroot}epoc32/tools/scanlog.pl"/>
   231                     <arg file="${build.log.dir}/${build.id}.${sysdef.configuration}_compile.log"/>
   238                     <arg file="${compile.log.dir}/${build.id}.${sysdef.configuration}_compile.log"/>
   232                 </exec>
   239                 </exec>
   233                 <exec executable="perl" dir="${build.drive}/" failonerror="${failonerror}">
   240                 <exec executable="perl" dir="${build.drive}/" failonerror="${failonerror}">
   234                     <arg value="${epocroot}epoc32/tools/htmlscanlog.pl"/>
   241                     <arg value="${epocroot}epoc32/tools/htmlscanlog.pl"/>
   235                     <arg value="-v"/>
   242                     <arg value="-v"/>
   236                     <arg value="-v"/>
   243                     <arg value="-v"/>
   237                     <arg value="-l"/>
   244                     <arg value="-l"/>
   238                     <arg file="${build.log.dir}/${build.id}.${sysdef.configuration}_compile.log"/>
   245                     <arg file="${compile.log.dir}/${build.id}.${sysdef.configuration}_compile.log"/>
   239                     <arg value="-o"/>
   246                     <arg value="-o"/>
   240                     <arg file="${build.log.dir}/${build.id}.${sysdef.configuration}_scan2.html"/>
   247                     <arg file="${build.log.dir}/${build.id}.${sysdef.configuration}_scan2.html"/>
   241                 </exec>
   248                 </exec>
   242                 <hlm:assertFileExists file="${build.log.dir}/${build.id}.${sysdef.configuration}_scan2.html"/>
   249                 <hlm:assertFileExists file="${build.log.dir}/${build.id}.${sysdef.configuration}_scan2.html"/>
   243                 <if>
   250                 <if>
   247                     -->
   254                     -->
   248                     <isfalse value="${compile.discard.result}"/>
   255                     <isfalse value="${compile.discard.result}"/>
   249                     <then>
   256                     <then>
   250                         <hlm:metadatarecord database="${metadata.dbfile}">
   257                         <hlm:metadatarecord database="${metadata.dbfile}">
   251                             <hlm:abldmetadatainput>
   258                             <hlm:abldmetadatainput>
   252                                 <fileset casesensitive="false" file="${build.log.dir}/${build.id}.${sysdef.configuration}_compile.log" />
   259                                 <fileset casesensitive="false" file="${compile.log.dir}/${build.id}.${sysdef.configuration}_compile.log" />
   253                                 <metadatafilterset refid="filterset.compile" />
   260                                 <metadatafilterset refid="filterset.compile" />
   254                             </hlm:abldmetadatainput>
   261                             </hlm:abldmetadatainput>
   255                         </hlm:metadatarecord>
   262                         </hlm:metadatarecord>
   256                         <hlm:compileLogSignalMacro compile.summary.file="${build.id}.${sysdef.configuration}_compile.log" 
   263                         <hlm:compileLogSignalMacro compile.summary.file="${build.id}.${sysdef.configuration}_compile.log" 
   257                             error.limit="${build.errors.limit}" />
   264                             error.limit="${build.errors.limit}" phase="compile"/>
   258                         <!-- Todo: metadata: insert assertions for metadata parsing here -->
   265                         <!-- Todo: metadata: insert assertions for metadata parsing here -->
   259                     </then>
   266                     </then>
   260                 </if>
   267                 </if>
   261             </else>
   268             </else>
   262         </if>
   269         </if>
   354 f.write(output)
   361 f.write(output)
   355     ]]></scriptdef>
   362     ]]></scriptdef>
   356 
   363 
   357     <!-- Creates a .csv log of the sizes of all the binaries created in the build. -->
   364     <!-- Creates a .csv log of the sizes of all the binaries created in the build. -->
   358     <target name="binary-sizes-log" if="binary.sizes.output">
   365     <target name="binary-sizes-log" if="binary.sizes.output">
   359         <hlm:startSpecificLogMacro name="${build.log.dir}/${build.id}_binary_sizes.log"/>
   366         <hlm:startSpecificLogMacro name="${compile.log.dir}/${build.id}_binary_sizes.log" phase="compile"/>
   360         <property name="binary.sizes.output.file" location="${build.log.dir}/${build.id}_flash_image_size_data.csv"/>
   367         <property name="binary.sizes.output.file" location="${build.log.dir}/${build.id}_flash_image_size_data.csv"/>
   361         <pathconvert pathsep=";" property="build.logs.list">
   368         <pathconvert pathsep=";" property="build.logs.list">
   362             <fileset dir="${build.log.dir}" includes="*_build.log" excludes="*ant_build.log;*_zipup_build.log"/>
   369             <fileset dir="${compile.log.dir}" includes="*_build.log" excludes="*ant_build.log;*_zipup_build.log"/>
   363         </pathconvert>
   370         </pathconvert>
   364         <pathconvert pathsep=";" property="binary.sizes.rom.logs.list">
   371         <pathconvert pathsep=";" property="binary.sizes.rom.logs.list">
   365             <fileset refid="binary.sizes.rom.logs"/>
   372             <fileset refid="binary.sizes.rom.logs"/>
   366         </pathconvert>
   373         </pathconvert>
   367         <hlm:python>
   374         <hlm:python>
   368 import logging
   375 import logging
   369 
   376 import compilation
   370 import build.io
       
   371 import sysdef.api
   377 import sysdef.api
   372 import sysdef.io
       
   373 
       
   374 #logging.basicConfig(level=logging.DEBUG)
   378 #logging.basicConfig(level=logging.DEBUG)
   375 logging.basicConfig(level=logging.INFO)
   379 logging.basicConfig(level=logging.INFO)
   376 
   380 
   377 logging.info('Reading the System Sefinition information')
   381 logging.info('Reading the System Sefinition information')
   378 sysDef = sysdef.api.SystemDefinition(r'${canonical.sysdef.file}')
   382 sysDef = sysdef.api.SystemDefinition(r'${canonical.sysdef.file}')
   379 
   383 
       
   384 bnsizelogger = compilation.BinarySizeLogger(sysDef)
   380 # Read in the output binaries of each unit
   385 # Read in the output binaries of each unit
   381 logging.info('Reading the output binaries created by each unit.')
   386 bnsizelogger.read_output_binaries_per_unit(r'${build.logs.list}'.split(';'))
   382 build_logs = r'${build.logs.list}'.split(';')
       
   383 if len(build_logs) == 0:
       
   384     raise Exception('List of build logs is empty!')
       
   385 logging.info("The list of log files:\n")
       
   386 logging.info("\n".join(build_logs))
       
   387 for logpath in build_logs:
       
   388     binaries_reader = build.io.AbldLogWhatReader(logpath)
       
   389     sysDef.merge_binaries(binaries_reader)
       
   390 
   387 
   391 # Read in the binary sizes listed in the ROM output logs
   388 # Read in the binary sizes listed in the ROM output logs
   392 logging.info('Reading the binary sizes of each binary from ROM logs.')
   389 bnsizelogger.read_binary_sizes_in_rom_output_logs(r'${binary.sizes.rom.logs.list}'.split(';'))
   393 rom_logs = r'${binary.sizes.rom.logs.list}'.split(';')
       
   394 if len(rom_logs) == 0:
       
   395     raise Exception('List of ROM logs is empty!')
       
   396 logging.info("The list of log files:\n")
       
   397 logging.info("\n".join(rom_logs))
       
   398 for log in rom_logs:
       
   399     binary_sizes_reader = build.io.RombuildLogBinarySizeReader(log)
       
   400     sysDef.merge_binary_sizes(binary_sizes_reader)
       
   401 
   390 
   402 # Write out a .csv file containing
   391 # Write out a .csv file containing
   403 size_writer = sysdef.io.FlashImageSizeWriter(r'${binary.sizes.output.file}')
   392 bnsizelogger.write2csvfile(r'${binary.sizes.output.file}', r'${sysdef.configurations.list}'.split(','))
   404 size_writer.write(sysDef, r'${sysdef.configurations.list}'.split(','))
       
   405 size_writer.close()
       
   406         </hlm:python>
   393         </hlm:python>
   407         <hlm:assertFileExists file="${binary.sizes.output.file}"/>
   394         <hlm:assertFileExists file="${binary.sizes.output.file}"/>
   408         <hlm:stopSpecificLogMacro name="${build.log.dir}/${build.id}_binary_sizes.log"/>
   395         <hlm:stopSpecificLogMacro name="${compile.log.dir}/${build.id}_binary_sizes.log" phase="compile"/>
   409     </target>
   396     </target>
   410 
   397 
   411 
   398 
   412     <!-- Run codescanner to perform analysis on source code.
   399     <!-- Run codescanner to perform analysis on source code.
   413     Logs will be created under ${build.log.dir}/codescanner/
   400     Logs will be created under ${build.log.dir}/codescanner/