buildframework/helium/tools/relnotes/relnotes.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        : relnotes.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 releases -->
       
    24 <project name="relnotes" default="release-notes" xmlns:hlm="http://www.nokia.com/helium">
       
    25     <description>
       
    26     Generates a release note by modifying a template (that you can edit yourself) with
       
    27     values from the build and Synergy.
       
    28     
       
    29     * Modifies a RTF template with values from build
       
    30     * Adds table of errors and warnings
       
    31     * Generates list of baselines, projects and tasks used
       
    32     </description>
       
    33     
       
    34     <!--* @property product.printname
       
    35     A printable name for a product used in release notes.
       
    36     @type string
       
    37     @editable required
       
    38     @scope public
       
    39     -->
       
    40     
       
    41     <!--* @property product.type
       
    42     Project ID in release notes.
       
    43     @type string
       
    44     @editable required
       
    45     @scope public
       
    46     -->
       
    47     
       
    48     <!--* @property relnotes.config.dir
       
    49     Defines the directory that contains release notes creation configuration files.
       
    50     @type string
       
    51     @editable required
       
    52     @scope public
       
    53     -->
       
    54 
       
    55     <!-- Defines the directory that will contain the output of release notes creation.
       
    56     @type string
       
    57     @scope private
       
    58     -->
       
    59     <property name="releasenotes.output.dir" value="${build.output.dir}/relnotes"/>
       
    60     <!-- Defines the logo image file which will be used in release notes.
       
    61     @type string
       
    62     @scope private
       
    63     -->
       
    64     <property name="releasenotes.logo" value="${relnotes.config.dir}/logo.png"/>
       
    65     <!-- Property file with customer values
       
    66     @type string
       
    67     @scope private
       
    68     -->
       
    69     <property name="releasenotes.props" value="${relnotes.config.dir}/relnotes.properties"/>
       
    70     <!-- Temp file
       
    71     @type string
       
    72     @scope private
       
    73     -->
       
    74     <property name="releasenotes.temp.props" value="${temp.build.dir}/relnotes.properties"/>
       
    75     <!-- Temp file
       
    76     @type string
       
    77     @scope private
       
    78     -->
       
    79     <property name="releasenotes.temp.props2" value="${temp.build.dir}/relnotes2.properties"/>
       
    80     <!-- Defines the name of the release note template used.
       
    81     @type string
       
    82     @scope private
       
    83     -->
       
    84     <property name="releasenotes.template" value="${relnotes.config.dir}/template.rtf"/>
       
    85     <!-- Location of output rtf file
       
    86     @type string
       
    87     @scope private
       
    88     -->
       
    89     <property name="releasenotes.output" value="${releasenotes.output.dir}/${build.id}_relnotes.rtf"/>
       
    90     <!-- Temp file
       
    91     @type string
       
    92     @scope private
       
    93     -->
       
    94     <property name="releasenotes.temp.errors" value="${temp.build.dir}/errors.csv"/>
       
    95     <!-- Temp file
       
    96     @type string
       
    97     @scope private
       
    98     -->
       
    99     <property name="releasenotes.temp.output" value="${temp.build.dir}/tempDocument.rtf"/>
       
   100     <!-- Location of scan2log HTML file
       
   101     @type string
       
   102     @scope private
       
   103     -->
       
   104     <property name="releasenotes.scan2log" value="${build.log.dir}/${build.id}.${product.family}_scan2.html"/>
       
   105     
       
   106     <import file="${relnotes.config.dir}/relnotes_properties.ant.xml" optional="true"/>
       
   107     
       
   108     <!-- @scope private -->
       
   109     <target name="release-notes-variant-configuration" depends="imaker-merge-rom-xml">
       
   110         <script language="jython" setbeans="false">
       
   111 tagnames = ""
       
   112 for product in project.getProperty("product.list").split(","):
       
   113     tagnames += "Type%sVariantTableHere\n" %  product 
       
   114 project.setProperty("variant.product.tagnames", tagnames)
       
   115         </script>
       
   116         <replace file="${releasenotes.output}" token="TypeVariantTableHere" value="${variant.product.tagnames}" summary="true"/>
       
   117         <for list="${product.list}" delimiter="," param="product.name" >
       
   118             <sequential>            
       
   119                 <exec executable="python" failonerror="${failonerror}">
       
   120                     <arg line="-m getVariantConfiguration"/>
       
   121                     <arg value="@{product.name}"/>
       
   122                     <arg value="${rombuild.config.file.parsed}"/>
       
   123                     <arg value="${temp.build.dir}/variant_@{product.name}.csv"/>
       
   124                 </exec>
       
   125                 <hlm:python>
       
   126 import ant
       
   127 import rtfutils
       
   128 rn = rtfutils.RTFUtils(ant.get_property(r'${releasenotes.output}'))
       
   129 rn.rtftable(ant.get_property(r'${temp.build.dir}/variant_@{product.name}.csv'), ant.get_property(r'${releasenotes.temp.output}'), ant.get_property(r'Type@{product.name}VariantTableHere'))
       
   130                 </hlm:python>
       
   131   
       
   132                 <delete file="${releasenotes.output}"/>
       
   133                 <move file="${releasenotes.temp.output}" tofile="${releasenotes.output}"/>
       
   134             </sequential>
       
   135         </for>
       
   136     </target>
       
   137     
       
   138     <!-- Create error list in release notes
       
   139     @scope private    
       
   140     -->
       
   141     <target name="release-notes-error-summary">
       
   142         <fmpp sourceFile="${helium.dir}/tools/relnotes/templates/errors.csv.ftl"
       
   143                      outputfile="${releasenotes.temp.errors}">
       
   144             <freemarkerLinks expandProperties="yes">
       
   145                 macro: ${helium.dir}/tools/common/templates/macro
       
   146             </freemarkerLinks>
       
   147             <data expandProperties="yes">
       
   148                 dbPath: ${metadata.dbfile}
       
   149                 ant: antProperties()
       
   150             </data>
       
   151         </fmpp>
       
   152         <hlm:python>
       
   153 import ant
       
   154 import rtfutils
       
   155 rn = rtfutils.RTFUtils(ant.get_property(r'${releasenotes.output}'))
       
   156 rn.rtftable(ant.get_property(r'${releasenotes.temp.errors}'), ant.get_property(r'${releasenotes.temp.output}'), 'TypeErrorTableSummaryHere')
       
   157         </hlm:python>
       
   158         <delete file="${releasenotes.output}"/>
       
   159         <move file="${releasenotes.temp.output}" tofile="${releasenotes.output}"/>
       
   160     </target>
       
   161     
       
   162     <!--  Add logo to release notes. @scope private -->
       
   163     <target name="release-notes-logo">
       
   164         <hlm:python>
       
   165 import ant
       
   166 import rtfutils
       
   167 rn = rtfutils.RTFUtils(ant.get_property(r'${releasenotes.output}'))
       
   168 rn.rtfimage(ant.get_property(r'${releasenotes.logo}'), ant.get_property(r'${releasenotes.temp.output}'), 'AddProductImageHere')
       
   169         </hlm:python>
       
   170         <move file="${releasenotes.temp.output}" tofile="${releasenotes.output}"/>
       
   171     </target>
       
   172     
       
   173     <!-- Find project and baseline of what is running helium
       
   174     @scope private    
       
   175     -->
       
   176     <target name="release-notes-getcmprojectname">
       
   177         <if>
       
   178             <istrue value="${ccm.enabled}" />
       
   179             <then>
       
   180                 <script language="jython" setbeans="false">
       
   181 import ccm.extra
       
   182 import traceback
       
   183 import os
       
   184 import logging
       
   185 import ccmutil
       
   186 
       
   187 #logging.basicConfig(level=logging.DEBUG)
       
   188 session = None
       
   189 try:
       
   190     database = project.getProperty('ccm.database')
       
   191     username = project.getProperty('ccm.user.login')
       
   192     password = project.getProperty('ccm.user.password')
       
   193     engine = project.getProperty('ccm.engine.host')
       
   194     dbpath = project.getProperty('ccm.database.path')     
       
   195     waroot = project.getProperty('create.bom.workarea.root')
       
   196     
       
   197     session = ccmutil.get_session(database, username, password, engine, dbpath)
       
   198     cmproject = ccm.extra.get_toplevel_project(session, waroot)
       
   199     
       
   200     if cmproject == None:
       
   201         print 'Error: ' + waroot + ' must be a synergy project and still be in database'
       
   202     else:
       
   203         project.setProperty("ccm.toplevel.project", str(cmproject))
       
   204     session.close()
       
   205 except Exception, ex:
       
   206     print 'Caught exception: ' + str(ex)
       
   207     traceback.print_exc()
       
   208     if session:
       
   209         session.close()
       
   210                 </script>
       
   211                 <hlm:python outputproperty="ccm.toplevel.baseline">
       
   212 import traceback
       
   213 import ant
       
   214 import logging
       
   215 import ccmutil
       
   216 logging.disable(logging.INFO)
       
   217 session = None
       
   218 try:
       
   219     database = ant.get_property(r'${ccm.database}')
       
   220     username = ant.get_property(r'${ccm.user.login}')
       
   221     password = ant.get_property(r'${ccm.user.password}')
       
   222     engine = ant.get_property(r'${ccm.engine.host}')
       
   223     dbpath = ant.get_property(r'${ccm.database.path}')
       
   224     session = ccmutil.get_session(database, username, password, engine, dbpath)
       
   225     cmproject = session.create(ant.get_property(r'${ccm.toplevel.project}'))
       
   226     print cmproject.baseline
       
   227     session.close()
       
   228 except Exception, ex:
       
   229     print 'Caught exception: ' + str(ex)
       
   230     traceback.print_exc()
       
   231     if session:
       
   232         session.close()
       
   233                 </hlm:python>
       
   234             </then>
       
   235         </if>
       
   236     </target>
       
   237     
       
   238     <!--
       
   239     Look 'startsWith' and find complete CM name
       
   240     Output property: '{startsWith}.project'.
       
   241         
       
   242     @scope private
       
   243     -->
       
   244     <macrodef name="releaseNotesGetProjectName" uri="http://www.nokia.com/helium">
       
   245         <attribute name="startsWith" />
       
   246         <sequential>
       
   247             <if>
       
   248                 <available file="${build.log.dir}/${build.id}_bom.xml" />
       
   249                 <then>
       
   250                     <hlm:python outputproperty="@{startsWith}.project">
       
   251 import amara
       
   252 import ant
       
   253 
       
   254 bomfile = open(r"${build.log.dir}/${build.id}_bom.xml")
       
   255 bom = amara.parse(bomfile)
       
   256 
       
   257 for p in bom.bom.content.project:
       
   258     if (str(p.name).startswith(ant.get_property(r'@{startsWith}'))):
       
   259         print str(p.name)
       
   260 bomfile.close()
       
   261                     </hlm:python>
       
   262                 </then>
       
   263             </if>
       
   264         </sequential>
       
   265     </macrodef>
       
   266     
       
   267     <!-- Write projects, baselines and task list for MC and IBUSAL
       
   268     @scope private    
       
   269     -->
       
   270     <target name="release-notes-ccm" depends="get-ccm-password,release-notes-getcmprojectname,create-bom">
       
   271         <if>
       
   272             <and>
       
   273                 <istrue value="${ccm.enabled}" />
       
   274                 <available file="${build.log.dir}/${build.id}_bom.xml" />
       
   275             </and>
       
   276             <then>
       
   277                 <hlm:python>
       
   278 import amara
       
   279 import ant
       
   280 import bomtofile
       
   281 import ccmutil
       
   282 
       
   283 bomfile = open(r"${build.log.dir}/${build.id}_bom.xml")
       
   284 bom = amara.parse(bomfile)
       
   285 password = ant.get_property(r'${ccm.user.password}')
       
   286 session = ccmutil.get_session(ant.get_property(r'${ccm.database}'), ant.get_property(r'${ccm.user.login}'), password, ant.get_property(r'${ccm.engine.host}'), ant.get_property(r'${ccm.database.path}'))
       
   287 for p in bom.bom.content.project:
       
   288     if p.name == ant.get_property(r'${ccm.toplevel.project}'):
       
   289         bomwriter = bomtofile.BOMWriter(session, 'MC', p, ant.get_property(r'${releasenotes.output.dir}'))
       
   290         bomwriter.writeprojects()
       
   291         bomwriter.writebaselines()
       
   292         bomwriter.writetasks()
       
   293             
       
   294     if (str(p.name).startswith('IBUSAL')):
       
   295         bomwriter = bomtofile.BOMWriter(session, 'IBUSAL', p, ant.get_property(r'${releasenotes.output.dir}'))
       
   296         bomwriter.writeprojects()
       
   297         bomwriter.writetasks()
       
   298 session.close()
       
   299 bomfile.close()
       
   300                 </hlm:python>
       
   301             </then>
       
   302         </if>
       
   303     </target>
       
   304     
       
   305     <!-- Read BOM and write ICF list
       
   306     @scope private
       
   307     -->
       
   308     <target name="release-notes-icfs" depends="create-bom">
       
   309         <exec executable="python" failonerror="${failonerror}">
       
   310             <arg line="-m icf2txt"/>
       
   311             <arg value="${temp.build.dir}/${build.id}_BOM.xml"/>            
       
   312             <arg value="${releasenotes.output.dir}/icdicf.txt"/>
       
   313         </exec>
       
   314     </target>
       
   315     
       
   316     <!-- @scope private -->
       
   317     <target name="release-notes-test" if="hlm.enable.asserts">
       
   318         <if>
       
   319             <istrue value="${ccm.enabled}" />
       
   320             <then>
       
   321                 <hlm:python>
       
   322 import ccm
       
   323 #check for ccm session leaks
       
   324 assert (len(ccm.running_sessions()) == 0)
       
   325                 </hlm:python>
       
   326             </then>
       
   327         </if>
       
   328     </target>
       
   329         
       
   330     <!-- 
       
   331     Generates a product release note based on a template in config dir
       
   332     -->
       
   333     <target name="release-notes" description="Generates a product release note based off a template in config dir">        
       
   334         <mkdir dir="${releasenotes.output.dir}"/>
       
   335         
       
   336         <copy file="${releasenotes.props}" tofile="${releasenotes.temp.props}">
       
   337             <filterchain>
       
   338                 <expandproperties/>
       
   339             </filterchain>
       
   340         </copy>
       
   341           
       
   342         <hlm:python>
       
   343 import ant
       
   344 import rtfutils
       
   345 rn = rtfutils.RTFUtils(ant.get_property(r'${releasenotes.output}'))
       
   346 rn.rtfconvert(ant.get_property(r'${releasenotes.temp.props}'), ant.get_property(r'${releasenotes.temp.props2}'))
       
   347         </hlm:python>
       
   348         
       
   349         <property file="${releasenotes.temp.props2}"/>                
       
   350         <copy file="${releasenotes.template}" tofile="${releasenotes.output}" overwrite="true"/>
       
   351 
       
   352         <antcall target="release-notes-logo" />
       
   353         <antcall target="release-notes-error-summary" />
       
   354         <antcall target="release-notes-variant-configuration" />
       
   355             
       
   356         <delete file="${releasenotes.temp.errors}"/>
       
   357         <delete file="${releasenotes.temp.output}"/>
       
   358         <delete file="${releasenotes.temp.props}"/>
       
   359         <delete file="${releasenotes.temp.props2}"/>
       
   360         
       
   361         <antcall target="release-notes-ccm"/>
       
   362         
       
   363         <antcall target="release-notes-icfs"/>
       
   364     
       
   365         <antcall target="release-notes-replace"/>
       
   366         
       
   367         <antcall target="release-notes-test"/>
       
   368     </target>
       
   369 
       
   370 </project>