buildframework/helium/tools/compile/ec/ec.ant.xml
changeset 1 be27ed110b50
child 179 d8ac696cc51f
equal deleted inserted replaced
0:044383f39525 1:be27ed110b50
       
     1 <?xml version="1.0" encoding="UTF-8"?>
       
     2 <!-- 
       
     3 ============================================================================ 
       
     4 Name        : ec.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.ec" xmlns:hlm="http://www.nokia.com/helium">
       
    24     <description>
       
    25         EC compilation targets.
       
    26     </description>
       
    27 
       
    28     <property name="ec.emake" value="emake"/>
       
    29     <property name="ec.makefile.file" location="${build.drive}/Makefile"/>
       
    30 
       
    31     <property name="ec.sysdef2make" location="${helium.dir}/tools/compile/ec/sysdef2make.pl"/>
       
    32     
       
    33     <property name="ec.historyfile" value="${build.drive}/emake.data"/>
       
    34     <property name="ec.mem.limit" value="1000000000"/>
       
    35     
       
    36     <!-- This can be used to query cluster manager to find information about the build. Set
       
    37     to default as all the clusture supports default class id.-->
       
    38     <property name="ec.build.class" value="default"/>
       
    39     
       
    40 
       
    41     <!-- Converting cononical SDF into a Makefile. -->
       
    42     <target name="compile-genxml-ec" if="build.system.ec-helium">
       
    43         <!-- Using now the official script for GTI. -->
       
    44         <exec executable="perl" dir="${build.drive}/" error="${build.log.dir}/${build.id}.${sysdef.configuration}.sysdef2make.log" failonerror="${failonerror}">
       
    45             <arg line="${ec.sysdef2make} -n ${sysdef.configuration} -s ${env.EPOCROOT} -forcemake ((abld.*\-(w|what|c|check))|(abld.*resource)) ${canonical.sysdef.file}"/>
       
    46         </exec>
       
    47         <hlm:metadatarecord database="${metadata.dbfile}">
       
    48             <hlm:textmetadatainput>
       
    49                 <fileset casesensitive="false" file="${build.log.dir}/${build.id}.${sysdef.configuration}.sysdef2make.log"/>
       
    50                 <metadatafilterset refid="filterset.genxml.ec" />
       
    51             </hlm:textmetadatainput>
       
    52         </hlm:metadatarecord>
       
    53         <hlm:generateBuildStatus file="${build.id}.${sysdef.configuration}.sysdef2make.log" />
       
    54     </target>
       
    55 
       
    56     <!-- Locate the dependancy files from a previous build so that only those files that have been changed need to be compiled -->
       
    57     <scriptdef name="findHistoryFile" language="jython" uri="http://www.nokia.com/helium">
       
    58         <attribute name="history.dir"/>
       
    59         <attribute name="week.number"/>
       
    60         <attribute name="branch.name"/>
       
    61 <![CDATA[
       
    62 import os
       
    63 from build.ec import history
       
    64 
       
    65 file_name = "-1"
       
    66 branch_nm = ""
       
    67 hfm = history.HistoryFileManager(attributes.get('history.dir'), attributes.get('week.number'), attributes.get('branch.name'))
       
    68 hfm.findHistoryFilePath()
       
    69 file_name = hfm.findFile()
       
    70 
       
    71 if (file_name is not None):
       
    72     file_name = os.path.join(hfm.path, file_name)
       
    73 project.setProperty("ec.historyfile.previous", file_name)
       
    74 ]]>
       
    75     </scriptdef>
       
    76 
       
    77 
       
    78     <!-- Find the previous history file based on nearest release.
       
    79     week.number and branch.name property needs to be set by the product
       
    80     xml configuration. ec.historyfile.previous holds the matching history file
       
    81     for current builds week.number and branch.name.
       
    82     -->    
       
    83     <target name="find-previous-history-file" if="build.system.ec-helium">
       
    84         <echo message="history.dir:${ec.history.dir}" />
       
    85         <if>
       
    86             <isset property="branch.name" />
       
    87             <then>
       
    88                 <var name="ec.branch" value="${branch.name}" />
       
    89             </then>
       
    90             <else>
       
    91                 <var name="ec.branch" value="" />
       
    92             </else>
       
    93         </if>
       
    94         <hlm:findHistoryFile history.dir="${ec.history.dir}" week.number="${week.number}" branch.name="${ec.branch}" />
       
    95         <echo message="${week.number}" />
       
    96         <echo message="history.file:${ec.historyfile.previous}" />
       
    97         <if>
       
    98             <not>
       
    99                 <equals arg1="${ec.historyfile.previous}" arg2="-1" />
       
   100             </not>
       
   101             <then>
       
   102                 <if>
       
   103                     <available file="${ec.historyfile.previous}" />
       
   104                     <then>
       
   105                         <copy file="${ec.historyfile.previous}" tofile="${ec.historyfile}" overwrite="true" failonerror="false" />
       
   106                         <hlm:assertFileExists file="${ec.historyfile}"/>
       
   107                     </then>
       
   108                 </if>
       
   109             </then>
       
   110         </if>
       
   111     </target>
       
   112 
       
   113     <!-- Find the previous history file based on time stamps. This is used 
       
   114     only when week.number and branch.name not set by product configuration.
       
   115     ec.historyfile.previous holds the history file generated using previous 
       
   116     build.
       
   117     -->    
       
   118     <target name="reuse-previous-ec-history" if="build.system.ec-helium">
       
   119         <if>
       
   120             <available file="${ec.history.dir}" />
       
   121             <then>
       
   122                 <timestampselector property="ec.historyfile.previous">
       
   123                     <path>
       
   124                         <fileset dir="${ec.history.dir}">
       
   125                             <include name="*.data"/>
       
   126                         </fileset>
       
   127                     </path>
       
   128                 </timestampselector>
       
   129                 <if>
       
   130                     <available file="${ec.historyfile.previous}"/>
       
   131                     <then>
       
   132                         <copy file="${ec.historyfile.previous}" tofile="${ec.historyfile}" overwrite="true" failonerror="false" />
       
   133                         <hlm:assertFileExists file="${ec.historyfile}"/>
       
   134                     </then>
       
   135                 </if>
       
   136             </then>
       
   137         </if>
       
   138     </target>
       
   139     
       
   140     <!-- EC prequisites before compile. Finds the previous history file either 
       
   141     based on nearest release or timestamp. If there is no previous history file,
       
   142     it switches back to single node. If build has to run in serial mode, then ec.mode
       
   143     needs to be set to serial -->    
       
   144     <target name="precompile-ec" if="build.system.ec-helium">
       
   145         <if>
       
   146             <equals arg1="${ec.mode}" arg2="serial" />
       
   147             <then>
       
   148                 <echo message="Single Node Build : Mode Serial" />
       
   149                 <var name="ec.maxagents" value="1"/>
       
   150                 <var name="ec.history.option" value="create"/>
       
   151             </then>
       
   152             <else>
       
   153                 <property name="ec.maxagents" value="0"/>    
       
   154                 <property name="ec.history.option" value="merge"/>
       
   155                 <if>
       
   156                     <isset property="week.number"/>
       
   157                     <then>
       
   158                         <antcall target="find-previous-history-file"/>
       
   159                         <if>
       
   160                             <not>
       
   161                                 <available file="${ec.historyfile}"/>
       
   162                             </not>
       
   163                             <then>
       
   164                                 <echo message="Switching to Single Node Build" />
       
   165                                 <var name="ec.maxagents" value="1"/>
       
   166                                 <var name="ec.history.option" value="create"/>
       
   167                             </then>
       
   168                         </if>
       
   169                     </then>
       
   170                     <else>
       
   171                         <antcall target="reuse-previous-ec-history"/>
       
   172                     </else>
       
   173                 </if>
       
   174             </else>
       
   175         </if>
       
   176         <echo message="ec.mode:${ec.mode}" />
       
   177         <echo message="ec.maxagents:${ec.maxagents}"/>
       
   178         <echo message="ec.history.option:${ec.history.option}"/>
       
   179     </target>
       
   180 
       
   181     <!--
       
   182     The findUpdateHFPathMacro is used to find the history update dir. 
       
   183     -->
       
   184     <scriptdef name="findUpdateHFPathMacro" language="jython" uri="http://www.nokia.com/helium">
       
   185         <attribute name="history.dir"/>
       
   186         <attribute name="week.number"/>
       
   187         <attribute name="branch.name"/>
       
   188         <attribute name="property"/>
       
   189 <![CDATA[
       
   190 import os
       
   191 from build.ec import history
       
   192 hfm = history.HistoryFileManager(attributes.get('history.dir'), attributes.get('week.number'), attributes.get('branch.name'))
       
   193 file_path = hfm.findActualFilePath()
       
   194 project.setProperty(str(attributes.get('property')), str(file_path))
       
   195 ]]>
       
   196     </scriptdef>
       
   197 
       
   198 
       
   199     <!-- EC post compile operation copy history file back to network drive -->    
       
   200     <target name="postcompile-ec" if="build.system.ec-helium">
       
   201         <if>
       
   202             <and>
       
   203                 <isset property="week.number"/>
       
   204                 <available file="${ec.history.dir}"/>
       
   205             </and>
       
   206             <then>
       
   207                 <if>
       
   208                     <isset property="branch.name"/>
       
   209                     <then>
       
   210                         <var name="ec.branch" value="${branch.name}"/>
       
   211                     </then>
       
   212                     <else>
       
   213                         <var name="ec.branch" value=""/>
       
   214                     </else>
       
   215                 </if>
       
   216                 <hlm:findUpdateHFPathMacro history.dir="${ec.history.dir}" week.number="${week.number}" branch.name="${ec.branch}" property="ec.history.update.dir"/>
       
   217                 <mkdir dir="${ec.history.update.dir}"/>
       
   218                 <if>
       
   219                     <not>
       
   220                         <available file="${ec.history.update.dir}/tmp" type="dir"/>
       
   221                     </not>
       
   222                     <then>
       
   223                         <mkdir dir="${ec.history.update.dir}/tmp"/>
       
   224                         <move file="${ec.history.update.dir}/${week.number}.data" todir="${ec.history.update.dir}/tmp" failonerror="false"/>
       
   225                         <copy file="${ec.historyfile}" tofile="${ec.history.update.dir}/${week.number}.data" overwrite="true" failonerror="false" />
       
   226                         <delete dir="${ec.history.update.dir}/tmp"/>
       
   227                         <hlm:assertFileExists file="${ec.history.update.dir}/${week.number}.data"/>
       
   228                     </then>
       
   229                 </if>
       
   230             </then>
       
   231             <else>
       
   232                 <if>
       
   233                     <available file="${ec.history.dir}"/>
       
   234                     <then>
       
   235                         <copy file="${ec.historyfile}" tofile="${ec.history.dir}/${build.id}.data" overwrite="true" failonerror="false" />
       
   236                         <hlm:assertFileExists file="${ec.history.dir}/${build.id}.data"/>
       
   237                     </then>
       
   238                 </if>
       
   239             </else>
       
   240         </if>
       
   241     </target>
       
   242 
       
   243 
       
   244     <!-- Required Patches for symbian and java component build, before compiling EC-->    
       
   245     <target name="compile-ec-patch" unless="skip.compile-ec-patch">
       
   246         <echo>Patching....</echo>
       
   247         <for list="\epoc32\tools\abld.pl,\src\cedar\generic\tools\e32toolp\bldmake\abld.pl"
       
   248                 param="file" trim="true">
       
   249             <sequential>
       
   250                 <echo>Patching @{file}</echo>
       
   251                 <if>
       
   252                     <available file="${build.drive}/@{file}"/>
       
   253                     <then>
       
   254                         <move file="${build.drive}\@{file}.ec_orig" tofile="${build.drive}\@{file}" overwrite="true" failonerror="false"/>
       
   255                         <move file="${build.drive}\@{file}" tofile="${build.drive}\@{file}.ec_orig"/>
       
   256                         <!-- perl -Wpe "s/\"make/\"\$ENV\{MAKE\}/" -->
       
   257                         <exec executable="perl" dir="${build.drive}/" input="${build.drive}\@{file}.ec_orig"
       
   258                                                 output="${build.drive}\@{file}" failonerror="${failonerror}">
       
   259                             <arg value="-Wpe"/>                         
       
   260                             <arg value="s/\&quot;make/\&quot;\$ENV\{MAKE\}/"/>
       
   261                         </exec>
       
   262                     </then>
       
   263                 </if>
       
   264             </sequential>
       
   265         </for>
       
   266     </target>
       
   267 
       
   268     <!-- Unpatch symbian tool and java tool after compiling using EC-->    
       
   269     <target name="compile-ec-unpatch" unless="skip.compile-ec-patch">
       
   270         <echo>Rollback patches....</echo>
       
   271         <move file="${build.drive}\epoc32\tools\abld.pl.ec_orig" tofile="${build.drive}\epoc32\tools\abld.pl" overwrite="true"/>
       
   272     </target>
       
   273 
       
   274     <!-- EC logs compatible to EBS. Still some of the EC errors are not compatible to 
       
   275     EBS. 
       
   276     1. If the component path in the sysdef is not valid, then in EBS the component is 
       
   277     removed. In case of EC, the component is still built and there will be an error Make
       
   278     No rule to make such directory.
       
   279     2. If there is any error in building the component, the return value is compared in EBS
       
   280     build and transfered to proper error message. The error will be there in EC, but it is not
       
   281     transfered to proper error message. -->
       
   282     <target name="compile-ec-logs">
       
   283         <echo>Cleaning up the logs....</echo>
       
   284         <exec executable="perl" dir="${build.drive}/" failonerror="${failonerror}">
       
   285             <arg line="${helium.dir}/tools/compile/ec/ec_whatcheck.pl"/>
       
   286             <redirector input="${build.log.dir}/${build.id}.${sysdef.configuration}_build_output.log"
       
   287                 output="${build.log.dir}/${build.id}.${sysdef.configuration}_compile.log"/>
       
   288         </exec>
       
   289     </target>
       
   290 
       
   291 
       
   292     <!-- Build the component using EC. This is the only target for EC builds.
       
   293     It patches the necessary tools for EC builds, and call the emake with 
       
   294     necessary arguments.-->
       
   295     <target name="compile-ec-helium" if="build.system.ec-helium" depends="set-arm-version" >
       
   296         <mkdir dir="${build.output.dir}/ec/history"/>
       
   297         <antcall target="compile-ec-patch"/>
       
   298         <if>
       
   299             <isset property="env.EMAKE_DEBUG"/>
       
   300             <then>
       
   301                 <var name="emake_debug_flag" value="${env.EMAKE_DEBUG}"/>
       
   302             </then>
       
   303             <else>
       
   304                 <property name="emake_debug_flag" value="g"/>
       
   305             </else>
       
   306         </if>
       
   307         
       
   308         <echo>emake debug flag: ${emake_debug_flag}</echo>
       
   309 
       
   310         <echo>Building ${sysdef.configuration}....</echo>
       
   311         <echo file="${build.log.dir}/${build.id}.${sysdef.configuration}_run_emake.bat" level="info">
       
   312 set
       
   313 ${ec.emake} --emake-build-label=${build.id}.${sysdef.configuration} --emake-class=${ec.build.class} --emake-priority=normal --emake-maxagents=${ec.maxagents} --emake-job-limit=0 --emake-mem-limit=${ec.mem.limit} --emake-history=${ec.history.option} --emake-annodetail=basic,history,file,waiting --emake-annofile=${build.log.dir}\${build.id}.${sysdef.configuration}.emake.anno.xml --emake-historyfile=${ec.historyfile} --emake-debug=${emake_debug_flag} --emake-logfile=${build.log.dir}\${build.id}.${sysdef.configuration}.emake.g.dlog --emake-root=%EMAKE_ROOT%;${helium.dir} --emake-autodepend=1 -k -i -f ${build.drive}/${sysdef.configuration}.make LOGBUILDTIME=&quot;&quot; VERBOSE=&quot;&quot; SAVESPACE=&quot;&quot; ${sysdef.configuration}
       
   314         </echo>
       
   315 
       
   316         <exec executable="${build.log.dir}/${build.id}.${sysdef.configuration}_run_emake.bat"
       
   317               dir="${build.drive}/" output="${build.log.dir}/${build.id}.${sysdef.configuration}_build_output.log"
       
   318               failonerror="${failonerror}">
       
   319             <env key="SYMBIANBUILD_DEPENDENCYOFF" value="1" />
       
   320         </exec>
       
   321         
       
   322         <antcall target="compile-ec-unpatch"/>
       
   323         <antcall target="compile-ec-logs"/>
       
   324 
       
   325         <!-- Testing everything happens correctly. -->
       
   326         <hlm:assertFileExists file="${build.log.dir}/${build.id}.${sysdef.configuration}_run_emake.bat"/>
       
   327         <hlm:assertFileExists file="${build.log.dir}/${build.id}.${sysdef.configuration}_build_output.log"/>
       
   328         <hlm:assertFileExists file="${build.log.dir}/${build.id}.${sysdef.configuration}_compile.log"/>
       
   329         <hlm:calculateErrorsFromLog logfile="${build.log.dir}/${build.id}.${sysdef.configuration}_compile.log" />
       
   330     </target>
       
   331 </project>