116 throw e; |
117 throw e; |
117 } |
118 } |
118 } |
119 } |
119 ]]> |
120 ]]> |
120 </scriptdef> |
121 </scriptdef> |
|
122 |
|
123 <!-- ConE tool macro to run the command for each argument --> |
|
124 <scriptdef name="conEToolMacro" language="beanshell" uri="http://www.nokia.com/helium"> |
|
125 <element name="arg" classname="com.nokia.ant.types.Variable"/> |
|
126 <attribute name="name"/> |
|
127 <![CDATA[ |
|
128 import com.nokia.ant.util.ToolsProcess; |
|
129 import com.nokia.tools.*; |
|
130 import com.nokia.ant.types.Variable; |
|
131 conETool = ToolsProcess.getTool("ConE"); |
|
132 vars = elements.get("arg"); |
|
133 for (i = 0; i < vars.size(); ++i) { |
|
134 try { |
|
135 var = (Variable)vars.get(i); |
|
136 conETool.storeVariables(var.getName(), var.getValue()); |
|
137 } catch (Exception e) { |
|
138 self.log("Error: " + e); |
|
139 //self.log("Tool Argument Validation failure"); |
|
140 throw e; |
|
141 } |
|
142 } |
|
143 conETool.execute(project); |
|
144 ]]> |
|
145 </scriptdef> |
|
146 |
|
147 |
|
148 <!-- This macro will read the line from file which matches the regexp --> |
|
149 <scriptdef name="grepMacro" language="beanshell" uri="http://www.nokia.com/helium"> |
|
150 <attribute name="filename"/> |
|
151 <attribute name="output"/> |
|
152 <attribute name="regexp"/> |
|
153 <![CDATA[ |
|
154 import java.util.*; |
|
155 import java.io.*; |
|
156 import java.util.regex.Matcher; |
|
157 import java.util.regex.Pattern; |
|
158 |
|
159 if (attributes.get("filename") == null || attributes.get("output") == null || attributes.get("regexp") == null) |
|
160 throw new BuildException("Filename/output/regexp attribute is not set for readLineMacro"); |
|
161 |
|
162 String search = attributes.get("regexp"); |
|
163 String output = ""; |
|
164 pattern = Pattern.compile(search); |
|
165 |
|
166 BufferedReader input = new BufferedReader(new FileReader(attributes.get("filename"))); |
|
167 try { |
|
168 String line = null; |
|
169 Matcher match = null; |
|
170 while (( line = input.readLine()) != null) { |
|
171 match = pattern.matcher(line); |
|
172 if (match.find()) { |
|
173 //self.log("Line containg " + search + " is = " + line + " returned vaue = " + match.group(1)); |
|
174 int checkIndex = output.indexOf(match.group(1), 0); |
|
175 if (checkIndex == -1 ) { |
|
176 output = output + match.group(1) + ","; |
|
177 } |
|
178 } |
|
179 } |
|
180 } catch (IOException ex) { |
|
181 ex.printStackTrace(); |
|
182 } |
|
183 project.setNewProperty(attributes.get("output") , output); |
|
184 |
|
185 ]]> |
|
186 </scriptdef> |
121 |
187 |
122 <!-- This task allow to dump the content of a text file to the shell. --> |
188 <!-- This task allow to dump the content of a text file to the shell. --> |
123 <scriptdef name="echoFileMacro" language="beanshell" uri="http://www.nokia.com/helium"> |
189 <scriptdef name="echoFileMacro" language="beanshell" uri="http://www.nokia.com/helium"> |
124 <attribute name="file"/> |
190 <attribute name="file"/> |
125 <![CDATA[ |
191 <![CDATA[ |
150 import log2xml |
216 import log2xml |
151 log2xml.symbian_log_footer(self) |
217 log2xml.symbian_log_footer(self) |
152 </scriptdef> |
218 </scriptdef> |
153 |
219 |
154 |
220 |
155 <!-- Macro to record content to a separate log file without recording in the main log. --> |
|
156 <macrodef name="recordStartMacro" uri="http://www.nokia.com/helium"> |
|
157 <attribute name="name"/> |
|
158 <attribute name="emacsmode" default="false"/> |
|
159 <sequential> |
|
160 <if> |
|
161 <available file="${build.log}"/> |
|
162 <then> |
|
163 <record name="${build.log}" action="stop" append="true"/> |
|
164 </then> |
|
165 </if> |
|
166 <if> |
|
167 <available file="${build.log.dir}" type="dir"/> |
|
168 <then> |
|
169 <record name="${build.log.dir}/@{name}" action="start" append="true" emacsmode="@{emacsmode}"/> |
|
170 </then> |
|
171 </if> |
|
172 </sequential> |
|
173 </macrodef> |
|
174 |
|
175 |
|
176 <!-- Macro to stop recording content to a separate log file without recording in the main log. --> |
|
177 <macrodef name="recordStopMacro" uri="http://www.nokia.com/helium"> |
|
178 <attribute name="name"/> |
|
179 <sequential> |
|
180 <if> |
|
181 <available file="${build.log.dir}/@{name}"/> |
|
182 <then> |
|
183 <record name="${build.log.dir}/@{name}" action="stop" append="true"/> |
|
184 </then> |
|
185 </if> |
|
186 <if> |
|
187 <available file="${build.log}"/> |
|
188 <then> |
|
189 <record name="${build.log}" action="start" append="true"/> |
|
190 </then> |
|
191 </if> |
|
192 </sequential> |
|
193 </macrodef> |
|
194 |
|
195 |
|
196 <!--Macro to stop recording to the main log file (if present) and record to |
|
197 a separate log file that is filtered after logging is stopped. --> |
|
198 <macrodef name="filterRecordStartMacro" uri="http://www.nokia.com/helium"> |
|
199 <sequential> |
|
200 <if> |
|
201 <available file="${build.log}"/> |
|
202 <then> |
|
203 <record name="${build.log}" action="stop" append="true"/> |
|
204 </then> |
|
205 </if> |
|
206 <echo>Start of filtering ${build.log} for passwords</echo> |
|
207 <record name="${build.cache.log.dir}/temp_ant_build.log" action="start" loglevel="info"/> |
|
208 </sequential> |
|
209 </macrodef> |
|
210 |
|
211 |
|
212 <!--Macro to stop recording the seperate filtered log file, filter the passwords |
|
213 and start recording in main log file --> |
|
214 <macrodef name="filterRecordStopMacro" uri="http://www.nokia.com/helium"> |
|
215 <attribute name="pattern"/> |
|
216 <attribute name="log" default="${build.log}"/> |
|
217 <attribute name="append" default="true"/> |
|
218 <sequential> |
|
219 <record name="${build.cache.log.dir}/temp_ant_build.log" action="stop"/> |
|
220 <concat destfile="@{log}" append="@{append}"> |
|
221 <filelist dir="${build.cache.log.dir}" files="temp_ant_build.log"/> |
|
222 <filterchain> |
|
223 <tokenfilter> |
|
224 <replaceregex pattern="@{pattern}" replace="****" flags="gi"/> |
|
225 </tokenfilter> |
|
226 </filterchain> |
|
227 </concat> |
|
228 <delete file="${build.cache.log.dir}/temp_ant_build.log" failonerror="false"/> |
|
229 <if> |
|
230 <available file="${build.log}"/> |
|
231 <then> |
|
232 <record name="${build.log}" action="start" append="true"/> |
|
233 </then> |
|
234 </if> |
|
235 <echo>End of filtering @{log} for passwords</echo> |
|
236 </sequential> |
|
237 </macrodef> |
|
238 |
|
239 |
221 |
240 <!-- A generic assert macro similar to AntUnit "assertTrue". --> |
222 <!-- A generic assert macro similar to AntUnit "assertTrue". --> |
241 <macrodef name="assert" uri="http://www.nokia.com/helium"> |
223 <macrodef name="assert" uri="http://www.nokia.com/helium"> |
242 <attribute name="message" default="Value is not true."/> |
224 <attribute name="message" default="Value is not true."/> |
243 <element name="condition" implicit="yes"/> |
225 <element name="condition" implicit="yes"/> |
402 netrc_info = netrc_file.authenticators(str(attributes.get("type"))) |
384 netrc_info = netrc_file.authenticators(str(attributes.get("type"))) |
403 if netrc_info == None: |
385 if netrc_info == None: |
404 raise Exception("No entry found for Type: %s" % str(attributes.get("type"))) |
386 raise Exception("No entry found for Type: %s" % str(attributes.get("type"))) |
405 (n_username, n_account, n_password) = netrc_info |
387 (n_username, n_account, n_password) = netrc_info |
406 if attributes.get('output-prop') != None: |
388 if attributes.get('output-prop') != None: |
407 self.log("Output: %s" % attributes.get('output-prop')) |
|
408 project.setProperty(str(attributes.get('output-prop')), str(n_password)) |
389 project.setProperty(str(attributes.get('output-prop')), str(n_password)) |
409 except Exception, e: |
390 except Exception, e: |
410 result = "-1" |
391 result = "-1" |
411 print "ERROR: %s" % e |
392 print "Warning: %s" % e |
412 if attributes.get('result-prop') != None: |
393 if attributes.get('result-prop') != None: |
413 self.log("Result: %s" % attributes.get('result-prop')) |
|
414 project.setProperty(str(attributes.get('result-prop')), str(result)) |
394 project.setProperty(str(attributes.get('result-prop')), str(result)) |
415 self.log("%s: %s" % (attributes.get('result-prop'), project.getProperty(str(attributes.get('result-prop'))))) |
|
416 ]]> |
395 ]]> |
417 </scriptdef> |
396 </scriptdef> |
418 |
397 |
419 <!-- Reads user name from .netrc file for a specific type of service. --> |
398 <!-- Reads user name from .netrc file for a specific type of service. --> |
420 <scriptdef name="netrcUsernameMacro" language="jython" uri="http://www.nokia.com/helium"> |
399 <scriptdef name="netrcUsernameMacro" language="jython" uri="http://www.nokia.com/helium"> |
431 netrc_info = netrc_file.authenticators(str(attributes.get("type"))) |
410 netrc_info = netrc_file.authenticators(str(attributes.get("type"))) |
432 if netrc_info == None: |
411 if netrc_info == None: |
433 raise Exception("No entry found for Type: %s" % str(attributes.get("type"))) |
412 raise Exception("No entry found for Type: %s" % str(attributes.get("type"))) |
434 (n_username, n_account, n_password) = netrc_info |
413 (n_username, n_account, n_password) = netrc_info |
435 if attributes.get('output-prop') != None: |
414 if attributes.get('output-prop') != None: |
436 self.log("Output: %s" % attributes.get('output-prop')) |
|
437 project.setProperty(str(attributes.get('output-prop')), str(n_username)) |
415 project.setProperty(str(attributes.get('output-prop')), str(n_username)) |
438 except Exception, e: |
416 except Exception, e: |
439 result = "-1" |
417 result = "-1" |
440 print "ERROR: %s" % e |
418 print "Warning: %s" % e |
441 if attributes.get('result-prop') != None: |
419 if attributes.get('result-prop') != None: |
442 |
|
443 self.log("Result: %s" % attributes.get('result-prop')) |
|
444 project.setProperty(str(attributes.get('result-prop')), str(result)) |
420 project.setProperty(str(attributes.get('result-prop')), str(result)) |
445 self.log("%s: %s" % (attributes.get('result-prop'), project.getProperty(str(attributes.get('result-prop'))))) |
|
446 ]]> |
421 ]]> |
447 </scriptdef> |
422 </scriptdef> |
448 |
423 |
449 <!-- Check availability of synergy. --> |
424 <!-- Check availability of synergy. --> |
450 <scriptdef name="ccmAvailableMacro" language="jython" uri="http://www.nokia.com/helium"> |
425 <scriptdef name="ccmAvailableMacro" language="jython" uri="http://www.nokia.com/helium"> |
492 self.log("Result: %s" % attributes.get('resultproperty')) |
468 self.log("Result: %s" % attributes.get('resultproperty')) |
493 project.setProperty(str(attributes.get('resultproperty')), str(result)) |
469 project.setProperty(str(attributes.get('resultproperty')), str(result)) |
494 ]]> |
470 ]]> |
495 </scriptdef> |
471 </scriptdef> |
496 |
472 |
497 <!-- Extract logs from text file and process error/warnings/components name etc |
|
498 into xml file.--> |
|
499 <scriptdef name="logextract" language="jython" uri="http://www.nokia.com/helium"> |
|
500 <attribute name="file" /> |
|
501 <attribute name="outputfile" /> |
|
502 <element name="fileset" type="fileset"/> |
|
503 <element name="logfilterset" classname="com.nokia.ant.types.LogFilterSet"/> |
|
504 <![CDATA[ |
|
505 import os.path |
|
506 import log2xml |
|
507 import java.io |
|
508 |
|
509 def convertFile(inputfile, outputfile, config): |
|
510 if (outputfile != None): |
|
511 print "output file not none" |
|
512 print "output file: %s" % outputfile |
|
513 targetfile = str(outputfile) |
|
514 else: |
|
515 #print "output file: %s" % outputfile |
|
516 targetfile = "%s.xml" % inputfile |
|
517 #print "targetFile %s" % targetfile |
|
518 if not os.path.exists(targetfile) or \ |
|
519 (os.path.exists(targetfile) and os.path.getmtime(inputfile) > os.path.getmtime(targetfile)): |
|
520 self.getProject().log("Converting %s..." % inputfile) |
|
521 log2xml.convert(inputfile, targetfile, False, config) |
|
522 else: |
|
523 self.getProject().log("Extracted log is uptodate: %s" % inputfile) |
|
524 |
|
525 config = log2xml.DEFAULT_CONFIGURATION |
|
526 logfilterset = elements.get("logfilterset") |
|
527 if logfilterset != None and logfilterset.size() > 0: |
|
528 # if any logfilterset are dfined then |
|
529 # it override the default configuration |
|
530 config = {} |
|
531 for filtersetid in range(logfilterset.size()): |
|
532 filterset = logfilterset.get(filtersetid) |
|
533 if filterset.isReference(): |
|
534 filterset = filterset.getRefid().getReferencedObject(project) |
|
535 filters = filterset.getFilters() |
|
536 for filterid in range(filters.size()): |
|
537 if not filters.get(filterid).getCategory() in config: |
|
538 config[filters.get(filterid).getCategory()] = [] |
|
539 config[filters.get(filterid).getCategory()].append(str(filters.get(filterid).getRegex())) |
|
540 |
|
541 fileset = elements.get("fileset") |
|
542 outputfile = attributes.get("outputfile") |
|
543 if fileset != None and fileset.size() > 0: |
|
544 for filesetid in range(fileset.size()): |
|
545 dirscanner = fileset.get(filesetid).getDirectoryScanner(project) |
|
546 for filename in dirscanner.getIncludedFiles(): |
|
547 inputfile = str(java.io.File(dirscanner.getBasedir(), str(filename)).getAbsolutePath()) |
|
548 convertFile(inputfile, outputfile, config) |
|
549 elif attributes.get("file") != None: |
|
550 inputfile = str(java.io.File(str(attributes.get("file"))).getAbsolutePath()) |
|
551 convertFile(inputfile, outputfile, config) |
|
552 else: |
|
553 self.log("No input specified.") |
|
554 ]]> |
|
555 </scriptdef> |
|
556 |
|
557 |
|
558 <!--Macro to stop recording to the main log file (if present) and record to |
|
559 a separate log file into a temporary location (doesn't need the build aread to work). --> |
|
560 <macrodef name="tempRecordStartMacro" uri="http://www.nokia.com/helium"> |
|
561 <attribute name="name"/> |
|
562 <sequential> |
|
563 <mkdir dir="${build.cache.log.dir}"/> |
|
564 <if> |
|
565 <available file="${build.log}"/> |
|
566 <then> |
|
567 <record name="${build.log}" action="stop" append="true"/> |
|
568 </then> |
|
569 </if> |
|
570 <record name="${build.cache.log.dir}/@{name}" action="start" loglevel="verbose"/> |
|
571 </sequential> |
|
572 </macrodef> |
|
573 |
|
574 |
|
575 <!--Macro to restart the main log file (if present) and stop recording to |
|
576 a separate log file into a temporary location the file is next xml summarized |
|
577 and potentially copied to the build area (if exists). Else those files will get copied during the |
|
578 build area preparation. --> |
|
579 <macrodef name="tempRecordStopMacro" uri="http://www.nokia.com/helium"> |
|
580 <attribute name="name"/> |
|
581 <attribute name="database" default="${metadata.dbfile}"/> |
|
582 <attribute name="filterref" default="filterset.temprecord"/> |
|
583 <sequential> |
|
584 <mkdir dir="${build.cache.log.dir}"/> |
|
585 <mkdir dir="${build.cache.log.dir}/signals"/> |
|
586 <record name="${build.cache.log.dir}/@{name}" action="stop" loglevel="verbose"/> |
|
587 <!--Temporary solution, the logextract in general |
|
588 needs to be handled in a better way (not all logs needs to be processed, |
|
589 logextract / counting errors could be merged and logextract should be |
|
590 executed on a need basis and not to process for all stopmacro.--> |
|
591 <!-- Todo: metadata: replace logextract --> |
|
592 <hlm:metadatarecord database="@{database}"> |
|
593 <hlm:antmetadatainput> |
|
594 <fileset casesensitive="false" file="${build.cache.log.dir}/@{name}" /> |
|
595 <metadatafilterset refid="@{filterref}" /> |
|
596 </hlm:antmetadatainput> |
|
597 </hlm:metadatarecord> |
|
598 <hlm:generateBuildStatus dbfile="@{database}" output-dir="${build.cache.log.dir}/signals" file="@{name}" /> |
|
599 <copy todir="${build.log.dir}" failonerror="false"> |
|
600 <fileset casesensitive="false" file="${build.cache.log.dir}/@{name}" /> |
|
601 </copy> |
|
602 <copy todir="${build.signal.status.dir}" failonerror="false"> |
|
603 <fileset casesensitive="false" dir="${build.cache.log.dir}/signals" /> |
|
604 </copy> |
|
605 <if> |
|
606 <available file="${build.log}"/> |
|
607 <then> |
|
608 <record name="${build.log}" action="start" append="true"/> |
|
609 </then> |
|
610 </if> |
|
611 </sequential> |
|
612 </macrodef> |
|
613 |
|
614 |
|
615 <macrodef name="signalMacro" uri="http://www.nokia.com/helium"> |
473 <macrodef name="signalMacro" uri="http://www.nokia.com/helium"> |
616 <attribute name="logfile"/> |
474 <attribute name="logfile"/> |
|
475 <attribute name="phase" default=""/> |
617 <attribute name="signal.input" /> |
476 <attribute name="signal.input" /> |
618 <attribute name="skip.count" default="false" /> |
477 <attribute name="skip.count" default="false" /> |
619 <attribute name="result" default="not-set"/> |
478 <attribute name="result" default="not-set"/> |
620 <sequential> |
479 <sequential> |
621 <var name="signal.errors.total" value="" unset="true"/> |
480 <var name="signal.errors.total" value="" unset="true"/> |
622 <var name="base.signal.log.file" value="" unset="true"/> |
481 <var name="base.signal.log.file" value="" unset="true"/> |
623 <basename property="base.signal.log.file" file="@{logfile}" suffix=".log"/> |
482 <basename property="base.signal.log.file" file="@{logfile}"/> |
624 <if> |
483 <if> |
625 <isfalse value="@{skip.count}" /> |
484 <isfalse value="@{skip.count}" /> |
626 <then> |
485 <then> |
627 <hlm:metadataCountSeverity severity="error" |
486 <hlm:metadataCountSeverity severity="error" |
628 log="@{logfile}" |
487 log="@{logfile}" |
636 </then> |
495 </then> |
637 </if> |
496 </if> |
638 <var name="signal.errors.total" value="@{result}" /> |
497 <var name="signal.errors.total" value="@{result}" /> |
639 </else> |
498 </else> |
640 </if> |
499 </if> |
|
500 <if> |
|
501 <isset property="@{phase}.log.dir" /> |
|
502 <then> |
|
503 <var name="signal.log.dir" value="" unset="true"/> |
|
504 <property name="signal.log.dir" value="${@{phase}.log.dir}"/> |
|
505 <echo>signal.log.dir = ${signal.log.dir}</echo> |
|
506 </then> |
|
507 <else> |
|
508 <var name="signal.log.dir" value="" unset="true"/> |
|
509 <property name="signal.log.dir" value="${build.log.dir}"/> |
|
510 </else> |
|
511 </if> |
641 <hlm:generateBuildStatus output-dir="${build.signal.status.dir}/" |
512 <hlm:generateBuildStatus output-dir="${build.signal.status.dir}/" |
642 file="${base.signal.log.file}" /> |
513 file="${base.signal.log.file}" /> |
643 <!-- signal for errors --> |
514 <!-- signal for errors --> |
644 <hlm:signal name="@{signal.input}" result="${signal.errors.total}" > |
515 <hlm:signal name="@{signal.input}" result="${signal.errors.total}" > |
645 <signalNotifierInput> |
516 <signalNotifierInput> |
646 <signalInput refid="@{signal.input}" /> |
517 <signalInput refid="@{signal.input}" /> |
647 <notifierInput file = "${build.signal.status.dir}/${base.signal.log.file}.status.html" /> |
518 <notifierInput> |
|
519 <fileset casesensitive="false" dir="${build.log.dir}" > |
|
520 <include name="**/${base.signal.log.file}*" /> |
|
521 </fileset> |
|
522 </notifierInput> |
648 </signalNotifierInput> |
523 </signalNotifierInput> |
649 </hlm:signal> |
524 </hlm:signal> |
650 </sequential> |
|
651 </macrodef> |
|
652 |
|
653 <!-- Macro to start logging to a separate log file. |
|
654 |
|
655 This will stop logging to the main ant_build log file until stopSpecificLogMacro |
|
656 is called. --> |
|
657 <macrodef name="startSpecificLogMacro"> |
|
658 <attribute name="name"/> |
|
659 <attribute name="regexp" default=""/> |
|
660 <attribute name="backup" default="false"/> |
|
661 |
|
662 <sequential> |
|
663 <if> |
|
664 <available file="${build.log}"/> |
|
665 <then> |
|
666 <echo>Stopping recording to main Ant build log.</echo> |
|
667 <record name="${build.log}" action="stop" append="true"/> |
|
668 </then> |
|
669 </if> |
|
670 <mkdir dir="@{name}/.."/> |
|
671 <hlm:logrecord name="@{name}" action="start" loglevel="verbose" regexp="@{regexp}" backup="@{backup}"/> |
|
672 </sequential> |
|
673 </macrodef> |
|
674 |
|
675 |
|
676 <!--Macro to restart the main log file (if present) and stop recording to |
|
677 a separate log file. --> |
|
678 <macrodef name="stopSpecificLogMacro"> |
|
679 <attribute name="name"/> |
|
680 <sequential> |
|
681 <hlm:logrecord name="@{name}" action="stop" loglevel="verbose"/> |
|
682 <if> |
|
683 <available file="${build.log}"/> |
|
684 <then> |
|
685 <record name="${build.log}" action="start" append="true"/> |
|
686 <echo>Starting recording to main Ant build log again.</echo> |
|
687 </then> |
|
688 </if> |
|
689 </sequential> |
|
690 </macrodef> |
|
691 |
|
692 <!-- Temp BMD macro --> |
|
693 <macrodef name="bmdLogExtractMacro" uri="http://www.nokia.com/helium"> |
|
694 <attribute name="log"/> |
|
695 <attribute name="metadatafilterset" default="common"/> |
|
696 <sequential> |
|
697 <hlm:metadatarecord database="${metadata.dbfile}"> |
|
698 <hlm:textmetadatainput> |
|
699 <fileset casesensitive="false" file="@{log}"/> |
|
700 <metadatafilterset refid="@{metadatafilterset}" /> |
|
701 </hlm:textmetadatainput> |
|
702 </hlm:metadatarecord> |
|
703 <!-- todo: check to add for usage and add genbuildstatus macro --> |
|
704 <basename property="log.name" file="@{log}"/> |
|
705 <fmpp sourceFile="${helium.dir}/tools/common/templates/db2xml.xml.ftl" |
|
706 outputfile="@{log}.xml"> |
|
707 <data expandProperties="yes"> |
|
708 dbPath: ${metadata.dbfile} |
|
709 log: ${log.name} |
|
710 ant: antProperties() |
|
711 </data> |
|
712 </fmpp> |
|
713 </sequential> |
525 </sequential> |
714 </macrodef> |
526 </macrodef> |
715 |
527 |
716 <!-- A simple test macro --> |
528 <!-- A simple test macro --> |
717 <macrodef name="fooMacro" uri="http://www.nokia.com/helium"> |
529 <macrodef name="fooMacro" uri="http://www.nokia.com/helium"> |