buildframework/helium/tools/compile/compile.antlib.xml
changeset 1 be27ed110b50
child 179 d8ac696cc51f
equal deleted inserted replaced
0:044383f39525 1:be27ed110b50
       
     1 <?xml version="1.0" encoding="UTF-8"?>
       
     2 <!--
       
     3 ============================================================================
       
     4 Name        : compile.antlib.xml
       
     5 Part of     : Helium
       
     6 
       
     7 Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     8 All rights reserved.
       
     9 This component and the accompanying materials are made available
       
    10 under the terms of the License "Eclipse Public License v1.0"
       
    11 which accompanies this distribution, and is available
       
    12 at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
    13 
       
    14 Initial Contributors:
       
    15 Nokia Corporation - initial contribution.
       
    16 
       
    17 Contributors:
       
    18 
       
    19 Description:
       
    20 
       
    21 ============================================================================
       
    22 -->
       
    23 <antlib xmlns:hlm="http://www.nokia.com/helium">
       
    24     <!-- This task transfer the log file into html format -->
       
    25     <macrodef name="compileHtmlscanlogMacro" uri="http://www.nokia.com/helium">
       
    26         <attribute name="input"/>
       
    27         <attribute name="output"/>
       
    28         <sequential>
       
    29             <exec dir="${build.drive}/" executable="perl" failonerror="${failonerror}">
       
    30                 <arg value="${epocroot}epoc32/tools/htmlscanlog.pl"/>
       
    31                 <arg value="-v"/>
       
    32                 <arg value="-v"/>
       
    33                 <arg value="-l"/>
       
    34                 <arg file="@{input}"/>
       
    35                 <arg value="-o"/>
       
    36                 <arg file="@{output}"/>
       
    37             </exec>
       
    38             <hlm:assertFileExists file="@{output}"/>
       
    39         </sequential>
       
    40     </macrodef>
       
    41 
       
    42     <macrodef name="calculateErrorsFromLog" uri="http://www.nokia.com/helium">
       
    43         <attribute name="logfile"/>
       
    44         <sequential>
       
    45             <if>
       
    46                 <not>
       
    47                     <isset property="skip.diamonds"/>
       
    48                 </not>
       
    49                 <then>
       
    50                     <fmpp sourceFile="${helium.dir}/tools/common/templates/diamonds/faults_metadata.ftl"
       
    51                                  outputfile="${build.log.dir}/compile-main.xml">
       
    52                         <data expandProperties="yes">
       
    53                             dbPath: ${metadata.dbfile}
       
    54                             logpath: @{logfile} 
       
    55                             ant: antProperties()
       
    56                         </data>
       
    57                     </fmpp>
       
    58                 </then>
       
    59             </if>
       
    60         </sequential>
       
    61     </macrodef>
       
    62 
       
    63     <macrodef name="compileLogSignalMacro" uri="http://www.nokia.com/helium">
       
    64         <attribute name="compile.summary.file"/>
       
    65         <attribute name="error.limit"/>
       
    66         <sequential>
       
    67             <hlm:metadataCountSeverity severity="ERROR" log="@{compile.summary.file}" 
       
    68                 db="${metadata.dbfile}" 
       
    69                 property="build.errors.total"/>
       
    70                 
       
    71             <echo>Errors after compile-main: ${build.errors.total}</echo>
       
    72             <echo message="${build.errors.limit}" />
       
    73             <echo message="@{error.limit}" />
       
    74             <if>
       
    75                 <scriptcondition language="jython" value="false">
       
    76 errorsTotal = project.getProperty("build.errors.total")
       
    77 errorsLimit = project.getProperty("build.errors.limit")
       
    78 if int(errorsLimit) > -1:
       
    79     if int(errorsTotal) > int(errorsLimit):
       
    80         self.setValue(1)
       
    81                 </scriptcondition>
       
    82                 <then>
       
    83                     <property name="compile.result" value="1"/>
       
    84                 </then>
       
    85                 <else>
       
    86                     <property name="compile.result" value="0"/>
       
    87                 </else>
       
    88             </if>
       
    89             <echo message="compile result:${compile.result}" />
       
    90             <hlm:signalMacro skip.count="true" result="${compile.result}" 
       
    91                 logfile="@{compile.summary.file}" 
       
    92                 signal.input="${compile.signal.input}" />
       
    93         </sequential>
       
    94     </macrodef>
       
    95     
       
    96     <!-- Macro to start the build using EBS. Parameters are generated xml file for EBS builds
       
    97     the log output of the build and the number of threads for the build. -->
       
    98     <macrodef name="compileEbsMacro" uri="http://www.nokia.com/helium">
       
    99         <attribute name="input"/>
       
   100         <attribute name="log"/>
       
   101         <attribute name="threads" default="${number.of.threads}"/>
       
   102         <sequential>
       
   103             <exec executable="perl" dir="${build.drive}/" failonerror="${failonerror}">
       
   104                 <env key="EPOCROOT" value="${epocroot}"/>
       
   105                 <arg value="${helium.dir}/tools/compile/buildjob.pl"/>
       
   106                 <arg value="-d"/>
       
   107                 <arg value="@{input}"/>
       
   108                 <arg value="-l"/>
       
   109                 <arg value="@{log}"/>
       
   110                 <arg value="-n"/>
       
   111                 <arg value="${number.of.threads}"/>
       
   112             </exec>
       
   113             <hlm:assertFileExists file="@{log}"/>
       
   114         </sequential>
       
   115     </macrodef>
       
   116 
       
   117     <!-- Macro to generate the xml file for EBS builds. Inputs are Merged xml file for the process,
       
   118     configuration for which the EBS xml file is generated and the output xml file for the EBS builds and
       
   119     the log output of the build. -->
       
   120     <macrodef name="compileGenxmlMacro" uri="http://www.nokia.com/helium">
       
   121         <attribute name="input"/>
       
   122         <attribute name="configuration"/>
       
   123         <attribute name="output"/>
       
   124         <attribute name="log"/>
       
   125         <sequential>
       
   126             <preset.exec executable="perl" dir="${build.drive}/" failonerror="${failonerror}">
       
   127                 <arg value="${epocroot}epoc32/tools/build/genxml.pl"/>
       
   128                 <arg value="-o"/>
       
   129                 <arg value="@{output}"/>
       
   130                 <arg value="-l"/>
       
   131                 <arg value="@{log}"/> <!-- ${build.log.dir}/${build.id}.@{configuration}_genxml.log -->
       
   132                 <arg value="-s"/>
       
   133                 <arg value="${epocroot}"/>
       
   134                 <arg value="-n"/>
       
   135                 <arg value="@{configuration}"/>
       
   136                 <arg line="@{input}"/>
       
   137             </preset.exec>
       
   138             <hlm:assertFileExists file="@{output}"/>
       
   139             <hlm:assertFileExists file="@{log}"/>
       
   140         </sequential>
       
   141     </macrodef>
       
   142 
       
   143     <!--
       
   144         Merges all preprocessed System Definition files into one combined file
       
   145         This macro also handles the copying of the sysdef DTDs on the root of
       
   146         the build environment.
       
   147     -->
       
   148     <macrodef name="compileGenxmlMergeMacro" uri="http://www.nokia.com/helium">
       
   149         <attribute name="input"/>
       
   150         <attribute name="output"/>
       
   151         <sequential>
       
   152             <copy todir="${build.drive}/" verbose="true">
       
   153                 <fileset dir="${helium.dir}/tools/common/dtd" includes="*.dtd"/>
       
   154             </copy>
       
   155             <preset.exec executable="perl" dir="${build.drive}/" failonerror="${failonerror}" output="${build.log.dir}/${build.id}.sysdef_GenxmlMerge.log">
       
   156                 <arg value="${epocroot}epoc32/tools/build/genxml.pl"/>
       
   157                 <arg value="-s"/>
       
   158                 <arg value="${epocroot}"/>
       
   159                 <arg value="-m"/>
       
   160                 <arg value="@{output}"/>              
       
   161                 <arg line="@{input}"/>
       
   162             </preset.exec>
       
   163             <if>
       
   164                 <not>
       
   165                     <available file="@{output}"/>
       
   166                 </not>
       
   167                 <then>
       
   168                     <!-- Todo: metadata: Make sure that logfilter is added to the filterset -->
       
   169                     <hlm:metadatarecord database="${metadata.dbfile}">
       
   170                         <hlm:textmetadatainput>
       
   171                             <fileset casesensitive="false" file="${build.log.dir}/${build.id}.sysdef_GenxmlMerge.log" />
       
   172                             <metadatafilterset>
       
   173                                 <metadatafilter priority="ERROR" regex="^ERROR:" description="genxml error" />
       
   174                                 <metadatafilter priority="ERROR" regex="^Context:" description="genxml context error" />
       
   175                             </metadatafilterset>
       
   176                             <metadatafilterset refid="filterset.genxml.merge" />
       
   177                         </hlm:textmetadatainput>
       
   178                     </hlm:metadatarecord>
       
   179                     <hlm:generateBuildStatus file="${build.id}.sysdef_GenxmlMerge.log" />
       
   180                     <hlm:signal name="canonicalSysDefFailSignal" result="1" >
       
   181                         <signalNotifierInput>
       
   182                             <signalInput refid="canonicalSysDefFailSignalInput" />
       
   183                             <notifierInput file = "${build.signal.status.dir}/${build.id}.sysdef_GenxmlMerge.log.status.html" />
       
   184                         </signalNotifierInput>
       
   185                     </hlm:signal>
       
   186                 </then>
       
   187             </if>
       
   188 
       
   189             <hlm:assertFileExists file="@{output}"/>
       
   190         </sequential>
       
   191     </macrodef>
       
   192 
       
   193     <!--
       
   194       This macro uses genxml to filter a sysdef file.
       
   195       -->
       
   196     <macrodef name="compileGenxmlFilterMacro" uri="http://www.nokia.com/helium">
       
   197         <attribute name="input"/>
       
   198         <attribute name="output"/>
       
   199         <attribute name="filter"/>
       
   200         <sequential>
       
   201             <preset.exec executable="perl" dir="${build.drive}/" failonerror="${failonerror}">
       
   202                 <arg value="${epocroot}epoc32/tools/build/genxml.pl"/>
       
   203                 <arg value="-s"/>
       
   204                 <arg value="${epocroot}"/>
       
   205                 <arg value="-m"/>
       
   206                 <arg value="@{output}"/>
       
   207                 <arg value="-f"/>
       
   208                 <arg value="@{filter}"/>
       
   209                 <arg value="-l"/>
       
   210                 <arg line="@{output}.log"/>
       
   211                 <arg value="-x"/>
       
   212                 <arg value="@{input}"/>
       
   213             </preset.exec>
       
   214             <hlm:assertFileExists file="@{output}"/>
       
   215         </sequential>
       
   216     </macrodef>
       
   217 
       
   218 
       
   219   <!--
       
   220     Electric Cloud emake support.
       
   221     e.g:
       
   222     <pre>
       
   223     <hlm:emakeMacro name="zip-ee" makefile="/foo.mk" log="${build.log.dir}/zip-ee.log" target="zip-all"/>
       
   224     </pre>
       
   225     Optionally to generate emake annotation file use/add attribute annodetail="basic,history,file,waiting".
       
   226   -->
       
   227     <scriptdef name="emakeMacro" language="beanshell" uri="http://www.nokia.com/helium">
       
   228         <attribute name="name"/>
       
   229         <attribute name="log"/>
       
   230         <attribute name="makefile"/>
       
   231         <attribute name="target"/>
       
   232         <attribute name="custom"/>
       
   233         <attribute name="dir"/>
       
   234         <attribute name="annodetail"/>
       
   235         <attribute name="root"/> 
       
   236         <attribute name="failonerror"/> 
       
   237           self.setTaskName("emake");
       
   238           // check attributes
       
   239           if (attributes.get("name") == null)
       
   240             throw new org.apache.tools.ant.BuildException("name attribute is not defined");
       
   241           self.log("Name: " + attributes.get("name"));
       
   242           if (attributes.get("makefile") == null)
       
   243             throw new org.apache.tools.ant.BuildException("makefile attribute is not defined");
       
   244           self.log("Makefile: " + attributes.get("makefile"));
       
   245           String target = "all";
       
   246           String custom = "";
       
   247           if (attributes.get("target") != null)
       
   248             target = attributes.get("target");
       
   249           self.log("Target: " + target);
       
   250           if (attributes.get("custom") != null)
       
   251             custom = attributes.get("custom");
       
   252           if (attributes.get("root") != null)
       
   253             root = attributes.get("root");
       
   254           else
       
   255             root = "";
       
   256           self.log("Custom: " + custom);
       
   257 
       
   258       // Create and configure exec target
       
   259           org.apache.tools.ant.taskdefs.ExecTask task = new org.apache.tools.ant.taskdefs.ExecTask();
       
   260           task.setTaskName(self.getTaskName());
       
   261           String emake = com.nokia.ant.util.Helper.getProperty(project, "ec.emake");          
       
   262           task.setExecutable(emake);
       
   263           if (attributes.get("failonerror") != null) {
       
   264             task.setFailonerror(Boolean.parseBoolean(attributes.get("failonerror")));
       
   265           } else {
       
   266             task.setFailonerror(true);
       
   267           }
       
   268           String buildDrive = com.nokia.ant.util.Helper.getProperty(project, "build.drive");              
       
   269           task.setDir(new java.io.File(buildDrive + "/"));
       
   270           if (attributes.get("log") != null) {
       
   271             self.log("Log: " + attributes.get("log"));
       
   272             task.setOutput(new java.io.File(attributes.get("log")));
       
   273           }
       
   274           if (attributes.get("dir") != null) {
       
   275             self.log("dir: " + attributes.get("dir"));
       
   276             task.setDir(new java.io.File(attributes.get("dir")));
       
   277           }
       
   278           String buildId = com.nokia.ant.util.Helper.getProperty(project, "build.id");
       
   279           task.createArg().setValue("--emake-build-label=" + buildId + "-" + attributes.get("name"));
       
   280           String eclass = com.nokia.ant.util.Helper.getProperty(project, "ec.build.class");
       
   281           task.createArg().setValue("--emake-class=" + eclass);
       
   282           String eroot = com.nokia.ant.util.Helper.getProperty(project, "env.EMAKE_ROOT");          
       
   283           String heliumDir = com.nokia.ant.util.Helper.getProperty(project, "helium.dir"); 
       
   284           if (attributes.get("root") != null) {
       
   285             self.log("--emake-root=" + eroot + ";" + heliumDir + ";" + root);
       
   286           }         
       
   287           task.createArg().setValue("--emake-root=" + eroot + ";" + heliumDir + ";" + root);
       
   288           if (attributes.get("annodetail") != null) {
       
   289             task.createArg().setValue("--emake-annodetail=" + attributes.get("annodetail"));            
       
   290             task.createArg().setValue("--emake-annofile=" + com.nokia.ant.util.Helper.getProperty(project, "build.log.dir") + "/" + buildId + "-" + attributes.get("name") + ".anno.xml");
       
   291           }
       
   292           task.createArg().setLine(custom);
       
   293           task.createArg().setLine("-f " + attributes.get("makefile"));
       
   294           task.createArg().setLine(target);
       
   295           // Execute.
       
   296           task.execute();
       
   297     </scriptdef>
       
   298 
       
   299   <!-- Macro to build using Raptor.-->
       
   300     <scriptdef name="sbsMacro" language="beanshell" uri="http://www.nokia.com/helium">
       
   301         <attribute name="config"/>
       
   302         <attribute name="layers"/>
       
   303         <attribute name="engine"/>
       
   304         <attribute name="skipbuild"/>
       
   305         <attribute name="singlejob"/>
       
   306         <attribute name="layer-order"/>
       
   307         <attribute name="command"/>
       
   308         <attribute name="components"/>
       
   309 <![CDATA[
       
   310 import com.nokia.tools.sbs.SBSTool;
       
   311 SBSTool sbsTool = new SBSTool();
       
   312 sbsTool.execute(attributes,project);
       
   313 ]]>
       
   314     </scriptdef>
       
   315 
       
   316     <scriptdef name="getSBSConfigMacro" language="beanshell" uri="http://www.nokia.com/helium">
       
   317         <attribute name="sbs.sysdef.file"/>
       
   318 <![CDATA[
       
   319 import com.nokia.config.SAXConfigParser;
       
   320 SAXConfigParser configParser = new SAXConfigParser(attributes.get("sbs.sysdef.file"));
       
   321 project.setProperty("sbs.configs",configParser.getConfigs());
       
   322 ]]>
       
   323     </scriptdef>
       
   324 </antlib>