buildframework/helium/tools/relnotes/relnotes.ant.xml
author Shabe Razvi <shaber@symbian.org>
Tue, 13 Jul 2010 18:36:46 +0100
branchhelium-7.0.x
changeset 615 23ca302eb377
parent 179 d8ac696cc51f
child 217 0f5e3a7fb6af
permissions -rw-r--r--
Add prebuilt jar for changes in Bug 3222

<?xml version="1.0" encoding="UTF-8"?>
<!-- 
============================================================================ 
Name        : relnotes.ant.xml 
Part of     : Helium 

Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
All rights reserved.
This component and the accompanying materials are made available
under the terms of the License "Eclipse Public License v1.0"
which accompanies this distribution, and is available
at the URL "http://www.eclipse.org/legal/epl-v10.html".

Initial Contributors:
Nokia Corporation - initial contribution.

Contributors:

Description:

============================================================================
-->
<project name="relnotes" default="release-notes" xmlns:hlm="http://www.nokia.com/helium">
    <description>
    Generates a release note by modifying a template (that you can edit yourself) with
    values from the build and Synergy.
    
    * Modifies a RTF template with values from build
    * Adds table of errors and warnings
    * Generates list of baselines, projects and tasks used
    </description>

    <property name="releasenotes.output.dir" value="${build.output.dir}/relnotes"/>
    <property name="releasenotes.logo" value="${relnotes.config.dir}/logo.png"/>
    <property name="releasenotes.props" value="${relnotes.config.dir}/relnotes.properties"/>
    <property name="releasenotes.temp.props" value="${temp.build.dir}/relnotes.properties"/>
    <property name="releasenotes.temp.props2" value="${temp.build.dir}/relnotes2.properties"/>
    <property name="releasenotes.template" value="${relnotes.config.dir}/template.rtf"/>
    <property name="releasenotes.output" value="${releasenotes.output.dir}/${build.id}_relnotes.rtf"/>
    <property name="releasenotes.temp.errors" value="${temp.build.dir}/errors.csv"/>
    <property name="releasenotes.temp.output" value="${temp.build.dir}/tempDocument.rtf"/>
    <property name="releasenotes.scan2log" value="${build.log.dir}/${build.id}.${product.family}_scan2.html"/>
    
    <import file="${relnotes.config.dir}/relnotes_properties.ant.xml" optional="true"/>
    
    <!-- Private: -->
    <target name="release-notes-variant-configuration" depends="rombuild-prepare-input">
        
        <script language="jython" setbeans="false">
tagnames = ""
for product in project.getProperty("product.list").split(","):
    tagnames += "Type%sVariantTableHere\n" %  product 
project.setProperty("variant.product.tagnames", tagnames)
        </script>
        <replace file="${releasenotes.output}" token="TypeVariantTableHere" value="${variant.product.tagnames}" summary="true"/>
        <for list="${product.list}" delimiter="," param="product.name" >
            <sequential>            
                <exec executable="python" dir="${helium.dir}/tools/relnotes" failonerror="${failonerror}">
                    <arg value="getVariantConfiguration.py"/>
                    <arg value="@{product.name}"/>
                    <arg value="${localisation.language.file}"/>
                    <arg value="${rombuild.config.file.parsed}"/>
                    <arg value="${temp.build.dir}/variant_@{product.name}.csv"/>
                </exec>
                <hlm:python>
import ant
import rtfutils
rn = rtfutils.RTFUtils(ant.get_property(r'${releasenotes.output}'))
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'))
                </hlm:python>
  
                <delete file="${releasenotes.output}"/>
                <move file="${releasenotes.temp.output}" tofile="${releasenotes.output}"/>
            </sequential>
        </for>
    </target>
    
    <!-- Private: Create error list in release notes -->
    <target name="release-notes-error-summary">
        <exec executable="python" dir="${helium.dir}/tools/relnotes" failonerror="${failonerror}">
            <arg value="readHTML.py"/>
            <arg value="${releasenotes.scan2log}"/>
            <arg value="${releasenotes.temp.errors}"/>
        </exec>
        <hlm:python>
import ant
import rtfutils
rn = rtfutils.RTFUtils(ant.get_property(r'${releasenotes.output}'))
rn.rtftable(ant.get_property(r'${releasenotes.temp.errors}'), ant.get_property(r'${releasenotes.temp.output}'), 'TypeErrorTableSummaryHere')
        </hlm:python>
        <delete file="${releasenotes.output}"/>
        <move file="${releasenotes.temp.output}" tofile="${releasenotes.output}"/>
    </target>
    
    <!-- Private: Add logo to release notes -->
    <target name="release-notes-logo">
        <hlm:python>
import ant
import rtfutils
rn = rtfutils.RTFUtils(ant.get_property(r'${releasenotes.output}'))
rn.rtfimage(ant.get_property(r'${releasenotes.logo}'), ant.get_property(r'${releasenotes.temp.output}'), 'AddProductImageHere')
        </hlm:python>
        <move file="${releasenotes.temp.output}" tofile="${releasenotes.output}"/>
    </target>
    
    <!-- Private: Find project and baseline of what is running helium -->
    <target name="release-notes-getcmprojectname">
        <script language="jython" setbeans="false">
import ccm.extra
import traceback
import os
import logging
import ccmutil

