buildframework/helium/tools/compile/sbs/sbs.ant.xml
author Shabe Razvi <shaber@symbian.org>
Tue, 13 Jul 2010 18:31:50 +0100
branchhelium-7.0.x
changeset 614 e08bbc2db635
parent 601 7c5cbd40d331
permissions -rw-r--r--
Implement enhancement Bug 3222 - Enable Helium to set diamonds status other than "succeeded" or "failed"

<?xml version="1.0" encoding="UTF-8"?>
<!-- 
============================================================================ 
Name        : sbs.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="compile.sbs" xmlns:hlm="http://www.nokia.com/helium">
    <description>
    Executes compilation of a System Model of System Definition file using Symbian SBS (Raptor) tools. 

    Should not be called directly but through compile-main by setting ${build.system.sbs} property.

    Example:

    hlm -Dsysdef.configurations.list=ALL -Dbuild.system=sbs compile-main
    hlm "-Dsysdef.configurations.list=REALLYCLEAN,ALL" -Dbuild.system=sbs compile-main
    </description>

    <!-- Executes compilation  of a System Model of System Definition file using Symbian SBS (Raptor) tools. 

    Should not be called directly but through compile-main by setting ${build.system.sbs} property.

    Example: 

    hlm -Dsysdef.configurations.list=ALL -Dbuild.system=sbs compile-main
    hlm "-Dsysdef.configurations.list=REALLYCLEAN,ALL" -Dbuild.system=sbs compile-main

    -->

    <property name="skip.sbs.layer.generation" value="false" />
    
    <!-- This target filters the canonical system definition file compare to the "raptor_${sysdef.configuration}" filter. -->
    <macrodef name="generate-layers" uri="http://www.nokia.com/helium">
        <sequential>
            <echo message="canno-file:${canonical.sysdef.file}" />
            <echo message="raptor-filters:raptor_${sysdef.configuration}" />
            <if>
                <istrue value="${skip.sbs.layer.generation}" />
                <then>
                    <copy file="${canonical.sysdef.file}" tofile="${build.drive}/output/build/canonical_system_definition_${sysdef.configuration}_temp.xml"/>
                </then>
                <else>
                    <hlm:compileGenxmlFilterMacro input="${canonical.sysdef.file}" filter="raptor_${sysdef.configuration}"
                        output="${build.output.dir}/build/canonical_system_definition_${sysdef.configuration}_temp.xml"/>
                </else>
            </if>
            <copy file="${build.drive}/output/build/canonical_system_definition_${sysdef.configuration}_temp.xml"
                    tofile="${build.drive}/output/build/canonical_system_definition_${sysdef.configuration}.xml">
                <filterchain>
                    <linecontainsregexp negate="true">
                        <regexp pattern="^\s*$"/>
                    </linecontainsregexp>
                </filterchain>
            </copy>
            <delete file="${build.drive}/output/build/canonical_system_definition_${sysdef.configuration}_temp.xml"/>
        </sequential>
    </macrodef>

    <!-- SBS build with gmake as engine type. Default is using sbs macro, to use old implementation to
    use using exec task, then sbs.using.exec needs to be set. -->
    <target name="compile-sbs" description="This is the main build that gets built for ARMV5 and WINSCW platforms">
        <!-- only temporary once config file option starts to work, then no 
        need to copy the plugin file -->

        <if>
            <or>
                <equals arg1="${build.system}" arg2="sbs" />
                <equals arg1="${build.system}" arg2="sbs-ec" />
            </or>
            <then>
                <echo message="Copying helium filter plugin to sbs home" />
                <copy file="${helium.dir}/tools/common/python/scripts/filter_metadatalog.py" todir="${env.SBS_HOME}/python/plugins/" failonerror="true" />
                <copy file="${helium.dir}/tools/common/python/scripts/sbsscanlogmetadata.py" todir="${env.SBS_HOME}/python/plugins/" failonerror="true" />
                <echo message="sbs.patternset: ${sbs.patternset}" />
                <hlm:generate-layers />
                <var name="sbs.internal.inputs.list" value="" unset="true"/>
                <if>
                    <istrue value="${schema.new}" />
                    <then>
                        <var name="sbs.internal.inputs.list" value="${sbs.inputs.list}"/>
                    </then>
                    <else>
                        <var name="sbs.internal.inputs.list" value="" unset="true"/>
                        <hlm:getsbsinputs config="sbs.${sysdef.configuration}" outputProperty="sbs.internal.inputs.list"/>  
                        <echo message="Inputs: ${sbs.internal.inputs.list}"/>
                    </else>
                </if>
                 <for list="${sbs.internal.inputs.list}" delimiter="," param="sbs.input">
                    <sequential>
                        <echo message="building raptor input: @{sbs.input}" />
                        <hlm:getVariableValue name="--logfile" property="sbs.log.file">
                            <hlm:sbsinput refid="@{sbs.input}" />
                        </hlm:getVariableValue>
                        <!-- run arm license checking / setting arm version only for arm config -->
                        <hlm:getVariableValue name="-c" property="compilevalue.var" failOnerror="false">
                            <hlm:sbsinput refid="@{sbs.input}" />
                        </hlm:getVariableValue>
                        <echo message="config parameter -c : ${compilevalue.var}" />
                        <if>
                            <and>
                                <isset property="compilevalue.var"/>
                                <matches string="${compilevalue.var}" pattern="arm.*"/>
                            </and>
                            <then>
                                <runtarget target="set-arm-version"/>
                            </then>
                        </if>
                        <var name="sbs.clean.log" value="${sbs.log.file}.clean.log"/>
                        <!-- Generate the filtered layers -->
                        <hlm:sbstask sbsinput="@{sbs.input}" sysdefFile="${build.drive}/output/build/canonical_system_definition_${sysdef.configuration}.xml" 
                            layerPatternSetRef="${sbs.patternset}" errorOutput="${sbs.log.file}.sbs_error.log" 
                            workingDir="${build.drive}/" failOnError="false" outputLog="${sbs.log.file}" cleanLog = "${sbs.clean.log}"
                             statsLog="${sbs.log.file}.info.xml" />

                        <!-- Check build for missing files -->
                        <exec osfamily="windows" executable="cmd" dir="${build.drive}/" input="${sbs.log.file}" output="${sbs.log.file}.check.log" failonerror="false">
                            <arg value="/c" />
                            <arg value="sbs_filter.bat" />
                            <arg value="--filters=FilterCheckComp" />
                        </exec>
                        <exec osfamily="unix" executable="sbs_filter" dir="${build.drive}/" input="${sbs.log.file}" output="${sbs.log.file}.check.log" failonerror="false">
                            <arg value="--filters=FilterCheckComp" />
                        </exec>
                        <hlm:assertFileExists file="${sbs.log.file}.check.log" />
                        
                        <!-- Push info to the database and generate scanlog. --> 
                        <echo message="sbs.log.file: ${sbs.log.file}" />
                        <hlm:sbsProcessOutputMacro sbs.log.file="${sbs.log.file}"
                            sbs.clean.log.file="${sbs.clean.log}"  sbs.stats.file="${sbs.log.file}.info.xml"
                            sbs.ant.output.file="${sbs.log.file}" sbs.error.output.file="${sbs.log.file}.sbs_error.log"/>
                    </sequential>
                </for>
                <hlm:assertFileExists file="${sbs.log.file}.sbs_error.log"/>
                <hlm:assertFileExists file="${compile.log.dir}/${build.id}_${sysdef.configuration}.info.xml"/>
                <hlm:assertFileExists file="${sbs.log.file}"/>
                <hlm:assertFileExists file="${sbs.clean.log}"/>
            </then>
        </if>
    </target>
    
    
    <macrodef name="sbsProcessOutputMacro" uri="http://www.nokia.com/helium">
        <attribute name="sbs.clean.log.file" />
        <attribute name="sbs.log.file" />
        <attribute name="sbs.stats.file" />
        <attribute name="sbs.error.output.file" />
        <attribute name="sbs.ant.output.file" />
        <sequential>
            <var name="sbs.scan2.template" value="scan2.html.ftl" />
            <var name="base.sbs.log" value="" unset="true"/>
            <basename property="base.sbs.log" file="@{sbs.log.file}" suffix=".log"/>
            <echo message="base.sbs.log: ${base.sbs.log}" />
            
            <!-- Push check log into the database -->
            <hlm:metadatarecord database="${metadata.dbfile}">
                <hlm:textmetadatainput>
                    <fileset casesensitive="false" file="@{sbs.log.file}.check.log"/>
                    <metadatafilterset refid="filterset.sbs" />
                </hlm:textmetadatainput>
            </hlm:metadatarecord>
            <delete file="${build.log.dir}/${base.sbs.log}.check.scan2.html" failonerror="false" />
            <exec executable="perl" dir="${build.drive}/" failonerror="false">
                <arg value="${build.drive}/epoc32/tools/htmlscanlog.pl" />
                <arg value="-v" />
                <arg value="-v" />
                <arg value="-l" />
                <arg file="@{sbs.log.file}.check.log" />
                <arg value="-o" />
                <arg file="${build.log.dir}/${base.sbs.log}.check.scan2.html" />
            </exec>
            <hlm:assertFileExists file="${build.log.dir}/${base.sbs.log}.check.scan2.html" />
            
            <hlm:metadatarecord database="${metadata.dbfile}">
                <hlm:textmetadatainput>
                    <fileset casesensitive="false" file="@{sbs.error.output.file}"/>
                    <metadatafilterset refid="filterset.sbs" />
                </hlm:textmetadatainput>
            </hlm:metadatarecord>
            <basename property="base.sbs.ant.output.log" file="@{sbs.ant.output.file}" />
            <hlm:signalMacro logfile="@{sbs.error.output.file}" 
                signal.input="raptorErrorSignalInput" phase="compile"/>
            <!-- update the resultes to database -->
            <echo message="Metadata enabled, storing build status in database" />
            <echo message="sbs log file :@{sbs.log.file}" />
            <echo message="sbs.clean.log.file :@{sbs.clean.log.file}" />
            <trycatch property="hlm-sbs.parser.thrown">
                <try>
                    <hlm:metadatarecord database="${metadata.dbfile}">
                        <hlm:sbsmetadatainput cleanLogFile="@{sbs.clean.log.file}">
                            <fileset casesensitive="false" file="@{sbs.log.file}"/>
                            <metadatafilterset refid="filterset.sbs" />
                        </hlm:sbsmetadatainput>
                    </hlm:metadatarecord>
                </try>
                <catch>
                    <if>
                        <istrue value="${skip.sbs.parser.exception}" />
                        <then>
                            <var name="sbs.scan2.template" value="scan2_text.html.ftl" />
                            <hlm:metadatadelete database="${metadata.dbfile}">
                                <fileset casesensitive="false" file="@{sbs.log.file}"/>
                            </hlm:metadatadelete>
                            <hlm:metadatarecord database="${metadata.dbfile}" >
                                <hlm:textmetadatainput>
                                    <fileset casesensitive="false" file="@{sbs.log.file}"/>
                                    <metadatafilterset refid="filterset.sbs" />
                                </hlm:textmetadatainput>
                            </hlm:metadatarecord>
                        </then>
                        <else>
                            <fail message="failed during raptor log parsing: might be due to invalid xml output from raptor" />
                        </else>
                    </if>
                </catch>
            </trycatch>
            <fmpp sourceFile="${helium.dir}/tools/common/templates/log/${sbs.scan2.template}"
                         outputfile="${build.log.dir}/${base.sbs.log}.scan2.html">
                <freemarkerLinks expandProperties="yes">
                    macro: ${helium.dir}/tools/common/templates/macro
                </freemarkerLinks>
                <data expandProperties="yes">
                    dbPath: ${metadata.dbfile}
                    doc: xml(@{sbs.stats.file})
                    ant: antProperties()
                </data>
            </fmpp>
            <echo message="generating signal" />
            <hlm:assertFileExists file="${build.log.dir}/${base.sbs.log}.scan2.html"/>
            <hlm:calculateErrorsFromLog logfile="@{sbs.log.file}" />
            <echo message="sbs.log.file: @{sbs.log.file}"/>
            <hlm:compileLogSignalMacro compile.summary.file="@{sbs.log.file}" 
                error.limit="${build.errors.limit}" phase="compile"/>
            <echo message="sbs.error.output.file: @{sbs.error.output.file}"/>
            <hlm:compileLogSignalMacro compile.summary.file="@{sbs.error.output.file}" 
                error.limit="${build.errors.limit}" phase="compile"/>
            <!-- Blocks packaging configuration generation. -->
            <if>
                <istrue value="${blocks.enabled}" />
                <then>
                    <mkdir dir="${blocks.config.dir}" />
                    <exec executable="python">
                        <arg value="-m"/>
                        <arg value="packager.cli"/>
                        <arg value="--epocroot=${build.drive}/" />
                        <arg value="--config=${blocks.config.dir}" />
                        <arg value="--datasource=sbs" />
                        <arg value="-Dsbslog=${sbs.log.file}" />
                        <arg value="-Dsysdef=${canonical.sysdef.file}" />
                        <arg value="-Dthreads=20" />
                        <arg value="--updateData" />
                    </exec>
                </then>
            </if>
        </sequential>
    </macrodef>
</project>