buildframework/helium/tools/publish/publish.ant.xml
changeset 179 d8ac696cc51f
parent 1 be27ed110b50
child 217 0f5e3a7fb6af
equal deleted inserted replaced
1:be27ed110b50 179:d8ac696cc51f
   126     e.g:
   126     e.g:
   127     <pre>
   127     <pre>
   128     <hlm:mergeMetadataMacro file="${zip.config.file.parsed}" config="${zips.@{type}.spec.name}"/>
   128     <hlm:mergeMetadataMacro file="${zip.config.file.parsed}" config="${zips.@{type}.spec.name}"/>
   129     </pre>
   129     </pre>
   130     -->
   130     -->
   131     <scriptdef name="mergeMetadataMacro" language="jython" uri="http://www.nokia.com/helium">
   131     <macrodef name="mergeMetadataMacro" uri="http://www.nokia.com/helium">
   132         <attribute name="file" />
   132         <attribute name="file" />
   133         <attribute name="config" />
   133         <attribute name="config" />
   134         <![CDATA[
   134         <sequential>
       
   135             <hlm:python>
       
   136                 <![CDATA[
   135 import configuration
   137 import configuration
   136 import symrec
   138 import symrec
   137 import os
   139 import os
   138 import traceback
   140 import sys
   139 # Nicer name
   141 import logging
   140 self.setTaskName("merge-metadata")
   142 import ant
       
   143 
       
   144 LOGGER = logging.getLogger("metadatamerger")
       
   145 LOGGER.setLevel(level=logging.INFO)
       
   146 logging.basicConfig(level=logging.INFO)
   141 
   147 
   142 def merge_filelist(merger, filelist):
   148 def merge_filelist(merger, filelist):
   143     for filename in filelist:
   149     for filename in filelist:
   144         try:
   150         try:
   145             self.log(str("Merging %s" % filename))
   151             LOGGER.info("Merging %s" % filename)
   146             merger.merge(filename)
   152             merger.merge(filename)
   147             os.unlink(filename)
   153             os.unlink(filename)
   148         except Exception, exc:
   154         except Exception, exc:
   149             self.log("Warning: %s" % exc)
   155             LOGGER.warning("Warning: %s" % exc)
   150 
   156 
   151 try:
   157 try:
   152     builder = configuration.NestedConfigurationBuilder(open(str(attributes.get('file')), 'r'))
   158     builder = configuration.NestedConfigurationBuilder(open(ant.get_property(r'@{file}')), 'r')
   153     configSet = builder.getConfiguration()
   159     configSet = builder.getConfiguration()
   154     configs = configSet.getConfigurations(str(attributes.get('config')))
   160     configs = configSet.getConfigurations(ant.get_property(r'@{config}'))
   155     
   161     
   156     if len(configs) > 0:
   162     if len(configs) > 0:
   157         filelist = []
   163         filelist = []
   158         for config in configs:
   164         for config in configs:
   159             if config.get_boolean("grace.metadata", False):
   165             if config.get_boolean("grace.metadata", False):
   160                 metadata = os.path.join(config['archives.dir'], config['name']+ ".metadata.xml")
   166                 metadata = os.path.join(config['archives.dir'], config['name']+ ".metadata.xml")
   161                 if os.path.exists(metadata):
   167                 if os.path.exists(metadata):
   162                     self.log(str("Found %s" % metadata))
   168                     LOGGER.info("Found %s" % metadata)
   163                     filelist.append(metadata)
   169                     filelist.append(metadata)
   164         
   170         
   165         merger = None
   171         merger = None
   166         metadata_main = os.path.join(configs[0]['archives.dir'], "release_metadata.xml")
   172         metadata_main = os.path.join(configs[0]['archives.dir'], "release_metadata.xml")
   167         if os.path.exists(metadata_main):
   173         if os.path.exists(metadata_main):
   168             merger = symrec.MetadataMerger(metadata_main)
   174             merger = symrec.MetadataMerger(metadata_main)
   169             merge_filelist(merger, filelist)
   175             merge_filelist(merger, filelist)
   170             self.log(str("Writing %s" % metadata_main))
   176             LOGGER.info(str("Writing %s" % metadata_main))
   171             merger.save()
   177             merger.save()
   172         elif len(filelist) > 0:
   178         elif len(filelist) > 0:
   173             input = filelist.pop(0)
   179             input = filelist.pop(0)
   174             merger = symrec.MetadataMerger(input)
   180             merger = symrec.MetadataMerger(input)
   175             merge_filelist(merger, filelist)
   181             merge_filelist(merger, filelist)
   176             self.log(str("Writing %s" % metadata_main))
   182             LOGGER.info(str("Writing %s" % metadata_main))
   177             merger.save(metadata_main)
   183             merger.save(metadata_main)
   178             os.unlink(input)
   184             os.unlink(input)
   179 except Exception, e:
   185 except Exception, e:
   180     self.log('ERROR: %s' % e)
   186     LOGGER.error('ERROR: %s' % e)
   181     traceback.print_exc()
   187     sys.exit(-1)
   182     # Let's propagate at the moment
       
   183     raise e
       
   184 ]]> 
   188 ]]> 
   185     </scriptdef>
   189             </hlm:python>
       
   190         </sequential>
       
   191     </macrodef>
   186 
   192 
   187     <!-- This macro allows you to add or update one archive definition inside the release metadata files.
   193     <!-- This macro allows you to add or update one archive definition inside the release metadata files.
   188     e.g.:
   194     e.g.:
   189     <pre>
   195     <pre>
   190         <hlm:updateMetadataMacro file="<path>/release_metadata.xml" archive="<path>/archive.zip" />
   196         <hlm:updateMetadataMacro file="<path>/release_metadata.xml" archive="<path>/archive.zip" />
   191     </pre>
   197     </pre>
   192      -->
   198      -->
   193     <scriptdef name="updateMetadataMacro" language="jython" uri="http://www.nokia.com/helium">
   199     <macrodef name="updateMetadataMacro" uri="http://www.nokia.com/helium">
   194         <attribute name="file" />
   200         <attribute name="file" />
   195         <attribute name="archive" />
   201         <attribute name="archive" />
   196         <attribute name="filters" />
   202         <attribute name="filters" default=""/>
       
   203         <sequential>
       
   204             <hlm:python>
   197         <![CDATA[
   205         <![CDATA[
   198 import symrec
   206 import symrec
   199 import os
   207 import os
   200 import traceback
   208 import traceback
   201 import fileutils
   209 import fileutils
   202 self.setTaskName("updateMetadataMacro")
   210 import ant
   203 if attributes.get('file') is None:
   211 import sys
       
   212 import logging
       
   213 
       
   214 LOGGER = logging.getLogger("metadataupdater")
       
   215 LOGGER.setLevel(level=logging.INFO)
       
   216 logging.basicConfig(level=logging.INFO)
       
   217 
       
   218 if ant.get_property(r'@{file}') is None:
   204     raise Exception('file attribute is not defined.')
   219     raise Exception('file attribute is not defined.')
   205 if attributes.get('archive') is None:
   220 if ant.get_property(r'@{archive}') is None:
   206     raise Exception('archive attribute is not defined.')
   221     raise Exception('archive attribute is not defined.')
   207 filters = None
   222 filters = None
   208 if attributes.get('filters') is not None:
   223 if ant.get_property(r'@{filters}') is not None:
   209     filters = str(attributes.get('filters')).split(r',')
   224     filters = ant.get_property(r'@{filters}').split(r',')
   210 
   225 
   211 try:
   226 try:
   212     filename = str(attributes.get('file'))
   227     filename = ant.get_property(r'@{file}')
   213     archive = str(attributes.get('archive'))
   228     archive = ant.get_property(r'@{archive}')
   214     if not os.path.exists(filename):
   229     if not os.path.exists(filename):
   215         raise Exception("Could not find file: %s" % filename)
   230         raise Exception("Could not find file: %s" % filename)
   216     if not os.path.exists(archive):
   231     if not os.path.exists(archive):
   217         raise Exception("Could not find file: %s" % archive)
   232         raise Exception("Could not find file: %s" % archive)
   218 
   233 
   219     self.log(str("Opening %s" % filename))
   234     LOGGER.info(str("Opening %s" % filename))
   220     md = symrec.ReleaseMetadata(filename)
   235     md = symrec.ReleaseMetadata(filename)
   221     if os.path.basename(archive) not in md.keys():
   236     if os.path.basename(archive) not in md.keys():
   222         self.log(str("Adding %s to metadata" % os.path.basename(archive)))
   237         LOGGER.info(str("Adding %s to metadata" % os.path.basename(archive)))
   223         md.add_package(os.path.basename(archive), md5checksum=fileutils.getmd5(archive), size=os.path.getsize(archive), filters=filters)
   238         md.add_package(os.path.basename(archive), md5checksum=fileutils.getmd5(archive), size=os.path.getsize(archive), filters=filters)
   224     else:
   239     else:
   225         self.log(str("Updating %s to metadata" % os.path.basename(archive)))
   240         LOGGER.info(str("Updating %s to metadata" % os.path.basename(archive)))
   226         result = md[os.path.basename(archive)]
   241         result = md[os.path.basename(archive)]
   227         result['md5checksum'] = unicode(fileutils.getmd5(archive))
   242         result['md5checksum'] = unicode(fileutils.getmd5(archive))
   228         result['size'] = unicode(os.path.getsize(archive))
   243         result['size'] = unicode(os.path.getsize(archive))
   229         if filters is not None:
   244         if filters is not None:
   230             result['filters'] = filters
   245             result['filters'] = filters
   231         md[os.path.basename(archive)] = result
   246         md[os.path.basename(archive)] = result
   232     md.save()
   247     md.save()
   233 except Exception, e:
   248 except Exception, e:
   234     self.log('ERROR: %s' % e)
   249     LOGGER.error('ERROR: %s' % e)
   235     traceback.print_exc()
   250     sys.exit(-1)
   236     # Let's propagate at the moment
       
   237     raise e
       
   238 ]]> 
   251 ]]> 
   239     </scriptdef>
   252             </hlm:python>
       
   253         </sequential>
       
   254     </macrodef>
   240     
   255     
   241     <!-- This macro update the metadata file generated by the config provided by file.
   256     <!-- This macro update the metadata file generated by the config provided by file.
   242     e.g:
   257     e.g:
   243     <pre>
   258     <pre>
   244     <hlm:updateMD5Macro file="${zip.config.file.parsed}" config="${zips.@{type}.spec.name}"/>
   259     <hlm:updateMD5Macro file="${zip.config.file.parsed}" config="${zips.@{type}.spec.name}"/>
   245     </pre>
   260     </pre>
   246     -->
   261     -->
   247     <scriptdef name="updateMD5Macro" language="jython" uri="http://www.nokia.com/helium">
   262     <macrodef name="updateMD5Macro" uri="http://www.nokia.com/helium">
   248         <attribute name="file" />
   263         <attribute name="file" />
   249         <attribute name="config" />
   264         <attribute name="config" />
       
   265         <sequential>
       
   266             <hlm:python>
   250         <![CDATA[
   267         <![CDATA[
   251 import configuration
   268 import configuration
   252 import archive
   269 import archive
   253 import os
   270 import os
   254 import symrec
   271 import symrec
   255 import traceback       
   272 import ant
   256 
   273 import logging
   257 self.setTaskName("update-md5")
   274 import sys
       
   275 
       
   276 LOGGER = logging.getLogger("metadataMD5updater")
       
   277 LOGGER.setLevel(level=logging.INFO)
       
   278 logging.basicConfig(level=logging.INFO)
   258           
   279           
   259 # Reading the config from Ant
   280 # Reading the config from Ant
   260 try:
   281 try:
   261     config_filename = str(attributes.get('file'))
   282     config_filename = ant.get_property(r'@{file}')
   262     spec_name = str(attributes.get('config'))
   283     spec_name = ant.get_property(r'@{config}')
   263     # Loading the config file.                        
   284     # Loading the config file.                        
   264     builder = configuration.NestedConfigurationBuilder(open(config_filename, 'r'))
   285     builder = configuration.NestedConfigurationBuilder(open(config_filename, 'r'))
   265     configSet = builder.getConfiguration()
   286     configSet = builder.getConfiguration()
   266     configs = configSet.getConfigurations(spec_name)
   287     configs = configSet.getConfigurations(spec_name)
   267 
   288 
   269         if os.path.exists(os.path.join(configs[0]['archives.dir'], "release_metadata.xml")):
   290         if os.path.exists(os.path.join(configs[0]['archives.dir'], "release_metadata.xml")):
   270             md5update = symrec.MD5Updater(os.path.join(configs[0]['archives.dir'], "release_metadata.xml"))
   291             md5update = symrec.MD5Updater(os.path.join(configs[0]['archives.dir'], "release_metadata.xml"))
   271             md5update.update()
   292             md5update.update()
   272             md5update.save()
   293             md5update.save()
   273         else:
   294         else:
   274             self.log(str('WARNING: Could not find %s.' % os.path.join(configs[0]['archives.dir'], "release_metadata.xml")))
   295             LOGGER.warning(str('WARNING: Could not find %s.' % os.path.join(configs[0]['archives.dir'], "release_metadata.xml")))
   275     else:
   296     else:
   276         self.log('WARNING: No config.')
   297         LOGGER.warning('WARNING: No config.')
   277 except Exception, e:
   298 except Exception, e:
   278     self.log('ERROR: %s' % e)
   299     LOGGER.error('ERROR: %s' % e)
   279     traceback.print_exc()
   300     sys.exit(-1)
   280     # Let's propagate at the moment
       
   281     raise e
       
   282 ]]> 
   301 ]]> 
   283     </scriptdef>
   302         </hlm:python>
       
   303         </sequential>
       
   304     </macrodef>
   284 
   305 
   285     <condition property="archive.using.ec">
   306     <condition property="archive.using.ec">
   286         <or>
   307         <or>
   287             <equals arg1="${build.system}" arg2="ec-helium" />
   308             <equals arg1="${build.system}" arg2="ec-helium" />
   288             <equals arg1="${build.system}" arg2="sbs-ec" />
   309             <equals arg1="${build.system}" arg2="sbs-ec" />
   292     <!-- Zips files using a type and zip config file as args -->
   313     <!-- Zips files using a type and zip config file as args -->
   293     <macrodef name="zipContentMacro" uri="http://www.nokia.com/helium">
   314     <macrodef name="zipContentMacro" uri="http://www.nokia.com/helium">
   294         <attribute name="type" />
   315         <attribute name="type" />
   295         <attribute name="file" />
   316         <attribute name="file" />
   296         <attribute name="ec" default="${archive.using.ec}"/>
   317         <attribute name="ec" default="${archive.using.ec}"/>
       
   318         <attribute name="failonemptyconfig" default="true"/>
       
   319         <attribute name="phase" default="archive"/>
   297         <sequential>
   320         <sequential>
   298             <if>
   321             <if>
   299                 <not>
   322                 <not>
   300                     <isset property="zip.@{type}.log.file" />
   323                     <isset property="zip.@{type}.log.file" />
   301                 </not>
   324                 </not>
   302                 <then>
   325                 <then>
   303                     <property name="zip.@{type}.log.file" location="${build.log.dir}/${build.id}_@{type}_zip.log" />
   326                     <property name="zip.@{type}.log.file" location="${@{phase}.log.dir}/${build.id}_@{type}_zip.log" />
   304                 </then>
   327                 </then>
   305             </if>
   328             </if>
       
   329             <mkdir dir="${@{phase}.log.dir}"/>
       
   330             <mkdir dir="${post.log.dir}"/>
       
   331             <property name="zip.@{type}.nopolicy.log.file" location="${@{phase}.log.dir}/${build.id}_@{type}_archive.nopolicy.log" />
       
   332             <property name="zip.@{type}.policy.log.file" location="${@{phase}.log.dir}/${build.id}_@{type}_archive.policy.log" />
   306             <trycatch property="exception" reference="exception">
   333             <trycatch property="exception" reference="exception">
   307                 <try>
   334                 <try>
   308                     <!-- Don't print 'compressing' on console -->
   335                     <!-- Don't print 'compressing' on console -->
   309                     <hlm:logtoconsole action="stop" />
   336                     <hlm:logtoconsole action="stop" />
   310                     <!-- Stops writing on ...ant_build.log file-->
   337                     <!-- Stops writing on ...ant_build.log file-->
   311                     <hlm:startSpecificLogMacro name="${zip.@{type}.log.file}" />
   338                     <hlm:startSpecificLogMacro name="${zip.@{type}.log.file}" phase="@{phase}"/>
   312             
   339             
   313                     <property name="zip.config.file.parsed" location="${temp.build.dir}/zip.cfg.xml.parsed" />
   340                     <property name="zip.config.file.parsed" location="${temp.build.dir}/zip.cfg.xml.parsed" />
   314                     <copy file="@{file}" tofile="${zip.config.file.parsed}" overwrite="true">
   341                     <copy file="@{file}" tofile="${zip.config.file.parsed}" overwrite="true">
   315                         <filterchain>
   342                         <filterchain>
   316                             <expandproperties />
   343                             <expandproperties />
   317                         </filterchain>
   344                         </filterchain>
   318                     </copy>
   345                     </copy>
   319                     <hlm:updateArchiveConfig configtype="${zips.@{type}.spec.name}" configfileparsed="${zip.config.file.parsed}" usingec="@{ec}" />
   346                     <hlm:updateArchiveConfig configtype="${zips.@{type}.spec.name}" configfileparsed="${zip.config.file.parsed}" usingec="@{ec}" failonemptyconfig="@{failonemptyconfig}"/>
   320                     <if>
   347                     <if>
   321                         <istrue value="@{ec}" />
   348                         <istrue value="@{ec}" />
   322                         <then>
   349                         <then>
   323                             <echo>emake.root.to.append=${emake.root.to.append}</echo>
   350                             <echo>emake.root.to.append=${emake.root.to.append}</echo>
   324                             <hlm:emakeMacro name="archive-full-@{type}" makefile="${build.drive}/ZIP_${zips.@{type}.spec.name}.make" target="all" dir="${build.drive}" annodetail="basic,history,file,waiting" root="${emake.root.to.append}" failonerror="false" />
   351                             <hlm:emakeMacro name="archive-full-@{type}" makefile="${build.drive}/ZIP_${zips.@{type}.spec.name}.make" target="all" dir="${build.drive}/" annodetail="basic,history,file,waiting" root="${emake.root.to.append}" failonerror="false" phase="archive"/>
   325                         </then>
   352                         </then>
   326                         <else>
   353                         <else>
   327                             <if>
   354                             <if>
   328                                 <isgreaterthan arg1="${number.of.threads}" arg2="${archive.max.number.of.threads}"/>
   355                                 <isgreaterthan arg1="${number.of.threads}" arg2="${archive.max.number.of.threads}"/>
   329                                 <then>
   356                                 <then>
   356                     <throw refid="exception"/>
   383                     <throw refid="exception"/>
   357                 </catch>
   384                 </catch>
   358                 <finally>
   385                 <finally>
   359                     <!-- Todo: metadata: Convert to metadata structure -->
   386                     <!-- Todo: metadata: Convert to metadata structure -->
   360                     <!-- Stops log back to main log. -->
   387                     <!-- Stops log back to main log. -->
   361                     <hlm:stopSpecificLogMacro name="${zip.@{type}.log.file}" />
   388                     <hlm:stopSpecificLogMacro name="${zip.@{type}.log.file}" phase="@{phase}"/>
   362                     <hlm:logtoconsole action="resume" />
   389                     <hlm:logtoconsole action="resume" />
   363                 </finally>
   390                 </finally>
   364             </trycatch>
   391             </trycatch>
   365             <hlm:assertFileExists file="${zip.@{type}.log.file}" />
   392             <hlm:assertFileExists file="${zip.@{type}.log.file}" />
   366             <copy file="${zip.@{type}.log.file}" tofile="${build.log.dir}/${build.id}_@{type}_archive.nopolicy.log" verbose="true">
   393             <copy file="${zip.@{type}.log.file}" tofile="${zip.@{type}.nopolicy.log.file}" verbose="true">
   367                 <filterchain>
   394                 <filterchain>
   368                     <linecontainsregexp negate="true">
   395                     <linecontainsregexp negate="true">
   369                         <regexp pattern="POLICY_(ERROR|WARNING|INFO)" />
   396                         <regexp pattern="POLICY_(ERROR|WARNING|INFO)" />
   370                     </linecontainsregexp>
   397                     </linecontainsregexp>
   371                 </filterchain>
   398                 </filterchain>
   372             </copy>
   399             </copy>
   373             <hlm:metadatarecord database="${metadata.dbfile}">
   400             <hlm:metadatarecord database="${metadata.dbfile}">
   374                 <hlm:textmetadatainput>
   401                 <hlm:textmetadatainput>
   375                     <fileset casesensitive="false" file="${build.log.dir}/${build.id}_@{type}_archive.nopolicy.log" />
   402                     <fileset casesensitive="false" file="${zip.@{type}.nopolicy.log.file}" />
   376                     <metadatafilterset refid="filterset.archive.nopolicy" />
   403                     <metadatafilterset refid="filterset.archive.nopolicy" />
   377                 </hlm:textmetadatainput>
   404                 </hlm:textmetadatainput>
   378             </hlm:metadatarecord>
   405             </hlm:metadatarecord>
   379             <hlm:signalMacro logfile="${build.log.dir}/${build.id}_@{type}_archive.nopolicy.log" 
   406             <hlm:signalMacro logfile="${zip.@{type}.nopolicy.log.file}" 
   380                 signal.input="archiveErrorSignalInput" />
   407                 signal.input="archiveErrorSignalInput" />
   381 
   408 
   382             <!-- Extracting policy errors from archiving. -->
   409             <!-- Extracting policy errors from archiving. -->
   383             <copy file="${zip.@{type}.log.file}" tofile="${build.log.dir}/${build.id}_@{type}_archive.policy.log" verbose="true">
   410             <copy file="${zip.@{type}.log.file}" tofile="${zip.@{type}.policy.log.file}" verbose="true">
   384                 <filterchain>
   411                 <filterchain>
   385                     <linecontainsregexp>
   412                     <linecontainsregexp>
   386                         <regexp pattern="POLICY_(ERROR|WARNING|INFO)" />
   413                         <regexp pattern="POLICY_(ERROR|WARNING|INFO)" />
   387                     </linecontainsregexp>
   414                     </linecontainsregexp>
   388                     <tokenfilter>
   415                     <tokenfilter>
   389                         <replaceregex pattern=".*(POLICY_(?:ERROR|WARNING|INFO))" replace="\1" flags="gi" />
   416                         <replaceregex pattern=".*(POLICY_(?:ERROR|WARNING|INFO))" replace="\1" flags="gi" />
   390                     </tokenfilter>
   417                     </tokenfilter>
   391                 </filterchain>
   418                 </filterchain>
   392             </copy>
   419             </copy>
   393             <hlm:assertFileExists file="${build.log.dir}/${build.id}_@{type}_archive.policy.log" />
   420             <hlm:assertFileExists file="${zip.@{type}.policy.log.file}" />
   394             <hlm:metadatarecord database="${metadata.dbfile}">
   421             <hlm:metadatarecord database="${metadata.dbfile}">
   395                 <hlm:textmetadatainput>
   422                 <hlm:textmetadatainput>
   396                     <fileset casesensitive="false" file="${build.log.dir}/${build.id}_@{type}_archive.policy.log" />
   423                     <fileset casesensitive="false" file="${zip.@{type}.policy.log.file}" />
   397                     <metadatafilterset refid="filterset.archive.policy" />
   424                     <metadatafilterset refid="filterset.archive.policy" />
   398                 </hlm:textmetadatainput>
   425                 </hlm:textmetadatainput>
   399             </hlm:metadatarecord>
   426             </hlm:metadatarecord>
   400             <hlm:signalMacro logfile="${build.log.dir}/${build.id}_@{type}_archive.policy.log" 
   427             <hlm:signalMacro logfile="${zip.@{type}.policy.log.file}" 
   401                 signal.input="archivePolicyErrorSignalInput" />
   428                 signal.input="archivePolicyErrorSignalInput" />
   402         </sequential>
   429         </sequential>
   403     </macrodef>
   430     </macrodef>
   404     
   431     
   405     <!--
   432     <!--
   408     -->
   435     -->
   409     <scriptdef name="updateArchiveConfig" language="jython" uri="http://www.nokia.com/helium">
   436     <scriptdef name="updateArchiveConfig" language="jython" uri="http://www.nokia.com/helium">
   410         <attribute name="configtype" />
   437         <attribute name="configtype" />
   411         <attribute name="configfileparsed" />
   438         <attribute name="configfileparsed" />
   412         <attribute name="usingec" />
   439         <attribute name="usingec" />
       
   440         <attribute name="failonemptyconfig" />
   413         <![CDATA[
   441         <![CDATA[
   414 import archive
   442 import archive
   415 import configuration
   443 import configuration
   416 import logging
   444 import logging
   417 import os
   445 import os
   418 
   446 
       
   447 failonemptyconfig = True      
       
   448 if attributes.get('failonemptyconfig'):
       
   449     failonemptyconfig = str(attributes.get('failonemptyconfig')).lower() == "true"
   419 config_parsed_filename = str(attributes.get('configfileparsed'))
   450 config_parsed_filename = str(attributes.get('configfileparsed'))
   420 config_type = str(attributes.get('configtype'))
   451 config_type = str(attributes.get('configtype'))
   421 is_it_ec = str(attributes.get('usingec'))
   452 is_it_ec = str(attributes.get('usingec'))
   422                         
   453                         
   423 builder = configuration.NestedConfigurationBuilder(open(config_parsed_filename, 'r'))
   454 builder = configuration.NestedConfigurationBuilder(open(config_parsed_filename, 'r'))
   428 outputext = '.xml'
   459 outputext = '.xml'
   429 if is_it_ec == "true":
   460 if is_it_ec == "true":
   430     outputtype = 'make'
   461     outputtype = 'make'
   431     outputext = '.make'
   462     outputext = '.make'
   432 
   463 
   433 if len(configs) > 0:
   464 if len(configs) > 0 or not failonemptyconfig:
   434     prebuilder = archive.ArchivePreBuilder(configuration.ConfigurationSet(configs), config_type, outputtype)
   465     prebuilder = archive.ArchivePreBuilder(configuration.ConfigurationSet(configs), config_type, outputtype)
   435     if os.sep == '\\':
   466     if os.sep == '\\':
   436         toAppendEmakeRoot = prebuilder.checkRootDirValue(builder, config_parsed_filename, project.getProperty('build.drive'), config_type)
   467         toAppendEmakeRoot = prebuilder.checkRootDirValue(builder, config_parsed_filename, project.getProperty('build.drive'), config_type)
   437         if toAppendEmakeRoot is not None:
   468         if toAppendEmakeRoot is not None:
   438             project.setProperty("emake.root.to.append", str(toAppendEmakeRoot))
   469             project.setProperty("emake.root.to.append", str(toAppendEmakeRoot))
   439     prebuilder.writeTopLevel(os.path.join(project.getProperty('build.drive') + os.sep, 'ZIP_' + config_type + outputext), project.getProperty('temp.build.dir'), config_parsed_filename)       
   470     prebuilder.writeTopLevel(os.path.join(project.getProperty('build.drive') + os.sep, 'ZIP_' + config_type + outputext), project.getProperty('temp.build.dir'), config_parsed_filename)       
   440     
       
   441 else:
   471 else:
   442     raise Exception('There are no archive configs to build. Looked for %s' % config_type)
   472     raise Exception('There are no archive configs to build. Looked for %s' % config_type)
   443 ]]>
   473 ]]>
   444     </scriptdef>
   474     </scriptdef>
   445     
   475     
   774         
   804         
   775     First the logging should be stopped, before the file is copied. Hence this target should be called
   805     First the logging should be stopped, before the file is copied. Hence this target should be called
   776     by the "final" target last.
   806     by the "final" target last.
   777     -->
   807     -->
   778     <target name="publish-build-log" depends="prep-publish" if="publish">
   808     <target name="publish-build-log" depends="prep-publish" if="publish">
   779         <record name="${build.log}" action="stop" append="true" />
       
   780         <copy todir="${publish.dir}/logs" preservelastmodified="true" failonerror="false">
   809         <copy todir="${publish.dir}/logs" preservelastmodified="true" failonerror="false">
   781             <fileset dir="${build.log.dir}" includes="${build.id}*_ant_build.log" />
   810             <fileset dir="${build.log.dir}" includes="**/*.log" />
   782         </copy>
   811         </copy>
   783     </target>
   812     </target>
   784 
   813 
       
   814     <!-- Copy the debug log to the build area if available-->
       
   815     <target name="copy-debug-logs">
       
   816         <echo message="log4j.dir:${log4j.cache.dir}" /> 
       
   817         <if>
       
   818             <available file="${log4j.cache.dir}" />
       
   819             <then>
       
   820                 <copy todir="${build.log.dir}/debug" failonerror="false">
       
   821                     <fileset dir="${log4j.cache.dir}" includes="hlm_*.log" />
       
   822                 </copy>
       
   823             </then>
       
   824         </if>
       
   825     </target>
       
   826 
       
   827     <!-- Target to simulate that the build is failed because of processing
       
   828     ant output
       
   829     -->
       
   830     <target name="raise-error">
       
   831         <echo message="ERROR: Build failed due to exceptions" />
       
   832     </target>
       
   833 
       
   834     <!-- Update the build status by processing the ant build output log -->
       
   835     <target name="build-status">
       
   836         <hlm:metadatarecord database="${metadata.dbfile}">
       
   837             <hlm:antmetadatainput>
       
   838                 <fileset casesensitive="false" file="${build.log.dir}/${build.id}_ant_build.log" />
       
   839                 <metadatafilterset refid="filterset.ant.output" />
       
   840             </hlm:antmetadatainput>
       
   841         </hlm:metadatarecord>
       
   842 
       
   843         <hlm:signalMacro logfile="${build.id}_ant_build.log" 
       
   844             signal.input="exceptionSignalInput" />
       
   845     </target>
       
   846 
       
   847     <!-- Exception handler to process the ant output log -->
       
   848     <target name="hlm-exception-handler">
       
   849         <if>
       
   850             <available file="${build.log.dir}/${build.id}_ant_build.log"/>
       
   851             <then>
       
   852                 <runtarget target="do-exception-handler" />
       
   853             </then>
       
   854         </if>
       
   855     </target>
       
   856 
       
   857     <target name="do-exception-handler" depends="raise-error, build-status, build-log-summary, copy-debug-logs, publish-build-log" />
   785 
   858 
   786     <!-- Does any wrap-up at the end of the build. This should be the last target for every top-level target. -->
   859     <!-- Does any wrap-up at the end of the build. This should be the last target for every top-level target. -->
   787     <target name="final" depends="publish-build-log">
   860     <target name="final" depends="build-status, build-log-summary, copy-debug-logs, publish-build-log" />
   788     </target>
       
   789     
   861     
   790     <!-- This target will zip the WA depending on the ado mapping file -->
   862     <!-- This target will zip the WA depending on the ado mapping file -->
   791     <target name="zip-wa" depends="ido-create-ado-mapping" if="zip.wa">
   863     <target name="zip-wa" depends="ido-create-ado-mapping" if="zip.wa">
   792         <tempfile property="zipwa.dynamic.config" suffix=".xml" deleteonexit="false" destdir="${temp.build.dir}"/>
   864         <tempfile property="zipwa.dynamic.config" suffix=".xml" deleteonexit="false" destdir="${temp.build.dir}"/>
   793         <fmpp sourceFile="${helium.dir}/tools/common/templates/ido/zip-ant-wa-copy.xml.ftl" outputFile="${zipwa.dynamic.config}">
   865         <fmpp sourceFile="${helium.dir}/tools/common/templates/ido/zip-ant-wa-copy.xml.ftl" outputFile="${zipwa.dynamic.config}">