<?xml version="1.0" encoding="UTF-8"?>
<!-- 
============================================================================ 
Name        : subcon.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="publish.subcon" xmlns:hlm="http://www.nokia.com/helium">
    <description>
    Targets for subcon build.
    </description>
    
    <!-- Verifies that the subcon zips allow subcon images to be built. -->
    <target name="create-subcon-roms">
        <!-- preparation.ant.xml <target name="prep-prepare-input"> 
        This will generate the subcon.prep.xml.parsed file with the appropriate file locations
        but with everything as it was in the original build (locations wise...)
        -->
        <property name="subcon.prep.config.file.parsed" location="${build.output.dir}/subcon.prep.xml.parsed" />
        <copy file="${subcon.prep.config.file}" tofile="${subcon.prep.config.file.parsed}" overwrite="true">
            <filterchain>
                <expandproperties/>
            </filterchain>
        </copy>
        <property name="subcon.prep.build.dir" value="${prep.root.dir}/subcon_${build.id}"/>

        <antcall target="subcon-build">
            <param name="build.drive" value="${subcon.build.drive}"/>
            <param name="prep.config.file" value="${subcon.prep.config.file}"/>
            <param name="prep.config.file.parsed" value="${subcon.prep.config.file.parsed}"/>
            <param name="prep.build.dir" value="${subcon.prep.build.dir}"/>
            <param name="build.log.dir" value="${subcon.build.drive}/output/logs"/>
        </antcall>

        <!-- CLEAR THE subcon.build.drive Drive -->
        <hlm:unsubst drive="${subcon.build.drive}" failonerror="${failonerror}"/>
    </target>

    
    <!-- Runs a mini build sequence for testing subcon zips. -->
    <target name="subcon-build" depends="prep-drive,init-build-area,subcon-prep-copy,subcon-roms"/>
   
    
    <!-- Prepares a build drive with subcon zip content.
    
    TODO: how to stop doing whole subcon stage if prep fails, but not kill the build?
    -->
    <target name="subcon-prep-copy" depends="prep-prepare-input">
        <preset.exec executable="${env.PERL}" failonerror="${failonerror}"
                     output="${build.log.dir}/${build.id}_subcon_buildarea_prep.log">
            <arg value="${helium.dir}/tools/preparation/prep_build_area.pl" />
            <arg value="-config" />
            <arg value="${prep.config.file.parsed}" />
            <arg value="-destdir" />
            <arg value="${build.drive}${env.EPOCROOT}" />
            <arg value="-zipdir" />
            <arg value="${build.drive}/unzip" />
        </preset.exec>
        <!--Delete Symbian file to force S60 version to compile-->
        <delete file="${build.drive}/epoc32/tools/j2me/hromize.exe" />
    </target>

    
    <!-- Copies subcon ROMs back to the main build area. -->
    <target name="copy-subcon-roms" depends="create-subcon-roms">
        <copy todir="${build.output.dir}" preservelastmodified="true" failonerror="false">
            <fileset dir="${subcon.prep.build.dir}\output" casesensitive="false">
                <include name="**/*"/>
            </fileset>
        </copy>
    </target>

    
    <!-- Verifies that subcon zips can be used to create subcon ROMs. -->
    <target name="verify-subcon-zips" depends="create-subcon-roms,copy-subcon-roms,zip-subcon-roms"/>
    
</project>
