buildframework/helium/tools/rombuild/imaker.ant.xml
author Shabe Razvi <shaber@symbian.org>
Tue, 13 Jul 2010 18:31:50 +0100
branchhelium-7.0.x
changeset 614 e08bbc2db635
parent 593 4367a1b2db65
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        : imaker.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="rombuild.imaker" xmlns:hlm="http://www.nokia.com/helium">
    <description>
        ROM image creation using iMaker (future implementation).
    </description>

    <!--
       This task merges all files mentioned in the fileset and output them in filename output file. 
    -->
    <scriptdef name="mergeConfigXML" language="beanshell"  uri="http://www.nokia.com/helium">
        <element name="fileset" type="fileset"/>
        <attribute name="filename"/>
<![CDATA[
import java.io.File;
import org.dom4j.Node;
import org.dom4j.io.SAXReader;
import org.dom4j.DocumentHelper;
import org.dom4j.Element;
import org.dom4j.Document;
import org.dom4j.io.OutputFormat;
import org.dom4j.io.XMLWriter;

Document document = DocumentHelper.createDocument();
Element root = document.addElement("build");
Element rootConfig = root.addElement( "config" );
rootConfig.addAttribute("abstract", "true");
rootConfig.addAttribute("name", "ee-roms");

filesets = elements.get("fileset");
for (i = 0; i < filesets.size(); ++i) {
        ds = filesets.get(i).getDirectoryScanner(project);
        ds.scan();
        String[] files = ds.getIncludedFiles();
        for (j = 0; j < files.length ; ++j) {
           romconf = new File(ds.getBasedir(), files[j]);
           self.log("Adding " + romconf + ".");
           SAXReader reader = new SAXReader();
           Document document = reader.read(romconf);
           Node node = document.selectSingleNode("//build/config");
           rootConfig.add(node.detach());
        }
}
// lets write to a file
OutputFormat format = OutputFormat.createPrettyPrint();
XMLWriter writer = new XMLWriter(new FileWriter(attributes.get("filename")), format);
writer.write( document );
writer.close();
]]>
    </scriptdef>
    
    <!--
       This target is an helper to recompose the rom image configuration using the output of iMaker.
    -->
    <target name="imaker-merge-rom-xml">
        <mkdir dir="${temp.build.dir}"/>
        <property name="rombuild.config.file.parsed" location="${build.output.dir}/rom_config.xml.parsed" />
        <hlm:mergeConfigXML filename="${rombuild.config.file.parsed}">
            <fileset dir="${release.images.dir}" includes="**/*.iconfig.xml"/>    
        </hlm:mergeConfigXML>
    </target>

    <!-- Future official target for building roms using iMaker.
         To configure that target you have to define an imakerconfigurationset type identified by
         'imaker.rom.config'.
    -->
    <target name="build-roms" depends="rombuild-imaker-create-buildinfo">
        <mkdir dir="${roms.log.dir}"/>
        <if>
            <not>
                <isset property="imaker.engine" />
            </not>
            <then>
                <if>
                    <or>
                        <equals arg1="${build.system}" arg2="ec-helium" />
                        <equals arg1="${build.system}" arg2="sbs-ec" />
                    </or>
                    <then>
                        <property name="imaker.engine" value="imaker.engine.ec" />
                    </then>
                </if>
            </then>
        </if>
        <property name="imaker.engine" value="imaker.engine.default" />        
        <property name="imaker.rom.name" value=""/>
        <hlm:imaker epocroot="${build.drive}/" engineRefid="${imaker.engine}"
                        output="${roms.log.dir}/${build.id}${imaker.rom.name}.roms.log" verbose="true">
            <hlm:imakerconfigurationset refid="imaker.rom.config" />
        </hlm:imaker>
        <hlm:metadatarecord database="${metadata.dbfile}">
            <hlm:textmetadatainput>
                <fileset casesensitive="false" file="${roms.log.dir}/${build.id}${imaker.rom.name}.roms.log" />
                <metadatafilterset refid="filterset.imaker" />
            </hlm:textmetadatainput>
        </hlm:metadatarecord>
        <hlm:signalMacro logfile="${roms.log.dir}/${build.id}${imaker.rom.name}.roms.log" 
                         signal.input="rombuildSignalInput" />
        <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=imaker-romdir" />
                    <arg value="-Dname=roms" />
                    <arg value="-Dversion=1" />
                    <arg value="-Ddir=${release.images.dir}" />
                    <arg value="--updateData" />
                </exec>
            </then>
        </if>
    </target>
    
    <!-- iMaker engine configuration -->
    <hlm:defaultEngine id="imaker.engine.default" threads="${number.of.threads}" />

    <hlm:emakeEngine id="imaker.engine.ec">
        <arg value="--emake-emulation=symbian" />
        <arg value="--emake-annofile=${roms.log.dir}/${build.id}${imaker.rom.name}.anno.xml"/>
        <arg value="--emake-root=${env.EMAKE_ROOT}${path.separator}${helium.dir}"/>
        <arg value="--emake-annodetail=basic,history,file,waiting"/>
        <arg value="--emake-historyfile=${roms.log.dir}/${build.id}${imaker.rom.name}.emake.data" />
        <arg value="--emake-class=${ec.build.class}" />
    </hlm:emakeEngine>
    
</project>