buildframework/helium/tools/preparation/ido-prep.ant.xml
changeset 2 39c28ec933dd
equal deleted inserted replaced
1:820b22e13ff1 2:39c28ec933dd
       
     1 <?xml version="1.0" encoding="UTF-8"?>
       
     2 <!-- 
       
     3 ============================================================================ 
       
     4 Name        : ido-prep.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 <!--* @package preparation -->
       
    24 <project name="ido-prep" xmlns:hlm="http://www.nokia.com/helium">
       
    25     <description>
       
    26         IDO related targets.
       
    27          * Build area preparation
       
    28          * Codescanner integration
       
    29          * Cenrep generation (old way)
       
    30          * IBY export (old way)
       
    31     </description>
       
    32         
       
    33     <!-- Path to a INI file that contains the mapping between the ADO from Synergy WA and it's location on the BA.
       
    34     @type string
       
    35     @scope private
       
    36     -->
       
    37     <property name="ado.mapping.file" location="${build.output.dir}/build/ado_mapping.ini"/>
       
    38     <!-- Path to a INI file that contains the mapping between the ADO from Synergy WA and it's location on the BA for quality targets.
       
    39     @type string
       
    40     @scope private
       
    41     -->
       
    42     <property name="ado.quality.mapping.file" location="${build.output.dir}/build/ado_quality_mapping.ini"/>
       
    43     <!-- Path to the build romtree; the location contains iby files. Default value is "${build.drive}${env.EPOCROOT}/epoc32/rom/include"
       
    44     @type string
       
    45     @scope private
       
    46     -->
       
    47     <property name="ido.romtree" location="${build.drive}${env.EPOCROOT}/epoc32/rom/include"  />
       
    48     <!-- Path to the cenrep root. Default value is "${build.drive}${env.EPOCROOT}/epoc32/tools/cenrep/ido/src"
       
    49     @type string
       
    50     @scope private
       
    51     -->
       
    52     <property name="ido.cenrep.root" location="${build.drive}${env.EPOCROOT}/epoc32/tools/cenrep/ido/src"  />
       
    53     <!-- Path to the cenrep target directory. Default value is "${build.drive}${env.EPOCROOT}/epoc32/data/z/private/10202be9"
       
    54     @type string
       
    55     @scope private
       
    56     -->
       
    57     <property name="ido.cenrep.target" value="${build.drive}${env.EPOCROOT}/epoc32/data/z/private/10202be9"  />
       
    58     <!-- Defines the location of Codescanner output.
       
    59     @type string
       
    60     -->
       
    61     <property name="ido.codescanner.output.dir" location="${build.output.dir}/${build.id}_codescanner"/>
       
    62     
       
    63     <!-- Internal target that generates the '''ado.mapping.file'''.
       
    64      It is a INI file that contains ADO location as a key and target location as value.
       
    65     -->
       
    66     <target name="ido-create-ado-mapping">        
       
    67         <mkdir dir="${build.output.dir}/build"/>
       
    68         <mkdir dir="${temp.build.dir}"/>
       
    69         <tempfile property="prep.dynamic.sysdef.config" suffix=".txt" deleteonexit="false" destdir="${temp.build.dir}"/>
       
    70         <trycatch property="error.message">
       
    71             <try>
       
    72                 <hlm:referenceToFileMacro refid="system.definition.files" output="${prep.dynamic.sysdef.config}"/>
       
    73             </try>
       
    74             <catch>       
       
    75                 <propertyregex property="message" input="${error.message}"
       
    76                   regexp=":(.*)$"
       
    77                   select="\1" casesensitive="false" />
       
    78                 <fail message="Error: ${message}" />     
       
    79             </catch>               
       
    80         </trycatch>
       
    81         <trycatch>
       
    82             <try>
       
    83                 <pathconvert pathsep="," property="ado.quality.dirs.path">
       
    84                     <dirset refid="ado.quality.dirs"/>
       
    85                 </pathconvert>                              
       
    86             </try>
       
    87         </trycatch>
       
    88         <script language="jython" setbeans="false">
       
    89 import idoprep
       
    90 idoprep.create_ado_mapping(project.getProperty(r"prep.dynamic.sysdef.config"), project.getProperty(r"ado.mapping.file"), project.getProperty(r"ado.quality.mapping.file"), project.getProperty(r"build.drive"), project.getProperty("ado.quality.dirs.path"))
       
    91         </script>
       
    92     </target>
       
    93     
       
    94     <!-- Target to generate cenreps using cone tool -->
       
    95     <target name="ido-gen-cenrep">
       
    96         <mkdir dir="${post.log.dir}" />
       
    97         <for list="${sysdef.configurations.list}" delimiter="," param="sysdef.config">
       
    98             <sequential>
       
    99                 <var name="confml.log.file" unset="true"/>
       
   100                 <if>
       
   101                     <or>
       
   102                         <equals arg1="${build.system}" arg2="sbs" />
       
   103                         <equals arg1="${build.system}" arg2="sbs-ec" />
       
   104                     </or>
       
   105                     <then>
       
   106                         <hlm:getsbsinputs config="sbs.@{sysdef.config}" outputProperty="sbs.internal.inputs.list"/>
       
   107                         <for list="${sbs.internal.inputs.list}" delimiter="," param="sbs.input">
       
   108                             <sequential>
       
   109                                 <hlm:getVariableValue name="--logfile" property="sbs.log.file">
       
   110                                     <hlm:sbsinput refid="@{sbs.input}" />
       
   111                                 </hlm:getVariableValue>
       
   112                                 <property name="confml.log.file" value="${sbs.log.file}"/>
       
   113                             </sequential>
       
   114                         </for>
       
   115                     </then>
       
   116                     <else>
       
   117                         <property name="confml.log.file" value="${compile.log.dir}/${build.id}.@{sysdef.config}_compile.log"/>
       
   118                     </else>
       
   119                 </if>
       
   120             </sequential>
       
   121         </for>
       
   122         <echo>confml.log.file = ${confml.log.file}</echo>
       
   123         <if>
       
   124             <available file="${confml.log.file}"/>
       
   125             <then>
       
   126                 <hlm:grepMacro filename="${confml.log.file}" regexp="([^\\/.]*?)\.confml" output="confml.file.list"/>
       
   127                 <for list="${confml.file.list}" delimiter="," param="confml.file">
       
   128                     <sequential>
       
   129                         <var name="crml.regexp" unset="true"/>
       
   130                         <echo>confml.file = @{confml.file}</echo>
       
   131                         <hlm:conEToolMacro>
       
   132                             <arg name="output" value="${post.log.dir}/${build.id}_cenrep.cone.log"/>
       
   133                             <arg name="path" value="${build.drive}/epoc32/tools/" />
       
   134                             <arg name="-v" value="5" />
       
   135                             <arg name="-p" value="${build.drive}\epoc32\rom\config\assets\s60" />
       
   136                             <arg name="-o" value="${build.drive}\epoc32\release\winscw\urel\z" />
       
   137                             <arg name="-c" value="root.confml" />
       
   138                             <arg name="-i" value="@{confml.file}" />
       
   139                         </hlm:conEToolMacro>
       
   140                         <hlm:conEToolMacro>
       
   141                             <arg name="output" value="${post.log.dir}/${build.id}_cenrep.cone.log"/>
       
   142                             <arg name="path" value="${build.drive}/epoc32/tools/" />
       
   143                             <arg name="-v" value="5" />
       
   144                             <arg name="-p" value="${build.drive}\epoc32\rom\config\assets\s60" />
       
   145                             <arg name="-o" value="${build.drive}\epoc32\release\winscw\udeb\z" />
       
   146                             <arg name="-c" value="root.confml" />
       
   147                             <arg name="-i" value="@{confml.file}" />
       
   148                         </hlm:conEToolMacro>
       
   149                     </sequential>
       
   150                 </for>
       
   151             </then>
       
   152         </if>
       
   153         <copy file="${post.log.dir}/${build.id}_cenrep.cone.log" tofile="${temp.build.dir}/${build.id}_cenrep_includefile.txt" overwrite="true" failonerror="false">
       
   154             <filterchain>
       
   155                 <linecontainsregexp>
       
   156                     <regexp pattern="^\s*Generating file"/>
       
   157                 </linecontainsregexp>
       
   158             </filterchain>
       
   159         </copy>
       
   160         <hlm:metadatarecord database="${metadata.dbfile}">
       
   161             <hlm:textmetadatainput>
       
   162                 <fileset casesensitive="false" file="${post.log.dir}/${build.id}_cenrep.cone.log" />
       
   163                 <metadatafilterset>
       
   164                     <metadatafilter priority="error" regex="^ERROR\s+:.*" description="cone error" />
       
   165                     <metadatafilter priority="warning" regex="^WARNING\s+:.*" description="cone warnings" />
       
   166                     <metadatafilter priority="info" regex="^INFO\s+:.*" description="cone info" />
       
   167                 </metadatafilterset>
       
   168             </hlm:textmetadatainput>
       
   169         </hlm:metadatarecord>
       
   170         <hlm:metadataCountSeverity severity="ERROR" log="${build.id}_cenrep.cone.log" db="${metadata.dbfile}" property="cone.error.total"/>
       
   171         <echo>ConE error: ${cone.error.total}</echo>
       
   172         <hlm:generateBuildStatus file="${build.id}_cenrep.cone.log" />
       
   173     </target>
       
   174     
       
   175     <!-- Target that uses the information from the system.definition.files to prepare the IDO build area.
       
   176         It relies on the fact that layer_real_source_path entity is declared in each ADO configuration.
       
   177         
       
   178         By default it deletes the previous content. If you want to backup what was previoulsy used please
       
   179         defined '''ido.keep.old''' property.         
       
   180         -->
       
   181     <target name="ido-prep-copy" depends="ido-create-ado-mapping">
       
   182         <mkdir dir="${temp.build.dir}"/>
       
   183         <tempfile property="prep.dynamic.config" suffix=".xml" deleteonexit="false" destdir="${temp.build.dir}"/>
       
   184         
       
   185         <!-- new implementation that only rely on Ant -->
       
   186         <fmpp sourceFile="${helium.dir}/tools/common/templates/ido/ido-ant-delete.xml.ftl"
       
   187                      outputFile="${prep.dynamic.config}.clean.xml">
       
   188             <data expandProperties="yes">
       
   189                     inputfile: antProperty(ado.mapping.file)
       
   190                     ant: antProperties()
       
   191                         data: eval('
       
   192                                 java.io.FileInputStream pin = new java.io.FileInputStream(filename);
       
   193                                 java.util.Properties props = new java.util.Properties();
       
   194                                 props.load(pin);
       
   195                                 return props;
       
   196                                 ', {filename:get(inputfile)})
       
   197             </data>
       
   198         </fmpp>
       
   199         <ant antfile="${prep.dynamic.config}.clean.xml"/>
       
   200         
       
   201         <!-- new implementation that only rely on Ant -->
       
   202         <fmpp sourceFile="${helium.dir}/tools/common/templates/ido/ido-ant-copy.xml.ftl"
       
   203             outputFile="${prep.dynamic.config}">
       
   204             <data expandProperties="yes">
       
   205                 inputfile: antProperty(ado.mapping.file)
       
   206                 ant: antProperties()
       
   207                     data: eval('
       
   208                             java.io.FileInputStream pin = new java.io.FileInputStream(filename);
       
   209                             java.util.Properties props = new java.util.Properties();
       
   210                             props.load(pin);
       
   211                             return props;
       
   212                             ', {filename:get(inputfile)})
       
   213             </data>
       
   214         </fmpp>
       
   215         <ant antfile="${prep.dynamic.config}"/>
       
   216     </target>
       
   217     
       
   218     
       
   219     <!--
       
   220     Run cleanup system definition configuration. The configuration name are
       
   221     generated from the '''sysdef.configurations.list''' property, appending '_clean'
       
   222     at the end of each configuration also reversing their build order.
       
   223     if '''sysdef.clean.configurations.list''' is defined it overrides
       
   224     the previous beharvious and is used to cleanup the environment.
       
   225     -->
       
   226     <target name ="ido-prep-clean">
       
   227         <if>
       
   228             <not>
       
   229                 <isset property="sysdef.clean.configurations.list"/>
       
   230             </not>
       
   231             <then>
       
   232                 <if>
       
   233                     <isset property="sysdef.configurations.list"/>
       
   234                     <then>
       
   235                         <script language="jython" setbeans="false">
       
   236 rev_names = ""
       
   237 for sysdef in project.getProperty("sysdef.configurations.list").split(","):    
       
   238     rev_names = sysdef + "_clean," + rev_names;
       
   239 project.setProperty("sysdef.clean.configurations.list", rev_names)
       
   240                         </script>
       
   241                     </then>
       
   242                     <else>
       
   243                         <fail message="You should either define sysdef.clean.configurations.list or sysdef.configurations.list."/>
       
   244                     </else>
       
   245                 </if>
       
   246             </then>
       
   247         </if>
       
   248         
       
   249         <antcall target="compile-main">
       
   250             <param name="sysdef.configurations.list" value="${sysdef.clean.configurations.list}"/>
       
   251             <param name="compile.signal.input" value="compileCleanSignalInput"/>
       
   252             <param name="compile.discard.result" value="true"/>
       
   253             <param name="compile.cmd.clean" value="true"/>
       
   254         </antcall>
       
   255     </target>
       
   256 
       
   257 
       
   258 
       
   259     <!--
       
   260       Internal target that set an intermediate property to disable codescanner execution.
       
   261     -->
       
   262     <target name="ido-codescanner-skip">
       
   263         <condition property="do.skip.codescanner" value="1">
       
   264             <istrue value="${skip.codescanner}"/>
       
   265         </condition>
       
   266     </target>
       
   267 
       
   268     <!--
       
   269         This targets run the codescanner application on each discovered ADO.
       
   270         The location of the output is defined byt '''ido.codescanner.output.dir''' property.
       
   271         And the type is defined by '''ido.codescanner.output.type''' (default is HTML). 
       
   272     -->
       
   273     <target name="ido-codescanner" depends="ido-create-ado-mapping,ido-codescanner-skip" unless="do.skip.codescanner">
       
   274         <!--hlm:iniKeys2Path ini="${ado.mapping.file}" pathid="ado.src.path"/-->
       
   275         <!-- Defines the format of Codescanner output (html|xml|std).
       
   276         @type string
       
   277         -->
       
   278         <property name="ido.codescanner.output.type" value="html"/>
       
   279         <script language="jython" setbeans="false">
       
   280 """ internal.codescanner.drive """
       
   281 import os
       
   282 import fileutils
       
   283 import configuration
       
   284 import pathaddition.relative
       
   285 
       
   286 config = configuration.PropertiesConfiguration(stream=open(str(project.getProperty("ado.quality.mapping.file")), 'r'))
       
   287 prefix = pathaddition.relative.commonprefix(config.keys())
       
   288 if not os.path.exists(prefix):
       
   289     raise Exception("Could not find common prefix for the following paths:\n" + "\n".join(config.keys()))
       
   290 self.log(str('Substing %s' % prefix))
       
   291 drive = fileutils.get_next_free_drive()
       
   292 fileutils.subst(drive, prefix)
       
   293 project.setProperty('internal.codescanner.drive', drive)
       
   294 
       
   295 # creating the structure form subst drive.
       
   296 path = project.createDataType("path")
       
   297 for location in config.keys():
       
   298     self.log(str("From %s" % location))
       
   299     location = drive + os.sep + pathaddition.relative.abs2rel(location, prefix)
       
   300     self.log(str("To %s" % location))
       
   301     pe = path.createPathElement()
       
   302     pe.setPath(location)
       
   303 project.addReference('substed.ado.src.path', path)
       
   304         </script>
       
   305         <hlm:codescanner dest="${ido.codescanner.output.dir}"
       
   306             format="${ido.codescanner.output.type}"
       
   307             configuration="${ido.codescanner.config}">
       
   308             <path refid="substed.ado.src.path"/>
       
   309         </hlm:codescanner>
       
   310         <hlm:unsubst drive="${internal.codescanner.drive}"/>
       
   311     </target>
       
   312 
       
   313         <!-- CMT Tool target. Complexity tool measures. Supported options for cmt tool macro is
       
   314         1. input - files to be measured
       
   315         2. output - output xml file (file size is huge 68MB for JAVA IDO, if this needs to be send, need to consider
       
   316         3. config - input config . 
       
   317         -->
       
   318     <target name="ido-cmt" depends="ido-create-ado-mapping" if="enable.cmt">
       
   319         <fmpp sourceFile="${helium.dir}/tools/common/templates/ido/ido-cmt-ant.xml.ftl"
       
   320                           outputFile="${temp.build.dir}/ido-cmt.ant.xml">
       
   321             <data expandProperties="yes">
       
   322                         inputfile: antProperty(ado.quality.mapping.file)
       
   323                         ant: antProperties()
       
   324                             data: eval('
       
   325                                     java.io.FileInputStream pin = new java.io.FileInputStream(filename);
       
   326                                        java.util.Properties props = new java.util.Properties();
       
   327                                     props.load(pin);
       
   328                                     return props;
       
   329                                     ', {filename:get(inputfile)})
       
   330             </data>
       
   331         </fmpp>
       
   332         <ant antfile="${temp.build.dir}/ido-cmt.ant.xml"/>
       
   333     </target>
       
   334 
       
   335 
       
   336     <!-- Internal target that generates a temporary file that allow the 
       
   337     either export of iby or either key*.xls. The generated Ant build file
       
   338     contains two targets with copy insturctions and generic set of fileset rules.     
       
   339     -->
       
   340     <target name="ido-create-copy-file" depends="ido-create-ado-mapping">
       
   341         <tempfile property="copyfile.dynamic.config" suffix=".ant.xml" deleteonexit="false" destdir="${temp.build.dir}"/>
       
   342         <fmpp sourceFile="${helium.dir}/tools/common/templates/ido/ido-export.ant.xml.ftl"
       
   343                       outputFile="${copyfile.dynamic.config}">
       
   344             <data expandProperties="yes">
       
   345                 inputfile: antProperty(ado.mapping.file)
       
   346                 ant: antProperties()
       
   347                 data: eval('
       
   348                             java.io.FileInputStream pin = new java.io.FileInputStream(filename);
       
   349                                java.util.Properties props = new java.util.Properties();
       
   350                             props.load(pin);
       
   351                             return props;
       
   352                             ', {filename:get(inputfile)})
       
   353             </data>
       
   354         </fmpp>
       
   355     </target>
       
   356 
       
   357     <!-- Do the export of the ibys from ADO work area level to epoc32 tree. -->    
       
   358     <target name="ido-copy-iby" depends="ido-create-copy-file">
       
   359         <ant antfile="${copyfile.dynamic.config}" target="ido-copy-iby"/>
       
   360     </target>
       
   361 
       
   362     <!-- Do the export of the Excel keys*.xls from ADO work area level to 
       
   363     epoc32 tree.
       
   364     -->
       
   365     <target name="ido-copy-cenrep" depends="ido-create-copy-file">
       
   366         <delete dir="${ido.cenrep.root}"/>
       
   367         <mkdir dir="${ido.cenrep.root}"/>
       
   368         <ant antfile="${copyfile.dynamic.config}" target="ido-copy-cenrep"/>
       
   369     </target>
       
   370 
       
   371     <!-- Generated cenrep from exported keys*.xls files. -->
       
   372     <target name="ido-create-cenrep" depends="ido-copy-cenrep">
       
   373         <delete dir="${ido.cenrep.root}/../data"/>
       
   374         <mkdir dir="${ido.cenrep.root}/../data"/>
       
   375         <exec executable="perl" dir="${ido.cenrep.root}" failonerror="true">
       
   376             <arg value="${build.drive}/epoc32/tools/cenrep/generate_cenrep_inifile.pl"/>
       
   377             <arg value="-r"/>
       
   378             <arg value="${ido.cenrep.platform}"/>
       
   379             <arg value="-d"/>
       
   380             <arg value="${ido.cenrep.root}"/>
       
   381             <arg value="-rd"/>
       
   382             <arg value="${ido.cenrep.root}/../data"/>
       
   383         </exec>
       
   384         <!-- Copy generated files to target path -->
       
   385         <copy todir="${ido.cenrep.target}" verbose="true" flatten="true" overwrite="true">
       
   386             <fileset dir="${ido.cenrep.root}/../data">
       
   387                 <include name="*.txt"/>
       
   388             </fileset>
       
   389         </copy>    
       
   390         
       
   391     </target>
       
   392 
       
   393     <!-- Gets the contents from GRACE / Dragonfly -->
       
   394     <target name="ido-check-latest-release" depends="ido-check-latest-release-grace" unless="env.HLM_SUBCON">
       
   395         <runtarget target="ido-check-latest-release-dragonfly"/>
       
   396     </target>
       
   397 
       
   398     <!--* @property s60.grace.server
       
   399         UNC path to GRACE server.
       
   400         @type string
       
   401         @editable required
       
   402         @scope public
       
   403     -->
       
   404     <!--* @property s60.grace.service
       
   405         GRACE service to look into.
       
   406         @type string
       
   407         @editable required
       
   408         @scope public
       
   409     -->
       
   410     <!--* @property s60.grace.product
       
   411         GRACE product to look into.
       
   412         @type string
       
   413         @editable required
       
   414         @scope public
       
   415     -->
       
   416     <!--* @property s60.grace.release
       
   417         Regular expression to match a particular GRACE realease.
       
   418         @type string
       
   419         @editable required
       
   420         @scope public
       
   421     -->
       
   422     <!--* @property s60.grace.release.fixbuildregex
       
   423         Regular expression to match a particular GRACE release fixbuilds. Example _(.*?)$ or _(\d+)$ 
       
   424         @type string
       
   425         @editable required
       
   426         @scope public
       
   427     -->
       
   428     <!--* @property s60.grace.cache
       
   429         Location of the Grace result cache for a builder.
       
   430         @type string
       
   431         @editable required
       
   432         @scope public
       
   433     -->
       
   434     <!--* @property s60.grace.checkmd5
       
   435         Enable MD5 validation for GRACE metadata (default: false).
       
   436         @type boolean
       
   437         @editable required
       
   438         @scope public
       
   439     -->
       
   440     <!--* @property s60.grace.revision
       
   441         Defined the regular expression to find a particular revision.
       
   442         @type string
       
   443         @editable required
       
   444         @scope public
       
   445     -->
       
   446     <!--* @property s60.grace.usetickler
       
   447         Enable the detection of ready release using GRACE tickler mechanism.
       
   448         @type string
       
   449         @editable required
       
   450         @scope public
       
   451     -->
       
   452 
       
   453     <!-- Checks the contents from GRACE release. Mainly used by IDOs. But could be
       
   454     extended to product builds.-->    
       
   455     <target name="ido-check-latest-release-grace" unless="use.dragonfly">
       
   456         <script language="jython" setbeans="false">
       
   457 import os
       
   458 import idoprep
       
   459 
       
   460 result = idoprep.get_s60_env_details(project.getProperty('s60.grace.server'), project.getProperty('s60.grace.service'), project.getProperty('s60.grace.product'), project.getProperty('s60.grace.release'), project.getProperty('s60.grace.revision'), project.getProperty('s60.grace.cache'), project.getProperty('s60.grace.checkmd5'), project.getProperty('s60.grace.usetickler'))
       
   461 resultname = os.path.basename(result[0])
       
   462 project.setProperty('s60.getenv.path', str(result[0]))
       
   463 project.setProperty('s60.getenv.release', str(resultname))
       
   464 version = idoprep.get_version(project.getProperty('build.drive'), resultname)
       
   465 if version is None or version.strip() != resultname:
       
   466     project.setProperty('s60.getenv.update', "1")
       
   467         </script>
       
   468     </target>
       
   469 
       
   470     <!-- Updates the build area from either GRACE / dragonfly server.-->
       
   471     <target name="ido-update-build-area" depends="backup-subst-drives,ido-update-build-area-grace" unless="env.HLM_SUBCON">
       
   472         <runtarget target="ido-update-build-area-dragonfly"/>
       
   473     </target>
       
   474 
       
   475     <!-- Creates the build area by getting the contents from GRACE release.-->    
       
   476     <target name="ido-update-build-area-grace" if="s60.getenv.update" depends="ido-check-latest-release" unless="use.dragonfly">
       
   477         <!-- Just get S60 for IDOs -->
       
   478         <echo>Location of the new S60 release:${s60.getenv.path}</echo>
       
   479         <tstamp>
       
   480             <format property="getenv.tstamp" pattern="yyyyMMddHHmmss"/>
       
   481         </tstamp>
       
   482         <antcall target="init-drive">
       
   483             <param name="prep.build.dir" location="${prep.root.dir}/${getenv.tstamp}_${s60.getenv.release}"/>            
       
   484         </antcall>
       
   485         <antcall target="preparation-getenv">
       
   486             <param name="base_release.path" value="${s60.getenv.path}"/>
       
   487         </antcall>
       
   488         <antcall target="ido-prep-variant"/>
       
   489 
       
   490         <if>
       
   491             <not>
       
   492                 <hlm:hasSeverity severity="error" file="${build.cache.log.dir}/${build.id}_getenv.log.xml" />
       
   493             </not>
       
   494             <then>
       
   495                 <hlm:python>
       
   496 from path import path
       
   497 print "Writing version file...."
       
   498 vfile = path(r'${build.drive}'+"/").joinpath('s60_version.txt')
       
   499 f = open(str(vfile), 'w')
       
   500 f.write(path(r'${s60.getenv.path}').name)
       
   501 f.close()
       
   502                 </hlm:python>
       
   503             </then>
       
   504         </if>
       
   505     </target>
       
   506 
       
   507     <!-- Gets the Contents for particular variant, by unpacking the variant zip from the metadata file.-->
       
   508     <target name="ido-prep-variant" if="ido.variant">
       
   509         <script language="jython" setbeans="false">
       
   510 import re
       
   511 import os
       
   512 import symrec
       
   513 from com.nokia.ant.util import Helper
       
   514 rel_path = Helper.getProperty(project, 's60.getenv.path')
       
   515 metadata = symrec.find_latest_metadata(str(rel_path))
       
   516 self.log(str("Release metadata file: %s." % metadata))
       
   517 rel_metadata = symrec.ReleaseMetadata(metadata)
       
   518 variant_pkg = rel_metadata.getVariantPackage(project.getProperty('ido.variant'))
       
   519 project.setProperty('ido.variant.package', os.path.join(rel_path, variant_pkg))
       
   520         </script>
       
   521         <unzip src="${ido.variant.package}" dest="${build.drive}${env.EPOCROOT}"/>
       
   522     </target>
       
   523 
       
   524 
       
   525     <!-- This target will help CI tool to trigger a build by updating a 's60.getenv.trigger.location' file timestamp. -->
       
   526     <target name="ido-latest-release-trigger" if="s60.getenv.update" depends="ido-check-latest-release">
       
   527         <if>
       
   528             <isset property="s60.getenv.trigger.location"/>
       
   529             <then>
       
   530                 <echo>Touching the trigger.</echo>
       
   531                 <touch file="${s60.getenv.trigger.location}"/>
       
   532             </then>
       
   533             <else>
       
   534                 <echo>Property s60.getenv.trigger.location is not defined, trigger will not get updated.</echo>
       
   535             </else>
       
   536         </if>
       
   537     </target>
       
   538     
       
   539     <!-- Convert keys of an ini file into a path structure.
       
   540         e.g: <pre><hlm:iniKeys2Path ini="${ado.mapping.file}" pathid="ado.src.path"/></pre>
       
   541 
       
   542     Usage example:
       
   543       <pre>
       
   544         <target name="test-iniKeys2Path" depends="ido-create-ado-mapping">
       
   545             <hlm:iniKeys2Path ini="${ado.mapping.file}" pathid="ado.src.path"/>
       
   546             <hlm:codescanner dest="${build.drive}/codescanner">
       
   547                 <path refid="ado.src.path"/>
       
   548             </hlm:codescanner>
       
   549         </target>
       
   550         </pre>
       
   551     -->
       
   552     <scriptdef name="iniKeys2Path" language="beanshell" uri="http://www.nokia.com/helium">
       
   553         <attribute name="ini"/>
       
   554         <attribute name="pathid"/>
       
   555         if (attributes.get("ini") == null)
       
   556             throw new org.apache.tools.ant.BuildException("ini is not defined");
       
   557         if (attributes.get("pathid") == null)
       
   558             throw new org.apache.tools.ant.BuildException("pathid is not defined");
       
   559         try {
       
   560             java.io.FileInputStream pin = new java.io.FileInputStream(attributes.get("ini"));
       
   561             java.util.Properties props = new java.util.Properties();
       
   562             props.load(pin);
       
   563             org.apache.tools.ant.types.Path path = project.createDataType("path");
       
   564             for (java.util.Iterator i = props.stringPropertyNames().iterator(); i.hasNext() ; ) { 
       
   565                 org.apache.tools.ant.types.Path.PathElement pe = (org.apache.tools.ant.types.Path.PathElement)path.createPathElement();
       
   566                 pe.setPath(i.next()); 
       
   567             }
       
   568             self.log("Creating reference: " + attributes.get("pathid"));
       
   569             project.addReference(attributes.get("pathid"), path);
       
   570         } catch (Exception e) {
       
   571             throw new org.apache.tools.ant.BuildException(e);
       
   572         }
       
   573     </scriptdef>
       
   574 
       
   575     <!-- Target to get the Substituted drives information-->
       
   576     <target name="backup-subst-drives">
       
   577         <exec dir="${cache.dir}" executable="subst.exe" osfamily="windows" output="${cache.dir}\hlmsubsteddrives.bat" failonerror="false"/>
       
   578         <trycatch property="backup-subst-drives.exception">
       
   579             <try>
       
   580                 <if>
       
   581                     <available file="${cache.dir}/hlmsubsteddrives.bat" type="file"/>
       
   582                     <then>
       
   583                         <replaceregexp file="${cache.dir}\hlmsubsteddrives.bat" match="\\: => " replace=" " flags="g" byline="true"/>
       
   584                         <replaceregexp file="${cache.dir}\hlmsubsteddrives.bat" match="\A" replace="subst.exe " byline="true"/>
       
   585                         <replaceregexp file="${cache.dir}\hlmsubsteddrives.bat" match="UNC" replace="\\\\" byline="true"/>
       
   586                     </then>
       
   587                 </if>
       
   588             </try>
       
   589             <catch>
       
   590                 <echo>${backup-subst-drives.exception}</echo>
       
   591             </catch>
       
   592         </trycatch>
       
   593     </target>
       
   594 
       
   595     <import file="ci.ant.xml"/>
       
   596 </project>
       
   597 
       
   598 
       
   599 
       
   600