--- a/buildframework/helium/tools/common/common.antlib.xml Thu Mar 25 12:47:55 2010 +0000
+++ b/buildframework/helium/tools/common/common.antlib.xml Thu Mar 25 14:10:11 2010 +0000
@@ -20,6 +20,7 @@
============================================================================
-->
+<!--* @package framework -->
<antlib xmlns:au="org.apache.ant.antunit" xmlns:hlm="http://www.nokia.com/helium">
@@ -92,12 +93,12 @@
</pre>
-->
<scriptdef name="toolMacro" language="beanshell" uri="http://www.nokia.com/helium">
- <element name="toolvarset" classname="com.nokia.ant.types.VariableSet"/>
+ <element name="toolvarset" classname="com.nokia.helium.core.ant.types.VariableSet"/>
<attribute name="name"/>
<![CDATA[
import com.nokia.ant.util.ToolsProcess;
import com.nokia.tools.*;
-import com.nokia.ant.types.VariableSet;
+import com.nokia.helium.core.ant.types.VariableSet;
import org.apache.tools.ant.types.Reference;
Reference ref;
java.lang.String toolName = attributes.get("name");
@@ -118,6 +119,71 @@
}
]]>
</scriptdef>
+
+ <!-- ConE tool macro to run the command for each argument -->
+ <scriptdef name="conEToolMacro" language="beanshell" uri="http://www.nokia.com/helium">
+ <element name="arg" classname="com.nokia.ant.types.Variable"/>
+ <attribute name="name"/>
+<![CDATA[
+import com.nokia.ant.util.ToolsProcess;
+import com.nokia.tools.*;
+import com.nokia.ant.types.Variable;
+ conETool = ToolsProcess.getTool("ConE");
+ vars = elements.get("arg");
+ for (i = 0; i < vars.size(); ++i) {
+ try {
+ var = (Variable)vars.get(i);
+ conETool.storeVariables(var.getName(), var.getValue());
+ } catch (Exception e) {
+ self.log("Error: " + e);
+ //self.log("Tool Argument Validation failure");
+ throw e;
+ }
+ }
+ conETool.execute(project);
+]]>
+ </scriptdef>
+
+
+ <!-- This macro will read the line from file which matches the regexp -->
+ <scriptdef name="grepMacro" language="beanshell" uri="http://www.nokia.com/helium">
+ <attribute name="filename"/>
+ <attribute name="output"/>
+ <attribute name="regexp"/>
+<![CDATA[
+import java.util.*;
+import java.io.*;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+if (attributes.get("filename") == null || attributes.get("output") == null || attributes.get("regexp") == null)
+ throw new BuildException("Filename/output/regexp attribute is not set for readLineMacro");
+
+String search = attributes.get("regexp");
+String output = "";
+pattern = Pattern.compile(search);
+
+BufferedReader input = new BufferedReader(new FileReader(attributes.get("filename")));
+try {
+ String line = null;
+ Matcher match = null;
+ while (( line = input.readLine()) != null) {
+ match = pattern.matcher(line);
+ if (match.find()) {
+ //self.log("Line containg " + search + " is = " + line + " returned vaue = " + match.group(1));
+ int checkIndex = output.indexOf(match.group(1), 0);
+ if (checkIndex == -1 ) {
+ output = output + match.group(1) + ",";
+ }
+ }
+ }
+ } catch (IOException ex) {
+ ex.printStackTrace();
+ }
+ project.setNewProperty(attributes.get("output") , output);
+
+]]>
+ </scriptdef>
<!-- This task allow to dump the content of a text file to the shell. -->
<scriptdef name="echoFileMacro" language="beanshell" uri="http://www.nokia.com/helium">
@@ -152,90 +218,6 @@
</scriptdef>
- <!-- Macro to record content to a separate log file without recording in the main log. -->
- <macrodef name="recordStartMacro" uri="http://www.nokia.com/helium">
- <attribute name="name"/>
- <attribute name="emacsmode" default="false"/>
- <sequential>
- <if>
- <available file="${build.log}"/>
- <then>
- <record name="${build.log}" action="stop" append="true"/>
- </then>
- </if>
- <if>
- <available file="${build.log.dir}" type="dir"/>
- <then>
- <record name="${build.log.dir}/@{name}" action="start" append="true" emacsmode="@{emacsmode}"/>
- </then>
- </if>
- </sequential>
- </macrodef>
-
-
- <!-- Macro to stop recording content to a separate log file without recording in the main log. -->
- <macrodef name="recordStopMacro" uri="http://www.nokia.com/helium">
- <attribute name="name"/>
- <sequential>
- <if>
- <available file="${build.log.dir}/@{name}"/>
- <then>
- <record name="${build.log.dir}/@{name}" action="stop" append="true"/>
- </then>
- </if>
- <if>
- <available file="${build.log}"/>
- <then>
- <record name="${build.log}" action="start" append="true"/>
- </then>
- </if>
- </sequential>
- </macrodef>
-
-
- <!--Macro to stop recording to the main log file (if present) and record to
- a separate log file that is filtered after logging is stopped. -->
- <macrodef name="filterRecordStartMacro" uri="http://www.nokia.com/helium">
- <sequential>
- <if>
- <available file="${build.log}"/>
- <then>
- <record name="${build.log}" action="stop" append="true"/>
- </then>
- </if>
- <echo>Start of filtering ${build.log} for passwords</echo>
- <record name="${build.cache.log.dir}/temp_ant_build.log" action="start" loglevel="info"/>
- </sequential>
- </macrodef>
-
-
- <!--Macro to stop recording the seperate filtered log file, filter the passwords
- and start recording in main log file -->
- <macrodef name="filterRecordStopMacro" uri="http://www.nokia.com/helium">
- <attribute name="pattern"/>
- <attribute name="log" default="${build.log}"/>
- <attribute name="append" default="true"/>
- <sequential>
- <record name="${build.cache.log.dir}/temp_ant_build.log" action="stop"/>
- <concat destfile="@{log}" append="@{append}">
- <filelist dir="${build.cache.log.dir}" files="temp_ant_build.log"/>
- <filterchain>
- <tokenfilter>
- <replaceregex pattern="@{pattern}" replace="****" flags="gi"/>
- </tokenfilter>
- </filterchain>
- </concat>
- <delete file="${build.cache.log.dir}/temp_ant_build.log" failonerror="false"/>
- <if>
- <available file="${build.log}"/>
- <then>
- <record name="${build.log}" action="start" append="true"/>
- </then>
- </if>
- <echo>End of filtering @{log} for passwords</echo>
- </sequential>
- </macrodef>
-
<!-- A generic assert macro similar to AntUnit "assertTrue". -->
<macrodef name="assert" uri="http://www.nokia.com/helium">
@@ -404,15 +386,12 @@
raise Exception("No entry found for Type: %s" % str(attributes.get("type")))
(n_username, n_account, n_password) = netrc_info
if attributes.get('output-prop') != None:
- self.log("Output: %s" % attributes.get('output-prop'))
project.setProperty(str(attributes.get('output-prop')), str(n_password))
except Exception, e:
result = "-1"
- print "ERROR: %s" % e
+ print "Warning: %s" % e
if attributes.get('result-prop') != None:
- self.log("Result: %s" % attributes.get('result-prop'))
project.setProperty(str(attributes.get('result-prop')), str(result))
- self.log("%s: %s" % (attributes.get('result-prop'), project.getProperty(str(attributes.get('result-prop')))))
]]>
</scriptdef>
@@ -433,16 +412,12 @@
raise Exception("No entry found for Type: %s" % str(attributes.get("type")))
(n_username, n_account, n_password) = netrc_info
if attributes.get('output-prop') != None:
- self.log("Output: %s" % attributes.get('output-prop'))
project.setProperty(str(attributes.get('output-prop')), str(n_username))
except Exception, e:
result = "-1"
- print "ERROR: %s" % e
+ print "Warning: %s" % e
if attributes.get('result-prop') != None:
-
- self.log("Result: %s" % attributes.get('result-prop'))
project.setProperty(str(attributes.get('result-prop')), str(result))
- self.log("%s: %s" % (attributes.get('result-prop'), project.getProperty(str(attributes.get('result-prop')))))
]]>
</scriptdef>
@@ -482,7 +457,8 @@
session = provider.get(username, password, database=database, reuse=False)
else:
session = provider.get(username, password, engine, dbpath, reuse=False)
- del(session)
+ session.close()
+ provider.close()
except Exception, e:
print "ERROR: %s" % e
if str(e).find("access denied") != -1:
@@ -494,133 +470,16 @@
]]>
</scriptdef>
- <!-- Extract logs from text file and process error/warnings/components name etc
- into xml file.-->
- <scriptdef name="logextract" language="jython" uri="http://www.nokia.com/helium">
- <attribute name="file" />
- <attribute name="outputfile" />
- <element name="fileset" type="fileset"/>
- <element name="logfilterset" classname="com.nokia.ant.types.LogFilterSet"/>
- <![CDATA[
-import os.path
-import log2xml
-import java.io
-
-def convertFile(inputfile, outputfile, config):
- if (outputfile != None):
- print "output file not none"
- print "output file: %s" % outputfile
- targetfile = str(outputfile)
- else:
- #print "output file: %s" % outputfile
- targetfile = "%s.xml" % inputfile
- #print "targetFile %s" % targetfile
- if not os.path.exists(targetfile) or \
- (os.path.exists(targetfile) and os.path.getmtime(inputfile) > os.path.getmtime(targetfile)):
- self.getProject().log("Converting %s..." % inputfile)
- log2xml.convert(inputfile, targetfile, False, config)
- else:
- self.getProject().log("Extracted log is uptodate: %s" % inputfile)
-
-config = log2xml.DEFAULT_CONFIGURATION
-logfilterset = elements.get("logfilterset")
-if logfilterset != None and logfilterset.size() > 0:
- # if any logfilterset are dfined then
- # it override the default configuration
- config = {}
- for filtersetid in range(logfilterset.size()):
- filterset = logfilterset.get(filtersetid)
- if filterset.isReference():
- filterset = filterset.getRefid().getReferencedObject(project)
- filters = filterset.getFilters()
- for filterid in range(filters.size()):
- if not filters.get(filterid).getCategory() in config:
- config[filters.get(filterid).getCategory()] = []
- config[filters.get(filterid).getCategory()].append(str(filters.get(filterid).getRegex()))
-
-fileset = elements.get("fileset")
-outputfile = attributes.get("outputfile")
-if fileset != None and fileset.size() > 0:
- for filesetid in range(fileset.size()):
- dirscanner = fileset.get(filesetid).getDirectoryScanner(project)
- for filename in dirscanner.getIncludedFiles():
- inputfile = str(java.io.File(dirscanner.getBasedir(), str(filename)).getAbsolutePath())
- convertFile(inputfile, outputfile, config)
-elif attributes.get("file") != None:
- inputfile = str(java.io.File(str(attributes.get("file"))).getAbsolutePath())
- convertFile(inputfile, outputfile, config)
-else:
- self.log("No input specified.")
- ]]>
- </scriptdef>
-
-
- <!--Macro to stop recording to the main log file (if present) and record to
- a separate log file into a temporary location (doesn't need the build aread to work). -->
- <macrodef name="tempRecordStartMacro" uri="http://www.nokia.com/helium">
- <attribute name="name"/>
- <sequential>
- <mkdir dir="${build.cache.log.dir}"/>
- <if>
- <available file="${build.log}"/>
- <then>
- <record name="${build.log}" action="stop" append="true"/>
- </then>
- </if>
- <record name="${build.cache.log.dir}/@{name}" action="start" loglevel="verbose"/>
- </sequential>
- </macrodef>
-
-
- <!--Macro to restart the main log file (if present) and stop recording to
- a separate log file into a temporary location the file is next xml summarized
- and potentially copied to the build area (if exists). Else those files will get copied during the
- build area preparation. -->
- <macrodef name="tempRecordStopMacro" uri="http://www.nokia.com/helium">
- <attribute name="name"/>
- <attribute name="database" default="${metadata.dbfile}"/>
- <attribute name="filterref" default="filterset.temprecord"/>
- <sequential>
- <mkdir dir="${build.cache.log.dir}"/>
- <mkdir dir="${build.cache.log.dir}/signals"/>
- <record name="${build.cache.log.dir}/@{name}" action="stop" loglevel="verbose"/>
- <!--Temporary solution, the logextract in general
- needs to be handled in a better way (not all logs needs to be processed,
- logextract / counting errors could be merged and logextract should be
- executed on a need basis and not to process for all stopmacro.-->
- <!-- Todo: metadata: replace logextract -->
- <hlm:metadatarecord database="@{database}">
- <hlm:antmetadatainput>
- <fileset casesensitive="false" file="${build.cache.log.dir}/@{name}" />
- <metadatafilterset refid="@{filterref}" />
- </hlm:antmetadatainput>
- </hlm:metadatarecord>
- <hlm:generateBuildStatus dbfile="@{database}" output-dir="${build.cache.log.dir}/signals" file="@{name}" />
- <copy todir="${build.log.dir}" failonerror="false">
- <fileset casesensitive="false" file="${build.cache.log.dir}/@{name}" />
- </copy>
- <copy todir="${build.signal.status.dir}" failonerror="false">
- <fileset casesensitive="false" dir="${build.cache.log.dir}/signals" />
- </copy>
- <if>
- <available file="${build.log}"/>
- <then>
- <record name="${build.log}" action="start" append="true"/>
- </then>
- </if>
- </sequential>
- </macrodef>
-
-
<macrodef name="signalMacro" uri="http://www.nokia.com/helium">
<attribute name="logfile"/>
+ <attribute name="phase" default=""/>
<attribute name="signal.input" />
<attribute name="skip.count" default="false" />
<attribute name="result" default="not-set"/>
<sequential>
<var name="signal.errors.total" value="" unset="true"/>
<var name="base.signal.log.file" value="" unset="true"/>
- <basename property="base.signal.log.file" file="@{logfile}" suffix=".log"/>
+ <basename property="base.signal.log.file" file="@{logfile}"/>
<if>
<isfalse value="@{skip.count}" />
<then>
@@ -638,81 +497,34 @@
<var name="signal.errors.total" value="@{result}" />
</else>
</if>
+ <if>
+ <isset property="@{phase}.log.dir" />
+ <then>
+ <var name="signal.log.dir" value="" unset="true"/>
+ <property name="signal.log.dir" value="${@{phase}.log.dir}"/>
+ <echo>signal.log.dir = ${signal.log.dir}</echo>
+ </then>
+ <else>
+ <var name="signal.log.dir" value="" unset="true"/>
+ <property name="signal.log.dir" value="${build.log.dir}"/>
+ </else>
+ </if>
<hlm:generateBuildStatus output-dir="${build.signal.status.dir}/"
file="${base.signal.log.file}" />
<!-- signal for errors -->
<hlm:signal name="@{signal.input}" result="${signal.errors.total}" >
<signalNotifierInput>
<signalInput refid="@{signal.input}" />
- <notifierInput file = "${build.signal.status.dir}/${base.signal.log.file}.status.html" />
+ <notifierInput>
+ <fileset casesensitive="false" dir="${build.log.dir}" >
+ <include name="**/${base.signal.log.file}*" />
+ </fileset>
+ </notifierInput>
</signalNotifierInput>
</hlm:signal>
</sequential>
</macrodef>
- <!-- Macro to start logging to a separate log file.
-
- This will stop logging to the main ant_build log file until stopSpecificLogMacro
- is called. -->
- <macrodef name="startSpecificLogMacro">
- <attribute name="name"/>
- <attribute name="regexp" default=""/>
- <attribute name="backup" default="false"/>
-
- <sequential>
- <if>
- <available file="${build.log}"/>
- <then>
- <echo>Stopping recording to main Ant build log.</echo>
- <record name="${build.log}" action="stop" append="true"/>
- </then>
- </if>
- <mkdir dir="@{name}/.."/>
- <hlm:logrecord name="@{name}" action="start" loglevel="verbose" regexp="@{regexp}" backup="@{backup}"/>
- </sequential>
- </macrodef>
-
-
- <!--Macro to restart the main log file (if present) and stop recording to
- a separate log file. -->
- <macrodef name="stopSpecificLogMacro">
- <attribute name="name"/>
- <sequential>
- <hlm:logrecord name="@{name}" action="stop" loglevel="verbose"/>
- <if>
- <available file="${build.log}"/>
- <then>
- <record name="${build.log}" action="start" append="true"/>
- <echo>Starting recording to main Ant build log again.</echo>
- </then>
- </if>
- </sequential>
- </macrodef>
-
- <!-- Temp BMD macro -->
- <macrodef name="bmdLogExtractMacro" uri="http://www.nokia.com/helium">
- <attribute name="log"/>
- <attribute name="metadatafilterset" default="common"/>
- <sequential>
- <hlm:metadatarecord database="${metadata.dbfile}">
- <hlm:textmetadatainput>
- <fileset casesensitive="false" file="@{log}"/>
- <metadatafilterset refid="@{metadatafilterset}" />
- </hlm:textmetadatainput>
- </hlm:metadatarecord>
- <!-- todo: check to add for usage and add genbuildstatus macro -->
- <basename property="log.name" file="@{log}"/>
- <fmpp sourceFile="${helium.dir}/tools/common/templates/db2xml.xml.ftl"
- outputfile="@{log}.xml">
- <data expandProperties="yes">
- dbPath: ${metadata.dbfile}
- log: ${log.name}
- ant: antProperties()
- </data>
- </fmpp>
- </sequential>
- </macrodef>
-
<!-- A simple test macro -->
<macrodef name="fooMacro" uri="http://www.nokia.com/helium">
<sequential>