buildframework/helium/tools/compile/sbs/sbs.ant.xml
author wbernard
Thu, 04 Mar 2010 15:10:37 +0200
changeset 217 0f5e3a7fb6af
parent 179 d8ac696cc51f
child 587 85df38eb4012
permissions -rw-r--r--
helium_8.0-r15308

<?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:

============================================================================
-->
<!--* @package compile -->
<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

    -->

    <!-- skip sbs layer filtering (true) for new schema and false for schema 1.4.0
    @type boolean
    -->
    <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"/>
                    </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"/>
                        <var name="sbs.what.log" value="${sbs.log.file}.whatlog.log"/>
                        <!-- Generate the filtered layers -->
                        <if>
                            <isset property="run.coverity"/>
                            <then>
                                <hlm:coveritybuild  sbsinput="@{sbs.input}" 
                                                    sysdeffile="${build.drive}/output/build/canonical_system_definition_${sysdef.configuration}.xml"
                                                    layerpatternsetref="${sbs.patternset}" 
                                                    workingdir="${build.drive}/" 
                                                    execute="true"
                                                    failonerror="false"
                                                    outputlog="${sbs.log.file}" 
                                                    cleanlog = "${sbs.clean.log}"
                                                    whatlog = "${sbs.what.log}"
                                                    erroroutput="${sbs.log.file}.sbs_error.log"
                                                    statslog="${sbs.log.file}.info.xml">
                                    <hlm:coverityoptions refid="coverity.build.options"/>
                                </hlm:coveritybuild>
                            </then>
                            <elseif>
                                <istrue value="${sbs.build.ctc}"/>
                                <then>
                                    <hlm:ctctask 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}"
                                                    whatlog = "${sbs.what.log}"
                                                    statsLog="${sbs.log.file}.info.xml" />                                
                                </then>
                            </elseif>
                            <else>
                                <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}"
                                                whatlog = "${sbs.what.log}"
                                                statsLog="${sbs.log.file}.info.xml" />
                            </else>
                        </if>
                        <hlm:assertFileExists file="${sbs.log.file}"/>
                        <hlm:assertFileExists file="${sbs.clean.log}"/>
                        <hlm:assertFileExists file="${sbs.what.log}"/>
                        <hlm:assertFileExists file="${sbs.log.file}.sbs_error.log"/>
                        <hlm:assertFileExists file="${sbs.log.file}.info.xml"/>
                        <!-- run arm license checking / setting arm version only for arm config --> 
                        <echo message="sbs.log.file: ${sbs.log.file}" />
                        <hlm:sbsProcessOutputMacro sbs.log.file="${sbs.log.file}"
                            sbs.clean.log.file="${sbs.clean.log}" sbs.what.log.file="${sbs.what.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>
            </then>
        </if>
    </target>
    
    
    <macrodef name="sbsProcessOutputMacro" uri="http://www.nokia.com/helium">
        <attribute name="sbs.clean.log.file" />
        <attribute name="sbs.what.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_orm.html.ftl" />
            <var name="base.sbs.log" value="" unset="true"/>
            <basename property="base.sbs.log" file="@{sbs.log.file}" />
            <echo message="base.sbs.log: ${base.sbs.log}" />
            <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}" />
            <echo message="sbs.what.log.file :@{sbs.what.log.file}" />
            <trycatch property="hlm-sbs.parser.thrown">
                <try>
                    <hlm:metadatarecord  database="${metadata.dbfile}">
                        <hlm:sbsmetadatainput whatLogFile="@{sbs.what.log.file}" 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_orm.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})
                    whatLogPath: @{sbs.what.log.file}
                    ant: antProperties()
                </data>
            </fmpp>
            <echo message="generating signal" />
            <hlm:assertFileExists file="${build.log.dir}/${base.sbs.log}.scan2.html"/>
            <hlm:compileLogSignalMacro compile.summary.file="@{sbs.log.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>
    
    <scriptdef language="jython" name="getSbsHome" uri="http://www.nokia.com/helium">
        <attribute name="property" />
if attributes.get("property") is None:
    raise Exception("property attribute has not been set.")
if project.getProperty(attributes.get("property")) is None:
    import symbian.raptor
    sbs_home = symbian.raptor.getSBSHome()
    if sbs_home is not None:
        #self.log("Found SBS_HOME as " + sbs_home)
        project.setNewProperty(attributes.get("property"), sbs_home)
    </scriptdef>

</project>