#logging.basicConfig(level=logging.DEBUG)
session = None
try:
    database = project.getProperty('ccm.database')
    username = project.getProperty('ccm.user.login')
    password = project.getProperty('ccm.user.password')
    engine = project.getProperty('ccm.engine.host')
    dbpath = project.getProperty('ccm.database.path')     
    waroot = project.getProperty('create.bom.workarea.root')
    
    session = ccmutil.get_session(database, username, password, engine, dbpath)
    cmproject = ccm.extra.get_toplevel_project(session, waroot)
    
    if cmproject == None:
        print 'Error: ' + waroot + ' must be a synergy project and still be in database'
    else:
        project.setProperty("ccm.toplevel.project", str(cmproject))
    session.close()
except Exception, ex:
    print 'Caught exception: ' + str(ex)
    traceback.print_exc()
        </script>
        <hlm:python outputproperty="ccm.toplevel.baseline">
import traceback
import ant
import logging
import ccmutil
logging.disable(logging.INFO)
session = None
try:
    database = ant.get_property(r'${ccm.database}')
    username = ant.get_property(r'${ccm.user.login}')
    password = ant.get_property(r'${ccm.user.password}')
    engine = ant.get_property(r'${ccm.engine.host}')
    dbpath = ant.get_property(r'${ccm.database.path}')
    session = ccmutil.get_session(database, username, password, engine, dbpath)
    cmproject = session.create(ant.get_property(r'${ccm.toplevel.project}'))
    print cmproject.baseline
    session.close()
except Exception, ex:
    print 'Caught exception: ' + str(ex)
    traceback.print_exc()
        </hlm:python>
    </target>
    
    <!-- Private: 
    Look at property 'project.startswith' and find complete CM name
    Output property: '${project.startswith}.project'
    -->
    <target name="release-notes-getprojectname">
        <hlm:python outputproperty="release.notes.temp">
import amara
import ant

bomfile = open(r"${temp.build.dir}/${build.id}_BOM.xml")
bom = amara.parse(bomfile)

for p in bom.bom.content.project:
    if (str(p.name).startswith(ant.get_property(r'${project.startswith}'))):
        print str(p.name)
bomfile.close()
        </hlm:python>
        <script language="jython" setbeans="false">
project.setProperty(project.getProperty('project.startswith') + '.project', project.getProperty('release.notes.temp'))
        </script>
        
    </target>
    
    <!-- Private: Write projects, baselines and task list for MC and IBUSAL -->
    <target name="release-notes-ccm" depends="get-ccm-password,release-notes-getcmprojectname,create-bom">
        <hlm:python>
import amara
import ant
import bomtofile
import ccmutil

bomfile = open(r"${temp.build.dir}/${build.id}_BOM.xml")
bom = amara.parse(bomfile)
session = ccmutil.get_session(ant.get_property(r'${ccm.database}'), ant.get_property(r'${ccm.user.login}'), ant.get_property(r'${ccm.user.password}'), ant.get_property(r'${ccm.engine.host}'), ant.get_property(r'${ccm.database.path}'))
for p in bom.bom.content.project:
    if p.name == ant.get_property(r'${ccm.toplevel.project}'):
        bomwriter = bomtofile.BOMWriter(session, 'MC', p, ant.get_property(r'${releasenotes.output.dir}'))
        bomwriter.writeprojects()
        bomwriter.writebaselines()
        bomwriter.writetasks()
            
    if (str(p.name).startswith('IBUSAL')):
        bomwriter = bomtofile.BOMWriter(session, 'IBUSAL', p, ant.get_property(r'${releasenotes.output.dir}'))
        bomwriter.writeprojects()
        bomwriter.writetasks()
session.close()
bomfile.close()
        </hlm:python>
    </target>
    
    <!-- Private: Read BOM and write ICF list -->
    <target name="release-notes-icfs" depends="create-bom">
        <exec executable="python" dir="${helium.dir}/tools/relnotes" failonerror="${failonerror}">
            <arg value="icf2txt.py"/>
            <arg value="${temp.build.dir}/${build.id}_BOM.xml"/>            
            <arg value="${releasenotes.output.dir}/icdicf.txt"/>
        </exec>
    </target>
    
    <!-- Private: -->
    <target name="release-notes-test" if="hlm.enable.asserts">
        <hlm:python>
import ccm
#check for ccm session leaks
assert (len(ccm.running_sessions()) == 0)
        </hlm:python>
    </target>
        
    <!-- 
    Generates a product release note based on a template in config dir
    -->
    <target name="release-notes" description="Generates a product release note based off a template in config dir">        
        <mkdir dir="${releasenotes.output.dir}"/>
        
        <copy file="${releasenotes.props}" tofile="${releasenotes.temp.props}">
            <filterchain>
                <expandproperties/>
            </filterchain>
        </copy>
          
        <hlm:python>
import ant
import rtfutils
rn = rtfutils.RTFUtils(ant.get_property(r'${releasenotes.output}'))
rn.rtfconvert(ant.get_property(r'${releasenotes.temp.props}'), ant.get_property(r'${releasenotes.temp.props2}'))
        </hlm:python>
        
        <property file="${releasenotes.temp.props2}"/>                
        <copy file="${releasenotes.template}" tofile="${releasenotes.output}" overwrite="true"/>

        <antcall target="release-notes-logo" />
        <antcall target="release-notes-error-summary" />
        <antcall target="release-notes-variant-configuration" />
            
        <delete file="${releasenotes.temp.errors}"/>
        <delete file="${releasenotes.temp.output}"/>
        <delete file="${releasenotes.temp.props}"/>
        <delete file="${releasenotes.temp.props2}"/>
        
        <antcall target="release-notes-ccm"/>
        
        <antcall target="release-notes-icfs"/>
    
        <antcall target="release-notes-replace"/>
        
        <antcall target="release-notes-test"/>
    </target>

</project>