buildframework/helium/tools/relnotes/relnotes.ant.xml
changeset 1 be27ed110b50
child 179 d8ac696cc51f
equal deleted inserted replaced
0:044383f39525 1:be27ed110b50
       
     1 <?xml version="1.0" encoding="UTF-8"?>
       
     2 <!-- 
       
     3 ============================================================================ 
       
     4 Name        : 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 <project name="relnotes" default="release-notes" xmlns:hlm="http://www.nokia.com/helium">
       
    24     <description>
       
    25     Generates a release note by modifying a template (that you can edit yourself) with
       
    26     values from the build and Synergy.
       
    27     
       
    28     * Modifies a RTF template with values from build
       
    29     * Adds table of errors and warnings
       
    30     * Generates list of baselines, projects and tasks used
       
    31     </description>
       
    32 
       
    33     <property name="releasenotes.output.dir" value="${build.output.dir}/relnotes"/>
       
    34     <property name="releasenotes.logo" value="${relnotes.config.dir}/logo.png"/>
       
    35     <property name="releasenotes.props" value="${relnotes.config.dir}/relnotes.properties"/>
       
    36     <property name="releasenotes.temp.props" value="${temp.build.dir}/relnotes.properties"/>
       
    37     <property name="releasenotes.temp.props2" value="${temp.build.dir}/relnotes2.properties"/>
       
    38     <property name="releasenotes.template" value="${relnotes.config.dir}/template.rtf"/>
       
    39     <property name="releasenotes.output" value="${releasenotes.output.dir}/${build.id}_relnotes.rtf"/>
       
    40     <property name="releasenotes.temp.errors" value="${temp.build.dir}/errors.csv"/>
       
    41     <property name="releasenotes.temp.output" value="${temp.build.dir}/tempDocument.rtf"/>
       
    42     <property name="releasenotes.scan2log" value="${build.log.dir}/${build.id}.${product.family}_scan2.html"/>
       
    43     
       
    44     <import file="${relnotes.config.dir}/relnotes_properties.ant.xml" optional="true"/>
       
    45     
       
    46     <!-- Private: -->
       
    47     <target name="release-notes-variant-configuration" depends="rombuild-prepare-input">
       
    48         
       
    49         <script language="jython" setbeans="false">
       
    50 tagnames = ""
       
    51 for product in project.getProperty("product.list").split(","):
       
    52     tagnames += "Type%sVariantTableHere\n" %  product 
       
    53 project.setProperty("variant.product.tagnames", tagnames)
       
    54         </script>
       
    55         <replace file="${releasenotes.output}" token="TypeVariantTableHere" value="${variant.product.tagnames}" summary="true"/>
       
    56         <for list="${product.list}" delimiter="," param="product.name" >
       
    57             <sequential>            
       
    58                 <exec executable="python" dir="${helium.dir}/tools/relnotes" failonerror="${failonerror}">
       
    59                     <arg value="getVariantConfiguration.py"/>
       
    60                     <arg value="@{product.name}"/>
       
    61                     <arg value="${localisation.language.file}"/>
       
    62                     <arg value="${rombuild.config.file.parsed}"/>
       
    63                     <arg value="${temp.build.dir}/variant_@{product.name}.csv"/>
       
    64                 </exec>
       
    65                 <hlm:python>
       
    66 import ant
       
    67 import rtfutils
       
    68 rn = rtfutils.RTFUtils(ant.get_property(r'${releasenotes.output}'))
       
    69 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'))
       
    70                 </hlm:python>
       
    71   
       
    72                 <delete file="${releasenotes.output}"/>
       
    73                 <move file="${releasenotes.temp.output}" tofile="${releasenotes.output}"/>
       
    74             </sequential>
       
    75         </for>
       
    76     </target>
       
    77     
       
    78     <!-- Private: Create error list in release notes -->
       
    79     <target name="release-notes-error-summary">
       
    80         <exec executable="python" dir="${helium.dir}/tools/relnotes" failonerror="${failonerror}">
       
    81             <arg value="readHTML.py"/>
       
    82             <arg value="${releasenotes.scan2log}"/>
       
    83             <arg value="${releasenotes.temp.errors}"/>
       
    84         </exec>
       
    85         <hlm:python>
       
    86 import ant
       
    87 import rtfutils
       
    88 rn = rtfutils.RTFUtils(ant.get_property(r'${releasenotes.output}'))
       
    89 rn.rtftable(ant.get_property(r'${releasenotes.temp.errors}'), ant.get_property(r'${releasenotes.temp.output}'), 'TypeErrorTableSummaryHere')
       
    90         </hlm:python>
       
    91         <delete file="${releasenotes.output}"/>
       
    92         <move file="${releasenotes.temp.output}" tofile="${releasenotes.output}"/>
       
    93     </target>
       
    94     
       
    95     <!-- Private: Add logo to release notes -->
       
    96     <target name="release-notes-logo">
       
    97         <hlm:python>
       
    98 import ant
       
    99 import rtfutils
       
   100 rn = rtfutils.RTFUtils(ant.get_property(r'${releasenotes.output}'))
       
   101 rn.rtfimage(ant.get_property(r'${releasenotes.logo}'), ant.get_property(r'${releasenotes.temp.output}'), 'AddProductImageHere')
       
   102         </hlm:python>
       
   103         <move file="${releasenotes.temp.output}" tofile="${releasenotes.output}"/>
       
   104     </target>
       
   105     
       
   106     <!-- Private: Find project and baseline of what is running helium -->
       
   107     <target name="release-notes-getcmprojectname">
       
   108         <script language="jython" setbeans="false">
       
   109 import nokia.nokiaccm
       
   110 import ccm.extra
       
   111 import traceback
       
   112 import os
       
   113 import logging
       
   114 #logging.basicConfig(level=logging.DEBUG)
       
   115 session = None
       
   116 try:
       
   117     database = project.getProperty('ccm.database')
       
   118     username = project.getProperty('ccm.user.login')
       
   119     password = project.getProperty('ccm.user.password')
       
   120     engine = project.getProperty('ccm.engine.host')
       
   121     dbpath = project.getProperty('ccm.database.path')     
       
   122     waroot = project.getProperty('create.bom.workarea.root')
       
   123     if database != None:
       
   124         session = nokia.nokiaccm.open_session(username, password, database=database)
       
   125     else:
       
   126         session = nokia.nokiaccm.open_session(username, password, engine, dbpath)
       
   127         
       
   128     cmproject = ccm.extra.get_toplevel_project(session, waroot)
       
   129     if cmproject == None:
       
   130         print 'Error: ' + waroot + ' must be a synergy project and still be in database'
       
   131     else:
       
   132         project.setProperty("ccm.toplevel.project", str(cmproject))
       
   133     session.close()
       
   134 except Exception, ex:
       
   135     print 'Caught exception: ' + str(ex)
       
   136     traceback.print_exc()
       
   137         </script>
       
   138         
       
   139         <hlm:python outputproperty="ccm.toplevel.baseline">
       
   140 import nokia.nokiaccm
       
   141 import traceback
       
   142 import ant
       
   143 import logging
       
   144 logging.disable(logging.INFO)
       
   145 session = None
       
   146 try:
       
   147     database = ant.get_property(r'${ccm.database}')
       
   148     username = ant.get_property(r'${ccm.user.login}')
       
   149     password = ant.get_property(r'${ccm.user.password}')
       
   150     engine = ant.get_property(r'${ccm.engine.host}')
       
   151     dbpath = ant.get_property(r'${ccm.database.path}')
       
   152     if database != None:
       
   153         session = nokia.nokiaccm.open_session(username, password, database=database)
       
   154     else:
       
   155         session = nokia.nokiaccm.open_session(username, password, engine, dbpath)
       
   156         
       
   157     cmproject = session.create(ant.get_property(r'${ccm.toplevel.project}'))
       
   158     print cmproject.baseline
       
   159     session.close()
       
   160 except Exception, ex:
       
   161     print 'Caught exception: ' + str(ex)
       
   162     traceback.print_exc()
       
   163         </hlm:python>
       
   164     </target>
       
   165     
       
   166     <!-- Private: 
       
   167     Look at property 'project.startswith' and find complete CM name
       
   168     Output property: '${project.startswith}.project'
       
   169     -->
       
   170     <target name="release-notes-getprojectname">
       
   171         <hlm:python outputproperty="release.notes.temp">
       
   172 import amara
       
   173 import ant
       
   174 
       
   175 bomfile = open(r"${build.log.dir}/${build.id}_BOM.xml")
       
   176 bom = amara.parse(bomfile)
       
   177 
       
   178 for p in bom.bom.content.project:
       
   179     if (str(p.name).startswith(ant.get_property(r'${project.startswith}'))):
       
   180         print str(p.name)
       
   181 bomfile.close()
       
   182         </hlm:python>
       
   183         <script language="jython" setbeans="false">
       
   184 project.setProperty(project.getProperty('project.startswith') + '.project', project.getProperty('release.notes.temp'))
       
   185         </script>
       
   186         
       
   187     </target>
       
   188     
       
   189     <!-- Private: Write projects, baselines and task list for MC and IBUSAL -->
       
   190     <target name="release-notes-ccm" depends="get-ccm-password,release-notes-getcmprojectname,create-bom">
       
   191         
       
   192         <hlm:python>
       
   193 import amara
       
   194 import nokia.nokiaccm
       
   195 import ant
       
   196 
       
   197 class BOMToFile(object):
       
   198     """
       
   199     Read BOM and output in text
       
   200     """
       
   201     def __init__(self, session, project_name, project, output_dir):
       
   202         self.project_name = project_name
       
   203         self.project = project
       
   204         self.output_dir = output_dir
       
   205         self.session = session
       
   206       
       
   207     def writeprojects(self):
       
   208         fileout = file(self.output_dir + '/' + self.project_name + '_projects.txt', 'w')
       
   209         
       
   210         i = 1
       
   211         for project in self.project.baseline:
       
   212             fileout.write(str(i) + ") " + str(project) + "\n")
       
   213             
       
   214             i += 1
       
   215         fileout.close()
       
   216         
       
   217     def writebaselines(self):
       
   218         fileout = file(self.output_dir + '/' + self.project_name + '_baselines.txt', 'w')    
       
   219         
       
   220         i = 1
       
   221         for project in self.project.baseline:
       
   222             fileout.write(str(i) + ") " + str(project) + "\n")
       
   223             
       
   224             cmproject = self.session.create(str(project))
       
   225             
       
   226             try:
       
   227                 baseline = str(cmproject.baseline).strip()
       
   228                 if baseline == "None":
       
   229                     fileout.write(str(i) + ") " + str(project) + "\n")
       
   230                 else:
       
   231                     fileout.write(str(i) + ") " + baseline + "\n")
       
   232                 i += 1
       
   233             except Exception, ex:
       
   234                 print ex
       
   235         fileout.close()
       
   236             
       
   237     def writetasks(self):
       
   238         if self.project.xml_properties.has_key("task"):
       
   239             fileout = file(self.output_dir + '/' + self.project_name + '_tasks.txt', 'w')
       
   240             
       
   241             i = 1
       
   242             for task in self.project.task:
       
   243                 fileout.write(str(i) + ") Task " + str(task) + "\n")
       
   244                 i += 1
       
   245             fileout.close()
       
   246 
       
   247 bomfile = open(r"${build.log.dir}/${build.id}_BOM.xml")
       
   248 bom = amara.parse(bomfile)
       
   249 database = ant.get_property(r'${ccm.database}')
       
   250 username = ant.get_property(r'${ccm.user.login}')
       
   251 password = ant.get_property(r'${ccm.user.password}')
       
   252 engine = ant.get_property(r'${ccm.engine.host}')
       
   253 dbpath = ant.get_property(r'${ccm.database.path}')
       
   254 if database != None:
       
   255     session = nokia.nokiaccm.open_session(username, password, database=database)
       
   256 else:
       
   257     session = nokia.nokiaccm.open_session(username, password, engine, dbpath)
       
   258 
       
   259 for p in bom.bom.content.project:
       
   260     if p.name == ant.get_property(r'${ccm.toplevel.project}'):
       
   261         btof = BOMToFile(session, 'MC', p, ant.get_property(r'${releasenotes.output.dir}'))
       
   262         
       
   263         btof.writeprojects()
       
   264         btof.writebaselines()
       
   265             
       
   266         btof.writetasks()
       
   267             
       
   268     if (str(p.name).startswith('IBUSAL')):
       
   269         btof = BOMToFile(session, 'IBUSAL', p, ant.get_property(r'${releasenotes.output.dir}'))
       
   270         
       
   271         btof.writeprojects()
       
   272             
       
   273         btof.writetasks()
       
   274             
       
   275 session.close()
       
   276 bomfile.close()
       
   277 
       
   278         </hlm:python>
       
   279     </target>
       
   280     
       
   281     <!-- Private: Read BOM and write ICF list -->
       
   282     <target name="release-notes-icfs" depends="create-bom">
       
   283         <exec executable="python" dir="${helium.dir}/tools/relnotes" failonerror="${failonerror}">
       
   284             <arg value="icf2txt.py"/>
       
   285             <arg value="${build.log.dir}/${build.id}_BOM.xml"/>            
       
   286             <arg value="${releasenotes.output.dir}/icdicf.txt"/>
       
   287         </exec>
       
   288     </target>
       
   289     
       
   290     <!-- Private: -->
       
   291     <target name="release-notes-test" if="hlm.enable.asserts">
       
   292         <hlm:python>
       
   293 import ccm
       
   294 #check for ccm session leaks
       
   295 assert (len(ccm.running_sessions()) == 0)
       
   296         </hlm:python>
       
   297     </target>
       
   298         
       
   299     <!-- 
       
   300     Generates a product release note based on a template in config dir
       
   301     -->
       
   302     <target name="release-notes" description="Generates a product release note based off a template in config dir">        
       
   303         <mkdir dir="${releasenotes.output.dir}"/>
       
   304         
       
   305         <copy file="${releasenotes.props}" tofile="${releasenotes.temp.props}">
       
   306             <filterchain>
       
   307                 <expandproperties/>
       
   308             </filterchain>
       
   309         </copy>
       
   310           
       
   311         <hlm:python>
       
   312 import ant
       
   313 import rtfutils
       
   314 rn = rtfutils.RTFUtils(ant.get_property(r'${releasenotes.output}'))
       
   315 rn.rtfconvert(ant.get_property(r'${releasenotes.temp.props}'), ant.get_property(r'${releasenotes.temp.props2}'))
       
   316         </hlm:python>
       
   317         
       
   318         <property file="${releasenotes.temp.props2}"/>                
       
   319         <copy file="${releasenotes.template}" tofile="${releasenotes.output}" overwrite="true"/>
       
   320 
       
   321         <antcall target="release-notes-logo" />
       
   322         <antcall target="release-notes-error-summary" />
       
   323         <antcall target="release-notes-variant-configuration" />
       
   324             
       
   325         <delete file="${releasenotes.temp.errors}"/>
       
   326         <delete file="${releasenotes.temp.output}"/>
       
   327         <delete file="${releasenotes.temp.props}"/>
       
   328         <delete file="${releasenotes.temp.props2}"/>
       
   329         
       
   330         <antcall target="release-notes-ccm"/>
       
   331         
       
   332         <antcall target="release-notes-icfs"/>
       
   333     
       
   334         <antcall target="release-notes-replace"/>
       
   335         
       
   336         <antcall target="release-notes-test"/>
       
   337     </target>
       
   338 
       
   339 </project>