<?xml version="1.0"?>
<!--
============================================================================
Name        : qt.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:

============================================================================
-->
<!--* @package compile -->
<project name="qt" xmlns:hlm="http://www.nokia.com/helium">
    <description>
    Qt build support.
    </description>
    
    <!-- The location of the ant template to run qmake commands.
    @type string
    -->
    <property name="qt.qmake.ant.template" location="${helium.dir}/tools/compile/qt/templates/run-qmake.ant.xml.ftl" />
    <!-- The location of the makefile template to run qmake commands.
    @type string
    -->
    <property name="qt.qmake.makefile.template" location="${helium.dir}/tools/compile/qt/templates/run-qmake.mk.ftl" />
    <!-- The command lines argument passed to the configure tool.
    @type string
    -->
    <property name="qt.configure.args" value="-platform win32-mwc -xplatform symbian-abld -confirm-license"/>
    <!-- Setting default arguments to qMake command line, if the qmakeArgs is defined from the system definition file then those arguments are discarded.
    @type string
    -->
    <property name="qt.qmake.default.args" value="-r"/>

    <!--* @property qmake.enabled
    Enables the run of qMake over a build configuration so bld.inf and mmps are generated for the build.
    @type boolean
    @editable required
    @scope public
    -->
    
    <!--* @property internal.qmake.enabled
    To run qmake based targets if qmake.enabled set to true.
    @type boolean
    @scope private
    -->
    
    <!-- Check, is qmake is enabled -->
    <condition property="internal.qmake.enabled">
        <istrue value="${qmake.enabled}"/>
    </condition>
    <condition property="iswindows" value="true" else="false">
        <os family='windows'/>
    </condition>
    
    <!--
        Executing qmake on all Qt components defined under the system definition file.
        It must use schema v1.5.0+, and Qt unit must define a proFile attibute.   
     -->
    <target name="run-qmake" if="internal.qmake.enabled">
        <!-- Generating the build steps from the sysdef information -->
        <if>
            <istrue value="${sysdef3.enabled}" />
            <then>
                <if>
                    <isreference refid="sysdef.filters.${sysdef.configuration}" />
                    <then>
                        <hlm:filterSysdef epocroot="${build.drive}/" srcfile="${canonical.sysdef.file}" 
                            destfile="${build.drive}/output/build/canonical_system_definition_${sysdef.configuration}.xml">
                            <filterSet refid="sysdef.filters.${sysdef.configuration}" />
                        </hlm:filterSysdef>
                    </then>
                    <else>
                        <echo message="The sysdef.filters.${sysdef.configuration} sysdefFilterSet is not defined." />
                        <copy file="${canonical.sysdef.file}"
                            tofile="${build.drive}/output/build/canonical_system_definition_${sysdef.configuration}.xml" />
                    </else>
                </if>
            </then>
            <else>
                <hlm:generate-layers />
            </else>
        </if>
        <if>
            <or>
                <equals arg1="${build.system}" arg2="ec-helium" />
                <equals arg1="${build.system}" arg2="sbs-ec" />
            </or>
            <then>
                <fmpp sourceFile="${qt.qmake.makefile.template}" outputFile="${temp.build.dir}/run-qmake-${sysdef.configuration}.mk">
                    <data expandProperties="yes">
                        data: xml(${build.drive}/output/build/canonical_system_definition_${sysdef.configuration}.xml)
                        ant: antProperties()
                    </data>
                </fmpp>
                <hlm:assertFileExists file="${temp.build.dir}/run-qmake-${sysdef.configuration}.mk" />
                <!-- Running the qmake steps -->
                <hlm:emakeMacro name="run-qmake-${sysdef.configuration}" makefile="${temp.build.dir}/run-qmake-${sysdef.configuration}.mk"
                                target="all" dir="${build.drive}/" log="${compile.log.dir}/${build.id}_${sysdef.configuration}.qmake.log"
                                annodetail="basic,history,file,waiting"
                                failonerror="false" 
                                phase="compile"/>
                <hlm:assertFileExists file="${compile.log.dir}/${build.id}_${sysdef.configuration}.qmake.log" />
            </then>
            <else>
                <fmpp sourceFile="${qt.qmake.ant.template}" outputFile="${temp.build.dir}/run-qmake-${sysdef.configuration}.ant.xml">
                    <data expandProperties="yes">
                        data: xml(${build.drive}/output/build/canonical_system_definition_${sysdef.configuration}.xml)
                        ant: antProperties()
                    </data>
                </fmpp>
                <hlm:assertFileExists file="${temp.build.dir}/run-qmake-${sysdef.configuration}.ant.xml" />
    
                <!-- Running the qmake steps -->
                <ant antfile="${temp.build.dir}/run-qmake-${sysdef.configuration}.ant.xml" dir="${build.drive}/"
                    output="${compile.log.dir}/${build.id}_${sysdef.configuration}.qmake.log"/>
                <hlm:assertFileExists file="${compile.log.dir}/${build.id}_${sysdef.configuration}.qmake.log" />
            </else>
        </if>
        <copy file="${compile.log.dir}/${build.id}_${sysdef.configuration}.qmake.log" tofile="${compile.log.dir}/${build.id}_${sysdef.configuration}.qmake.generated.txt">
            <filterchain>
                <linecontainsregexp>
                    <regexp pattern="Generating"/>
                </linecontainsregexp>
            </filterchain>
        </copy>
        <replaceregexp file="${compile.log.dir}/${build.id}_${sysdef.configuration}.qmake.generated.txt" match="^\s*(?:\[exec\])?\s*Generating[^/\\]*." replace="" byline="true"/>
        <hlm:assertFileExists file="${compile.log.dir}/${build.id}_${sysdef.configuration}.qmake.generated.txt"/>
        <hlm:metadatarecord database="${metadata.dbfile}">
            <hlm:textmetadatainput>
                <fileset casesensitive="false" file="${compile.log.dir}/${build.id}_${sysdef.configuration}.qmake.log" />
                <metadatafilterset refid="filterset.qmake" />
            </hlm:textmetadatainput>
        </hlm:metadatarecord>
        <hlm:signalMacro logfile="${compile.log.dir}/${build.id}_${sysdef.configuration}.qmake.log" 
                    signal.input="signalRunQMakeInput" phase="compile"/>
    </target>

</project>
