<?xml version="1.0" encoding="UTF-8"?>
<!-- 
============================================================================ 
Name        : ivalidate_overlay.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="integration.validate-overlay" xmlns:hlm="http://www.nokia.com/helium">
    <description>Validation and merging of overlays to resolve conflicts.</description>

    <!-- Validates the overlay and outputs a log file listing any files that need to be merged
    because a more recent version is present in Synergy. -->
    <target name="validate-overlay" depends="get-ccm-password,ccm-prepare-input,prep-prepare-input">
        <fail unless="prep.config.file"/>
        
        <delete file="${build.cache.dir}\validate_overlay.html" failonerror="false"/>
        <delete file="${build.cache.dir}\validate_overlay.xml" failonerror="false"/>
        <delete file="${build.cache.dir}\validate_overlay.input.xml" failonerror="false"/>

        <!-- Analysing and creating the Virtual Build area configuration -->
        <preset.exec executable="python" dir="${build.cache.dir}">        
            <arg file="${helium.dir}/tools/integration/validate_overlay/generate_vo_conf_${ccmgetinput}.py"/>
            <arg line="${prep.delivery.conf.parsed}"/>
            <arg line="${prep.config.file.parsed}"/>                         
            <arg line="${build.cache.dir}/validate_overlay.input.xml"/>
        </preset.exec>
        
        <hlm:python>
import nokia.nokiaccm
import sys
import validateoverlay
import ant
import traceback
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}')
    if database != None:
        session = nokia.nokiaccm.open_session(username, password, database=database)
    else:
        session = nokia.nokiaccm.open_session(username, password, engine, dbpath)

    objects = validateoverlay.get_additional_delivery_objects(session, ant.get_property(r'${prep.delivery.conf.parsed}'))
    # overlay validation
    #validate(session, inputfile, overlaydir, showBranchInfo, createtask=False, releasetag=None, extra_objects=[]):    
    validateoverlay.validate(session, ant.get_property(r'${build.cache.dir}/validate_overlay.input.xml'), ant.get_property(r'${common.overlay.dir}'), True, False, None, objects, r'${build.cache.dir}\validate_overlay')
    
    session.close()
except Exception, e:
    print "ERROR: %s" % e
    print traceback.format_exc()
    session.close()
    sys.exit(-1)
sys.exit(0)
        </hlm:python>
        <preset.exec executable="cmd.exe">
            <!--<arg line="/c ${env.TEMP}\validate_overlay.html"/>-->
            <arg line="/c ${build.cache.dir}\validate_overlay.html"/>            
        </preset.exec>        
    </target>
    
    
    <!-- Creates a task containing merged files. This must be manually reviewed and submitted. -->
    <target name="merge-overlay" depends="get-ccm-password,ccm-prepare-input,prep-prepare-input">
        <fail unless="prep.config.file"/>
        
        <delete file="${build.cache.dir}\validate_overlay.html" failonerror="false"/>        
        <delete file="${build.cache.dir}\validate_overlay.xml" failonerror="false"/>        
        <delete file="${build.cache.dir}\validate_overlay.input.xml" failonerror="false"/>        
    
        <!-- Analysing and creating the Virtual Build area configuration -->
        <preset.exec executable="python" dir="${build.cache.dir}">        
            <arg file="${helium.dir}/tools/integration/validate_overlay/generate_vo_conf_${ccmgetinput}.py"/>
            <arg line="${prep.delivery.conf.parsed}"/>
            <arg line="${prep.config.file.parsed}"/>                         
            <arg line="${build.cache.dir}/validate_overlay.input.xml"/>                     
        </preset.exec>
        <hlm:python>
import nokia.nokiaccm
import sys
import validateoverlay
import ant
import traceback
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}')
    if database != None:
        session = nokia.nokiaccm.open_session(username, password, database=database)
    else:
        session = nokia.nokiaccm.open_session(username, password, engine, dbpath)
    objects = validateoverlay.get_additional_delivery_objects(session, ant.get_property(r'${prep.delivery.conf.parsed}'))
    # overlay validation    
    validateoverlay.validate(session, ant.get_property(r'${build.cache.dir}/validate_overlay.input.xml'), ant.get_property(r'${common.overlay.dir}'), True, True, 'mc/integration', objects, r'${build.cache.dir}\validate_overlay')    
    
    session.close()
except Exception, e:
    print "ERROR: %s" % e
    print traceback.format_exc()
    sys.exit(-1)
sys.exit(0)
        </hlm:python>
        <preset.exec executable="cmd.exe">            
            <arg line="/c ${build.cache.dir}\validate_overlay.html"/>            
        </preset.exec>        
    </target>
</project>
