common/templates/source-spec.ant.xml.ftl
changeset 901 1bec8957803b
parent 898 79766bc6c419
child 909 869f7b50a6f1
equal deleted inserted replaced
900:ed28a33746f2 901:1bec8957803b
     1 <?xml version="1.0"?>
     1 <?xml version="1.0"?>
     2 <project name="SF-SOURCESPEC" default="all" xmlns:hlm="http://www.nokia.com/helium">
     2 <project name="SF-SOURCESPEC" default="all" xmlns:hlm="http://www.nokia.com/helium">
     3 
     3 
       
     4 <#assign dollar = "$"/>
       
     5 
       
     6     <!-- Convert \s in cache location, because otherwise they disappear entirely when used in a regex replacement! -->
       
     7     <propertyregex property="sf.spec.sourcesync.cachelocation.for.regex" input="${dollar}{sf.spec.sourcesync.cachelocation}" regexp="\\" replace="/" global="true" defaultValue="${dollar}{sf.spec.sourcesync.cachelocation}"/>
       
     8     
     4 <#assign fileset = "" />
     9 <#assign fileset = "" />
     5 <#assign sync_list = "" />
    10 <#assign sync_list = "" />
     6 <#assign bom_list  = "" />
    11 <#assign bom_list  = "" />
     7 <#assign change_list  = "" />
    12 <#assign change_list  = "" />
     8 <#assign dollar = "$"/>
       
     9 <#assign count = 0 />
    13 <#assign count = 0 />
    10 <#if ("${ant['sf.spec.sourcesync.archive']}")?? && "${ant['sf.spec.sourcesync.archive']}" == "true">
       
    11   <#assign fast_sync = true />
       
    12 <#else>
       
    13   <#assign fast_sync = false />
       
    14 </#if>
       
    15 <#if ("${ant['sf.spec.sourcesync.bug419']}")?? && "${ant['sf.spec.sourcesync.bug419']}" == "true">
       
    16   <#assign bug419 = true />
       
    17 <#else>
       
    18   <#assign bug419 = false />
       
    19 </#if>
       
    20 
       
    21     <!-- remove previous version of BOM file (if exists)  -->
       
    22     <target name="reset-bom-sources-csv">
       
    23         <delete file="${ant['build.drive']}/output/logs/BOM/sources.csv" quiet="true"/>
       
    24     </target>
       
    25 
    14 
    26 <#list data as csv_file>
    15 <#list data as csv_file>
    27   <#list csv_file as pkg_detail>
    16   <#list csv_file as pkg_detail>
    28     <target name="sf-prebuild-${count}">
    17     <target name="sf-prebuild-${count}">
    29         <sequential>
    18         
    30             <!-- create sf\layer dir  -->
    19         <!-- Create sf\layer dir on build dir -->
    31             <mkdir dir="${ant['build.drive']}${pkg_detail.dst}"/>
    20         <mkdir dir="${ant['build.drive']}${pkg_detail.dst}"/>
    32             <delete dir="${ant['build.drive']}${pkg_detail.dst}" failonerror="false" />
    21         <delete dir="${ant['build.drive']}${pkg_detail.dst}" failonerror="true" />
    33             <!-- Don't use hg archive with tags, as we can have wildcards in the tags... -->
    22         
    34             <#if fast_sync && ("${pkg_detail.type}"!="tag") > 
    23         <if>
    35               <!-- Identify the version on the cache first -->
    24             <istrue value="${dollar}{sf.spec.sourcesync.usecache}"/>
    36               <exec executable="hg" dir="${pkg_detail.source}" outputproperty="sf.sourcesync.${count}.checksum">
    25             <then>
    37                   <arg value="identify"/>
    26                 <!-- Work out cache location from source location -->
    38                   <arg value="-i"/>
    27                 <propertyregex property="sf.spec.sourcesync.cachelocation.${count}" input="${pkg_detail.source}" regexp="^http://developer.symbian.org/" casesensitive="false" replace="${dollar}{sf.spec.sourcesync.cachelocation.for.regex}/Live/"/>
    39                   <arg value="-r"/>
    28                 <propertyregex property="sf.spec.sourcesync.cachelocation.${count}" input="${pkg_detail.source}" regexp="^${ant['sf.spec.sourcesync.local.development.area']}/" casesensitive="false" replace="${dollar}{sf.spec.sourcesync.cachelocation.for.regex}/LocalDev/"/>
    40                   <arg value="${pkg_detail.pattern}"/>
    29             </then>
    41               </exec>
    30         </if>
    42               <!-- hg archive on the version we found -->
    31 	
    43               <exec executable="hg" dir="${pkg_detail.source}">
    32         <if>
    44                   <arg value="archive"/>
    33             <and>
    45                   <arg value="-r"/>
    34                 <isset property="sf.spec.sourcesync.cachelocation.${count}"/>
    46                   <arg value="${dollar}{sf.sourcesync.${count}.checksum}"/>
    35                 <available file="${dollar}{sf.spec.sourcesync.cachelocation.${count}}" type="dir"/>
    47                   <arg value="${ant['build.drive']}${pkg_detail.dst}"/>
    36             </and>
    48               </exec>
    37             <then>
    49             <#else>
    38                 <!-- Package in cache already -->
    50             <exec executable="hg" dir="${ant['build.drive']}">
    39                 <echo message="Pull from ${pkg_detail.source} to ${dollar}{sf.spec.sourcesync.cachelocation.${count}}"/>
    51                 <arg value="clone"/>
    40                 <exec executable="hg" dir="${dollar}{sf.spec.sourcesync.cachelocation.${count}}" failonerror="false" resultproperty="sf.spec.sourcesync.cache.pull.error.code.${count}">
    52                 <arg value="-U"/>
    41                     <arg value="pull"/>
    53                 <arg value="${pkg_detail.source}"/>
    42                     <arg value="${pkg_detail.source}"/>
    54                 <arg value="${ant['build.drive']}${pkg_detail.dst}"/>
    43                 </exec>
    55             </exec>
    44                 <if>
    56             
    45                     <equals arg1="0" arg2="${dollar}{sf.spec.sourcesync.cache.pull.error.code.${count}}"/>
    57             <#if bug419 >
    46                     <then>
    58               <exec executable="hg" dir="${ant['build.drive']}${pkg_detail.dst}" outputproperty="sf.sourcesync.${count}.checksum">
    47                         <echo message="Clone from ${dollar}{sf.spec.sourcesync.cachelocation.${count}} to ${ant['build.drive']}${pkg_detail.dst}"/>
    59                   <arg value="identify"/>
    48                         <exec executable="hg" dir="${ant['build.drive']}/" failonerror="true">
    60                   <arg value="-i"/>
    49                             <arg value="clone"/>
    61                   <arg value="-r"/>
    50                             <arg value="-U"/>
    62                   <arg value="${pkg_detail.pattern}"/>
    51                             <arg value="--uncompressed"/>
    63               </exec>
    52                             <arg value="${dollar}{sf.spec.sourcesync.cachelocation.${count}}"/>
    64               <exec executable="hg" dir="${ant['build.drive']}${pkg_detail.dst}">
    53                             <arg value="${ant['build.drive']}${pkg_detail.dst}"/>
    65                   <arg value="update"/>
    54                         </exec>
    66                   <arg value="-r"/>
    55                     </then>
    67                   <arg value="${dollar}{sf.sourcesync.${count}.checksum}"/>
    56                     <else>
    68               </exec>            
    57                         <!-- Uh oh - the cache is corrupted somehow -->
    69             <#else>
    58                         <!-- (Try to) recover the cache repo -->
    70             <hlm:scm verbose="true" scmUrl="scm:hg:${pkg_detail.source}">
    59                         <forget>
    71                 <!--hlm:checkout basedir="${ant['build.drive']}${pkg_detail.dst}"/-->
    60                             <exec executable="hg" dir="${dollar}{sf.spec.sourcesync.cachelocation.${count}}" failonerror="false" resultproperty="sf.spec.sourcesync.cache.recover.error.code.${count}">
    72                 <#if "${pkg_detail.type}"=="tag" >
    61                                 <arg value="recover"/>
    73                 <hlm:tags basedir="${ant['build.drive']}${pkg_detail.dst}" reference="hg.tags.id${dollar}{refid}"/>
    62                             </exec>
    74                 <hlm:update basedir="${ant['build.drive']}${pkg_detail.dst}">
    63                             <if>
    75                 <hlm:latestTag pattern="${pkg_detail.pattern}">
    64                                 <not><equals arg1="0" arg2="${dollar}{sf.spec.sourcesync.cache.recover.error.code.${count}}"/></not>
    76                         <hlm:tagSet refid="hg.tags.id${dollar}{refid}" />
    65                                 <then>
    77                 </hlm:latestTag>
    66                                     <echo message="Trashing ${dollar}{sf.spec.sourcesync.cachelocation.${count}} as broken"/>
    78                 </hlm:update>
    67                                     <delete dir="${dollar}{sf.spec.sourcesync.cachelocation.${count}}"/>
    79                 </#if>
    68                                 </then>
    80                 <#if "${pkg_detail.type}"== "changeset" || "${pkg_detail.type}"=="branch">
    69                             </if>
    81                 <hlm:update basedir="${ant['build.drive']}${pkg_detail.dst}">
    70                         </forget>
    82                      <hlm:tag name="${pkg_detail.pattern}"/>
    71                         <!-- In the meantime, by-pass it for this build -->
    83                 </hlm:update>
    72                         <echo message="Clone from ${pkg_detail.source} to ${ant['build.drive']}${pkg_detail.dst}"/>
    84                 </#if>
    73                         <exec executable="hg" dir="${ant['build.drive']}/" failonerror="true">
    85             </hlm:scm>
    74                             <arg value="clone"/>
    86             </#if>
    75                             <arg value="-U"/>
       
    76                             <arg value="${pkg_detail.source}"/>
       
    77                             <arg value="${ant['build.drive']}${pkg_detail.dst}"/>
       
    78                         </exec>
       
    79                     </else>
       
    80                 </if>
       
    81                 <!-- Update to required revision -->
       
    82                 <exec executable="hg" dir="${ant['build.drive']}${pkg_detail.dst}" failonerror="true">
       
    83                     <arg value="update"/>
       
    84                     <arg value="-r"/>
       
    85                     <arg value="${pkg_detail.pattern}"/>
       
    86                 </exec>
       
    87                 <!-- Record the changeset selected, for the BOM -->
    87                 <exec executable="hg" dir="${ant['build.drive']}${pkg_detail.dst}" outputproperty="sf.sourcesync.${count}.checksum">
    88                 <exec executable="hg" dir="${ant['build.drive']}${pkg_detail.dst}" outputproperty="sf.sourcesync.${count}.checksum">
    88                 <arg value="identify"/>
    89                     <arg value="identify"/>
    89                 <arg value="-i"/>
    90                     <arg value="-i"/>
    90             </exec>
    91                 </exec>
    91           </#if>  
    92             </then>
    92         </sequential>
    93             <else>
    93     </target>
    94                 <echo message="Clone from ${pkg_detail.source} to ${ant['build.drive']}${pkg_detail.dst}"/>
    94 
    95                 <exec executable="hg" dir="${ant['build.drive']}/" failonerror="true">
       
    96                     <arg value="clone"/>
       
    97                     <arg value="-U"/>
       
    98                     <arg value="${pkg_detail.source}"/>
       
    99                     <arg value="${ant['build.drive']}${pkg_detail.dst}"/>
       
   100                 </exec>
       
   101                 <!-- Update to required version -->
       
   102                 <exec executable="hg" dir="${ant['build.drive']}${pkg_detail.dst}" failonerror="true">
       
   103                     <arg value="update"/>
       
   104                     <arg value="-r"/>
       
   105                     <arg value="${pkg_detail.pattern}"/>
       
   106                 </exec>
       
   107                 <!-- Record the changeset selected, for the BOM -->
       
   108                 <exec executable="hg" dir="${ant['build.drive']}${pkg_detail.dst}" outputproperty="sf.sourcesync.${count}.checksum">
       
   109                     <arg value="identify"/>
       
   110                     <arg value="-i"/>
       
   111                 </exec>
       
   112                 <if>
       
   113                     <isset property="sf.spec.sourcesync.cachelocation.${count}"/>
       
   114                     <then>
       
   115                         <forget>
       
   116                             <nice newpriority="1"/>
       
   117                             <!-- Init cache -->
       
   118                             <mkdir dir="${dollar}{sf.spec.sourcesync.cachelocation.${count}}"/>
       
   119                             <delete dir="${dollar}{sf.spec.sourcesync.cachelocation.${count}}" failonerror="true" />
       
   120                             <echo message="Initialise cache at ${dollar}{sf.spec.sourcesync.cachelocation.${count}}"/>
       
   121                             <!-- Clone source to get the right default repo -->
       
   122                             <exec executable="hg" dir="${ant['build.drive']}/" failonerror="false">
       
   123                                 <arg value="clone"/>
       
   124                                 <arg value="-r"/>
       
   125                                 <arg value="null"/>
       
   126                                 <arg value="${pkg_detail.source}"/>
       
   127                                 <arg value="${dollar}{sf.spec.sourcesync.cachelocation.${count}}"/>
       
   128                             </exec>
       
   129                             <!-- Set the speed-up flag on the cache repo -->
       
   130                             <echo file="${dollar}{sf.spec.sourcesync.cachelocation.${count}}/.hg/hgrc" append="true" message="${dollar}{line.separator}"/>
       
   131                             <echo file="${dollar}{sf.spec.sourcesync.cachelocation.${count}}/.hg/hgrc" append="true" message="[server]${dollar}{line.separator}"/>
       
   132                             <echo file="${dollar}{sf.spec.sourcesync.cachelocation.${count}}/.hg/hgrc" append="true" message="uncompressed=True${dollar}{line.separator}"/>
       
   133                             <echo message="Push from ${ant['build.drive']}${pkg_detail.dst} to ${dollar}{sf.spec.sourcesync.cachelocation.${count}} in background"/>
       
   134                             <exec executable="hg" dir="${ant['build.drive']}${pkg_detail.dst}" failonerror="false">
       
   135                                 <arg value="push"/>
       
   136                                 <arg value="-f"/>
       
   137                                 <arg value="${dollar}{sf.spec.sourcesync.cachelocation.${count}}"/>
       
   138                             </exec>
       
   139                         </forget>
       
   140                     </then>
       
   141                 </if>
       
   142             </else>
       
   143         </if>
       
   144     </target>
       
   145     
    95     <target name="sf-bom-info-${count}">
   146     <target name="sf-bom-info-${count}">
    96         <sequential>
   147         <!-- record info on source code repo/rev in BOM file  -->
    97             <!-- record info on source code repo/rev in BOM file  -->
   148         <echo file="${ant['build.drive']}/output/logs/BOM/sources.csv" append="true" message="${pkg_detail.source},${pkg_detail.dst},changeset,${dollar}{sf.sourcesync.${count}.checksum},${pkg_detail.sysdef}${dollar}{line.separator}"/>
    98             <echo message="dir ${ant['build.drive']}${pkg_detail.dst} : ${dollar}{sf.sourcesync.${count}.checksum}"/>
   149     </target>
    99             <exec executable="cmd" output="${ant['build.drive']}/output/logs/BOM/sources.csv" append="true">
   150     
   100                 <arg value="/c"/>
       
   101                 <arg value="echo"/>
       
   102                 <arg value="${pkg_detail.source},${pkg_detail.dst},changeset,${dollar}{sf.sourcesync.${count}.checksum},${pkg_detail.sysdef}"/>
       
   103             </exec>
       
   104         </sequential>
       
   105     </target>
       
   106 
       
   107     <target name="sf-bom-change-info-${count}">
   151     <target name="sf-bom-change-info-${count}">
   108         <sequential>
   152         <if><not><isset property="sf.sourcesync.${count}.checksum"/></not>
   109       		<if><not><isset property="sf.sourcesync.${count}.checksum"/></not>
   153             <then>
   110       			<then>
   154                 <exec executable="hg" dir="${ant['build.drive']}${pkg_detail.dst}" outputproperty="sf.sourcesync.${count}.checksum">
   111               <exec executable="hg" dir="${ant['build.drive']}${pkg_detail.dst}" outputproperty="sf.sourcesync.${count}.checksum">
   155                     <arg value="identify"/>
   112                 <arg value="identify"/>
   156                     <arg value="-i"/>
   113                 <arg value="-i"/>
   157                 </exec>
   114               </exec>
   158             </then>
   115       			</then>
   159         </if>
   116       		</if>
   160         <echo message="Writing BOM changes since ${dollar}{sf.previous.pdk.tag} for ${pkg_detail.dst}" />
   117       		  <echo message="Writing BOM changes since ${dollar}{sf.previous.pdk.tag} for ${pkg_detail.dst}" />
   161         <echo file="${ant['build.drive']}/output/logs/BOM/changes.txt" append="true" message="${dollar}{line.separator}${pkg_detail.source}${dollar}{line.separator}${pkg_detail.dst}${dollar}{line.separator}${dollar}{line.separator}" />
   118       		  <echo file="${ant['build.drive']}/output/logs/BOM/changes.txt" append="true" message="${dollar}{line.separator}${pkg_detail.source}${dollar}{line.separator}${pkg_detail.dst}${dollar}{line.separator}${dollar}{line.separator}" />
   162             <exec executable="hg" dir="${ant['build.drive']}${pkg_detail.dst}" output="${ant['build.drive']}/output/logs/BOM/changes.txt" append="true">
   119             <#if fast_sync > 
       
   120               <exec executable="hg" dir="${pkg_detail.source}" output="${ant['build.drive']}/output/logs/BOM/changes.txt" append="true">
       
   121             <#else>      		  
       
   122               <exec executable="hg" dir="${ant['build.drive']}${pkg_detail.dst}" output="${ant['build.drive']}/output/logs/BOM/changes.txt" append="true">
       
   123             </#if>
       
   124                 <arg value="log"/>
   163                 <arg value="log"/>
   125                 <arg value="-r"/>
   164                 <arg value="-r"/>
   126                 <arg value="${dollar}{sf.sourcesync.${count}.checksum}:${dollar}{sf.previous.pdk.tag}"/>
   165                 <arg value="${dollar}{sf.sourcesync.${count}.checksum}:${dollar}{sf.previous.pdk.tag}"/>
   127                 <#if "${pkg_detail.type}"=="branch">
   166                 <#if "${pkg_detail.type}"=="branch">
   128                 <arg value="-b"/>
   167                 <arg value="-b"/>
   129                 <arg value="${pkg_detail.pattern}"/>
   168                 <arg value="${pkg_detail.pattern}"/>
   130                 </#if>    
   169                 </#if>    
   131             </exec>
   170             </exec>
   132           </sequential>
   171     </target>
   133     </target>
   172     
   134 
       
   135     <#assign fileset = "${fileset}" + "<fileset dir=\"${ant['build.drive']}${pkg_detail.dst}\" includes=\"${pkg_detail.sysdef}\"/>\r\n        " />       
   173     <#assign fileset = "${fileset}" + "<fileset dir=\"${ant['build.drive']}${pkg_detail.dst}\" includes=\"${pkg_detail.sysdef}\"/>\r\n        " />       
   136     <#assign sync_list = "${sync_list}" + "<runtarget target=\"sf-prebuild-${count}\"/>\r\n    "/>
   174     <#assign sync_list = "${sync_list}" + "<runtarget target=\"sf-prebuild-${count}\"/>\r\n            "/>
   137     <#assign bom_list = "${bom_list}" + "<runtarget target=\"sf-bom-info-${count}\"/>\r\n  "/>
   175     <#assign bom_list = "${bom_list}" + "<runtarget target=\"sf-bom-info-${count}\"/>\r\n        "/>
   138     <#assign change_list = "${change_list}" + "<runtarget target=\"sf-bom-change-info-${count}\"/>\r\n  "/>
   176     <#assign change_list = "${change_list}" + "<runtarget target=\"sf-bom-change-info-${count}\"/>\r\n        "/>
   139     <#assign count = count + 1 />
   177     <#assign count = count + 1 />
   140   </#list>
   178   </#list>
   141 </#list>
   179 </#list>
   142 
   180     
   143     <path id="system.definition.files">
   181     <path id="system.definition.files">
   144         <fileset dir="${dollar}{sf.common.config.dir}/sysdefs" includes="*.sysdef.xml"/>
   182         <fileset dir="${dollar}{sf.common.config.dir}/sysdefs" includes="*.sysdef.xml"/>
   145         ${fileset}
   183         ${fileset}
   146     </path>
   184     </path>
   147 
   185     
   148 <target name="all" depends="reset-bom-sources-csv">
   186     <target name="all">
   149   <parallel threadCount="${ant['env.NUMBER_OF_PROCESSORS']}">
   187         <parallel threadsPerProcessor="1" failonany="true">
   150     ${sync_list}
   188             ${sync_list}
   151   </parallel>
   189         </parallel>
   152 
   190         
   153   <echo message="Adding BOM header"/>
   191         <echo message="Adding BOM header"/>
   154       <mkdir dir="${ant['build.drive']}/output/logs/BOM/"/>
   192         <mkdir dir="${ant['build.drive']}/output/logs/BOM/"/>
   155       <exec executable="cmd" output="${ant['build.drive']}/output/logs/BOM/sources.csv" append="true">
   193         <echo file="${ant['build.drive']}/output/logs/BOM/sources.csv" message="source,dst,type,pattern,sysdef${dollar}{line.separator}"/>
   156       <arg value="/c"/>
   194         
   157       <arg value="echo"/>
   195         ${bom_list}
   158       <arg value="source,dst,type,pattern,sysdef"/>
   196         
   159   </exec>
   197         <delete file="${ant['build.drive']}/output/logs/BOM/changes.txt" quiet="true"/>
   160   
   198         
   161   ${bom_list}
   199         ${change_list}
   162   <runtarget target="sf-bom-change-info" />
   200     </target>
   163 </target>
   201     
   164 
       
   165 <target name="sf-bom-change-info">
       
   166   <mkdir dir="${ant['build.drive']}/output/logs/BOM/"/>
       
   167   <delete file="${ant['build.drive']}/output/logs/BOM/changes.txt" quiet="true"/>
       
   168 
       
   169   ${change_list}
       
   170 </target>
       
   171 
       
   172 </project>
   202 </project>