]> git.saurik.com Git - wxWidgets.git/blob - build/buildbot/config/include/defs.xml
revert 59680; implement proper fix for wxMSW test failure detection
[wxWidgets.git] / build / buildbot / config / include / defs.xml
1 <?xml version="1.0" encoding="utf-8"?>
2
3 <!--
4 Name: include/defs.xml
5 Purpose: Common declarations for buildbot
6 Author: Mike Wetherell
7 RCS-ID: $Id$
8 Copyright: (c) 2007 Mike Wetherell
9 Licence: wxWidgets licence
10 -->
11
12 <bot xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
13 xmlns:exsl="http://exslt.org/common"
14 xmlns:func="http://exslt.org/functions"
15 xmlns:get="local"
16 xsl:extension-element-prefixes="func"
17 xsl:version="1.0">
18
19 <!--
20 Constants
21 -->
22 <xsl:template name="SVN_URL">http://svn.wxwidgets.org/svn/wx/wxWidgets/</xsl:template>
23 <xsl:template name="STABLE_BRANCH">branches/WX_2_8_BRANCH</xsl:template>
24 <xsl:variable name="STABLE_BRANCH"><STABLE_BRANCH/></xsl:variable>
25 <xsl:template name="SNAPSHOT_URL">http://biolpc22.york.ac.uk/pub</xsl:template>
26
27 <!--
28 checkout - build step for source checkout.
29
30 Usage: as <svn> with defaults for <baseURL> and <defaultBranch>
31
32 Typically just:
33 <checkout/>
34 for the trunk, or:
35 <checkout branch="branches/WX_2_8_BRANCH"/>
36 to checkout a branch.
37 -->
38 <xsl:template name="checkout">
39 <xsl:param name="content"/>
40 <xsl:param name="branch" select="'trunk'"/>
41 <xsl:variable name="nodes" select="exsl:node-set($content)"/>
42 <svn>
43 <xsl:if test="not($nodes/svnurl)">
44 <xsl:if test="not($nodes/baseURL)">
45 <baseURL><SVN_URL/></baseURL>
46 </xsl:if>
47 <xsl:if test="not($nodes/defaultBranch)">
48 <defaultBranch><xsl:value-of select="$branch"/></defaultBranch>
49 </xsl:if>
50 </xsl:if>
51 <xsl:copy-of select="$content"/>
52 </svn>
53 </xsl:template>
54
55 <!--
56 configure - add the options attribute to <configure>
57
58 Usage: <configure options="-with-foobar"/>
59 -->
60 <xsl:template name="configure">
61 <xsl:param name="content"/>
62 <xsl:param name="options"/>
63 <configure>
64 <copy-with-defaults content="{$content}">
65 <command>./configure <xsl:value-of select="normalize-space($options)"/></command>
66 </copy-with-defaults>
67 </configure>
68 </xsl:template>
69
70 <!--
71 make - specify the make command.
72
73 Usage: <make>nmake -f makefile.vc SHARED=1</make>
74
75 Used as a child of <build> to specify the make command used by the
76 <compile> elements below, if omitted 'make' is used.
77 -->
78 <xsl:template name="make"/>
79
80 <!--
81 compile - modifiy <compile> to default to the command given by <make>
82
83 Usage: as <compile>
84
85 The <make> element of <build> spcecifies the make command used by all
86 compile build steps in the build. If <make> is not given 'make' is used.
87
88 The command for a particular compile build step can be further overridden
89 using its <command> element:
90 <compile>
91 <command>myscript</command>
92 </compile>
93 -->
94 <xsl:template name="compile">
95 <xsl:param name="content"/>
96 <compile>
97 <copy-with-defaults content="{$content}">
98 <command><get name="make" default="make"/></command>
99 </copy-with-defaults>
100 </compile>
101 </xsl:template>
102
103 <!--
104 Adds build steps to compile the library and the usual subdirectories.
105
106 Usage: as <compile> with the additional attributes below.
107
108 Usually the attributes default to suitable values, so typical usage
109 is just <compile-all/>.
110
111 <compile-all [ gui = 'true'|'false' ]
112 [ msw = 'true'|'false' ]
113 [ wx = 'true'|'false' ]
114 [ samples = 'true'|'false' ]
115 [ utils = 'true'|'false' ]
116 [ demos = 'true'|'false' ]
117 [ contrib = 'true'|'false' ]
118 [ tests = 'true'|'false' ] />
119
120 gui - if 'true' then build fully the subdirectories specified,
121 otherwise only the wxBase subset of the directories are built.
122 msw - if 'true' then build the directory 'build/msw' when building the
123 library instead of the root.
124 wx - build the library itself.
125 samples, utils, demos, contrib, tests
126 - build subdirectories.
127 -->
128 <xsl:template name="compile-all">
129 <xsl:param name="content"/>
130
131 <xsl:param name="gui"><is-gui/></xsl:param>
132 <xsl:param name="msw"><is-msw/></xsl:param>
133
134 <xsl:param name="wx" select="'true'"/>
135 <xsl:param name="samples" select="'true'"/>
136 <xsl:param name="utils" select="'true'"/>
137 <xsl:param name="demos" select="$gui"/>
138 <xsl:param name="contrib"><has-contrib/></xsl:param>
139 <xsl:param name="tests"><has-tests/></xsl:param>
140
141 <xsl:param name="wx-dirs">
142 <get-dirs wx="{$wx}" gui="{$gui}" msw="{$msw}"/>
143 </xsl:param>
144 <xsl:param name="sample-dirs">
145 <get-dirs samples="{$samples}" gui="{$gui}" msw="{$msw}"/>
146 </xsl:param>
147 <xsl:param name="util-dirs">
148 <get-dirs utils="{$utils}" gui="{$gui}" msw="{$msw}"/>
149 </xsl:param>
150 <xsl:param name="demo-dirs">
151 <get-dirs demos="{$demos}" gui="{$gui}" msw="{$msw}"/>
152 </xsl:param>
153 <xsl:param name="contrib-dirs">
154 <get-dirs contrib="{$contrib}" gui="{$gui}" msw="{$msw}"/>
155 </xsl:param>
156 <xsl:param name="test-dirs">
157 <get-dirs tests="{$tests}" gui="{$gui}" msw="{$msw}"/>
158 </xsl:param>
159
160 <compile-subdirs dirs="{$wx-dirs}" halt="true">
161 <xsl:copy-of select="$content"/>
162 </compile-subdirs>
163 <compile-subdirs name="samples" dirs="{$sample-dirs}">
164 <xsl:copy-of select="$content"/>
165 </compile-subdirs>
166 <compile-subdirs name="utils" dirs="{$util-dirs}">
167 <xsl:copy-of select="$content"/>
168 </compile-subdirs>
169 <compile-subdirs name="demos" dirs="{$demo-dirs}">
170 <xsl:copy-of select="$content"/>
171 </compile-subdirs>
172 <compile-subdirs name="contrib" dirs="{$contrib-dirs}">
173 <xsl:copy-of select="$content"/>
174 </compile-subdirs>
175 <compile-subdirs name="tests" dirs="{$test-dirs}" halt="true">
176 <xsl:copy-of select="$content"/>
177 </compile-subdirs>
178 </xsl:template>
179
180 <!--
181 Helper for compile-all.
182 Returns the directories that need to be built for the various components:
183 wx (the library itself), samples, utils, demos, contrib and tests.
184 -->
185 <xsl:template name="get-dirs">
186 <xsl:param name="contents"/>
187
188 <xsl:param name="gui"/>
189 <xsl:param name="msw"/>
190
191 <xsl:param name="wx"/>
192 <xsl:param name="samples"/>
193 <xsl:param name="utils"/>
194 <xsl:param name="demos"/>
195 <xsl:param name="contrib"/>
196 <xsl:param name="tests"/>
197
198 <xsl:if test="$wx = 'true'">
199 <xsl:choose>
200 <xsl:when test="$msw = 'true'">build/msw</xsl:when>
201 <xsl:otherwise>.</xsl:otherwise>
202 </xsl:choose>
203 <xsl:text> </xsl:text>
204 </xsl:if>
205
206 <xsl:if test="$samples = 'true'">
207 <xsl:choose>
208 <xsl:when test="$gui = 'true'">samples</xsl:when>
209 <xsl:otherwise>samples/console</xsl:otherwise>
210 </xsl:choose>
211 <xsl:text> </xsl:text>
212 </xsl:if>
213
214 <xsl:if test="$utils = 'true'">
215 <xsl:choose>
216 <xsl:when test="$gui = 'true'">utils</xsl:when>
217 <xsl:otherwise>utils/tex2rtf/src ../../HelpGen/src</xsl:otherwise>
218 </xsl:choose>
219 <xsl:text> </xsl:text>
220 </xsl:if>
221
222 <xsl:if test="$demos = 'true' and $gui = 'true'">demos </xsl:if>
223
224 <xsl:if test="$contrib = 'true' and $gui = 'true'">contrib </xsl:if>
225
226 <xsl:if test="$tests = 'true'">tests</xsl:if>
227 </xsl:template>
228
229 <!--
230 compile-subdir - build step to compile a subdirectory.
231
232 Usage: as <compile> plus the following attributes,
233 <compile-subdir dir="foobar" [ halt="true" ]/>
234
235 Compiles the named subdirectory 'foobar'. Continues with the next build
236 step on failure, unless the optional attibute 'halt="true"' is given.
237 The make command used is as described for the compile step above.
238 -->
239 <xsl:template name="compile-subdir">
240 <xsl:param name="content"/>
241 <xsl:param name="dir"/>
242 <xsl:param name="halt" select="'false'"/>
243 <compile-subdirs name="{$dir}" dirs="{$dir}" halt="{$halt}">
244 <xsl:copy-of select="$content"/>
245 </compile-subdirs>
246 </xsl:template>
247
248 <!--
249 compile-subdirs - adds a compile build step for each directory in a list.
250
251 Usage: as <compile> plus the following attributes,
252 <compile-subdir dirs="foobar1 foobar2"
253 [ name="foobars" ]
254 [ sep=" " ]
255 [ halt="true" ]/>
256
257 Compiles the named subdirectories. Continues with the next build
258 step on failure, unless the optional attibute 'halt="true"' is given.
259 The make command used is as described for the compile step above.
260 The 'name' attribute can be used to give a collective name for the
261 subdirectories, and the 'sep' attibute can be used to specify the
262 separator in the 'dirs' list (defaults to space).
263 -->
264 <xsl:template name="compile-subdirs">
265 <xsl:param name="content"/>
266 <xsl:param name="name"/>
267 <xsl:param name="dirs"/>
268 <xsl:param name="sep" select="' '"/>
269 <xsl:param name="halt" select="'false'"/>
270 <xsl:if test="translate($dirs, $sep, '')">
271 <compile>
272 <defaults content="{$content}">
273 <name>
274 <xsl:value-of select="normalize-space(concat('compile ', $name))"/>
275 </name>
276 <description>
277 <xsl:value-of select="normalize-space(concat('compiling ', $name))"/>
278 </description>
279 <descriptionDone>
280 <xsl:value-of select="normalize-space(concat('compile ', $name))"/>
281 </descriptionDone>
282 <haltOnFailure>
283 <xsl:value-of select="$halt"/>
284 </haltOnFailure>
285 <warnOnFailure/>
286 </defaults>
287 <copy-with-defaults content="{$content}">
288 <command>
289 <compile-subdirs-cmd dirs="{$dirs}" sep="{$sep}"/>
290 </command>
291 </copy-with-defaults>
292 </compile>
293 </xsl:if>
294 </xsl:template>
295
296 <xsl:template name="compile-subdirs-cmd">
297 <xsl:param name="content"/>
298 <xsl:param name="dirs"/>
299 <xsl:param name="sep"/>
300 <xsl:choose>
301 <xsl:when test="contains($dirs, $sep)">
302 <xsl:variable name="before" select="substring-before($dirs, $sep)"/>
303 <xsl:variable name="after" select="substring-after($dirs, $sep)"/>
304
305 <xsl:call-template name="compile-subdirs-cmd">
306 <xsl:with-param name="dirs" select="$before"/>
307 <xsl:with-param name="sep" select="$sep"/>
308 </xsl:call-template>
309
310 <xsl:if test="$after and substring($after, 1, 1) != ' '">
311 <xsl:text> &amp;&amp; </xsl:text>
312 </xsl:if>
313
314 <xsl:call-template name="compile-subdirs-cmd">
315 <xsl:with-param name="dirs" select="$after"/>
316 <xsl:with-param name="sep" select="$sep"/>
317 </xsl:call-template>
318 </xsl:when>
319 <xsl:when test="string($dirs)">
320 <xsl:if test="$dirs != '.'">cd <xsl:value-of select="$dirs"/> &amp;&amp; </xsl:if>
321 <get name="make" default="make"/>
322 </xsl:when>
323 </xsl:choose>
324 </xsl:template>
325
326 <!--
327 run-tests - build step to run the test suites.
328
329 Usage: as <test>
330
331 Typically just:
332 <run-tests/>
333 -->
334 <xsl:template name="run-tests">
335 <xsl:param name="content"/>
336 <xsl:param name="options"/>
337 <xsl:param name="msw"><is-msw/></xsl:param>
338 <test>
339 <defaults content="{$content}">
340 <description>running tests</description>
341 <descriptionDone>run tests</descriptionDone>
342 <warnOnFailure/>
343 </defaults>
344 <copy-with-defaults content="{$content}">
345 <command>
346 <xsl:choose>
347 <xsl:when test="$msw = 'true'">
348 <run-tests-win options="{$options}"/>
349 </xsl:when>
350 <xsl:otherwise>
351 <run-tests-unix options="{$options}"/>
352 </xsl:otherwise>
353 </xsl:choose>
354 </command>
355 </copy-with-defaults>
356 </test>
357 </xsl:template>
358
359 <xsl:template name="run-tests-win">
360 <xsl:param name="options"/>
361 <normalize-space>
362 cd tests &amp;&amp; runtests.bat
363 </normalize-space>
364 </xsl:template>
365
366 <xsl:template name="run-tests-unix">
367 <xsl:param name="options"/>
368 <normalize-space>
369 cd tests &amp;&amp;
370 ./test <xsl:value-of select="normalize-space($options)"/> &amp;&amp;
371 if [ -n "$DISPLAY" -a -x test_gui ]; then ./test_gui; fi
372 </normalize-space>
373 </xsl:template>
374
375 <!--
376 defaults - supply default content for an element.
377
378 Usage: <defaults content="{$content}">
379 <foo>foo</foo>
380 <bar>bar</bar>
381 </defaults>
382
383 Copies those child elements that do not already exist in $content.
384 -->
385 <xsl:template name="defaults">
386 <xsl:param name="defaults"/>
387 <xsl:param name="content"/>
388
389 <xsl:variable name="def-nodes" select="exsl:node-set($defaults)"/>
390 <xsl:variable name="cont-nodes" select="exsl:node-set($content)"/>
391
392 <xsl:for-each select="$def-nodes/*">
393 <xsl:if test="not($cont-nodes/*[name() = name(current())])">
394 <xsl:copy-of select="."/>
395 </xsl:if>
396 </xsl:for-each>
397 </xsl:template>
398
399 <!--
400 copy-with-defaults - copy elements supplying defaults for any that are
401 missing or empty.
402
403 Usage: <copy-with-defaults content="{$content}">
404 <foo>foo</foo>
405 <bar>bar</bar>
406 </copy-with-defaults>
407
408 Copies $content plus any child elements that do not exist in $content,
409 substituting empty elements in $content with any child elements of the
410 same name.
411 -->
412 <xsl:template name="copy-with-defaults">
413 <xsl:param name="defaults"/>
414 <xsl:param name="content"/>
415
416 <xsl:variable name="def-nodes" select="exsl:node-set($defaults)"/>
417 <xsl:variable name="cont-nodes" select="exsl:node-set($content)"/>
418
419 <xsl:for-each select="$def-nodes/*">
420 <xsl:if test="not($cont-nodes/*[name() = name(current())])">
421 <xsl:copy-of select="."/>
422 </xsl:if>
423 </xsl:for-each>
424
425 <xsl:for-each select="$cont-nodes/*">
426 <xsl:choose>
427 <xsl:when test="not(node())">
428 <xsl:copy-of select="$def-nodes/*[name() = name(current())]"/>
429 </xsl:when>
430 <xsl:otherwise>
431 <xsl:copy-of select="."/>
432 </xsl:otherwise>
433 </xsl:choose>
434 </xsl:for-each>
435 </xsl:template>
436
437 <!--
438 get - gets the text from a child element of the current build.
439
440 Usage: <get name="foobar" [ default="value" ]/>
441
442 Gets the text from the <foobar> element of the current build, or returns
443 $default if there is not such element.
444 -->
445 <xsl:template name="get">
446 <xsl:param name="content"/>
447 <xsl:param name="build" select="get:build()"/>
448 <xsl:param name="name"/>
449 <xsl:param name="default"/>
450 <xsl:variable name="property" select="get:property($name, $build)"/>
451 <strip>
452 <xsl:choose>
453 <xsl:when test="$property">
454 <xsl:apply-templates select="$property/node()"/>
455 </xsl:when>
456 <xsl:otherwise>
457 <xsl:value-of select="$default"/>
458 </xsl:otherwise>
459 </xsl:choose>
460 </strip>
461 </xsl:template>
462
463 <!--
464 Accessors to get builds and their fields. XSLT code should use these
465 instead of traversing the input tree directly.
466 -->
467 <func:function name="get:build">
468 <func:result select="ancestor-or-self::build[last()]"/>
469 </func:function>
470
471 <func:function name="get:all-builds">
472 <func:result select="//build[not(ancestor::*[name() != name(/*)])]"/>
473 </func:function>
474
475 <func:function name="get:preceding-builds">
476 <func:result select="get:build()/preceding-sibling::build"/>
477 </func:function>
478
479 <func:function name="get:property">
480 <xsl:param name="name"/>
481 <xsl:param name="build" select="get:build()"/>
482 <func:result select="$build/*[name() = $name]"/>
483 </func:function>
484
485 <func:function name="get:step">
486 <xsl:param name="name"/>
487 <xsl:param name="build" select="get:build()"/>
488 <func:result select="get:property('steps', $build)/*[name() = $name]"/>
489 </func:function>
490
491 <!--
492 Returns true if this is an msw build.
493 -->
494 <xsl:template name="is-msw">
495 <xsl:param name="content"/>
496 <xsl:param name="build" select="get:build()"/>
497 <xsl:value-of select="not(get:step('configure', $build))"/>
498 </xsl:template>
499
500 <!--
501 Returns true if this a gui build.
502 -->
503 <xsl:template name="is-gui">
504 <xsl:param name="content"/>
505 <xsl:param name="build" select="get:build()"/>
506 <xsl:variable name="make"><get name="make" build="{$build}"/></xsl:variable>
507 <xsl:variable name="configure"><xsl:apply-templates select="get:step('configure', $build)"/></xsl:variable>
508 <xsl:value-of select="not(contains($make, 'USE_GUI=0') or contains($configure, '--disable-gui'))"/>
509 </xsl:template>
510
511 <!--
512 Returns true if the branch we're building has a contrib subdirectory.
513 -->
514 <xsl:template name="has-contrib">
515 <xsl:param name="content"/>
516 <xsl:param name="build" select="get:build()"/>
517 <xsl:variable name="checkout"><xsl:apply-templates select="get:step('checkout', $build)"/></xsl:variable>
518 <xsl:value-of select="contains($checkout, 'WX_2_') and not(contains($checkout, 'WX_2_9_'))"/>
519 </xsl:template>
520
521 <!--
522 Returns true if the build should build the test suite.
523 -->
524 <xsl:template name="has-tests">
525 <xsl:param name="content"/>
526 <xsl:param name="build" select="get:build()"/>
527 <xsl:variable name="configure"><xsl:apply-templates select="get:step('configure', $build)"/></xsl:variable>
528 <xsl:value-of select="get:step('run-tests', $build) or contains($configure, '--host=')"/>
529 </xsl:template>
530
531 <!--
532 strip - strips leading and trailing whitespace
533
534 Usage: <strip>
535 foobar
536 </strip>
537
538 Converts to text and strips leading and trailing whitespace.
539 -->
540 <xsl:template name="strip">
541 <xsl:param name="content"/>
542 <xsl:variable name="len" select="string-length($content)"/>
543 <xsl:variable name="norm" select="normalize-space($content)"/>
544 <xsl:variable name="normlen" select="string-length($norm)"/>
545 <xsl:choose>
546 <xsl:when test="substring($content, 1, 1) != substring($norm, 1, 1)">
547 <xsl:call-template name="strip">
548 <xsl:with-param name="content" select="substring($content, 2)"/>
549 </xsl:call-template>
550 </xsl:when>
551 <xsl:when test="substring($content, $len, 1) != substring($norm, $normlen, 1)">
552 <xsl:call-template name="strip">
553 <xsl:with-param name="content" select="substring($content, 1, $len - 1)"/>
554 </xsl:call-template>
555 </xsl:when>
556 <xsl:otherwise>
557 <xsl:value-of select="$content"/>
558 </xsl:otherwise>
559 </xsl:choose>
560 </xsl:template>
561
562 <!--
563 normalize-space - normalises whitespace.
564
565 Usage: <normalize-space>
566 foobar
567 </normalize-space>
568
569 Converts to text, strips leading and trailing whitespace and replaces
570 sequences of whitespace characters by a single space.
571 -->
572 <xsl:template name="normalize-space">
573 <xsl:param name="content"/>
574 <xsl:value-of select="normalize-space($content)"/>
575 </xsl:template>
576
577 <!--
578 lower-case - converts to lower case.
579
580 Usage: <lower-case>FooBar</lower-case>
581 -->
582 <xsl:template name="lower-case">
583 <xsl:param name="content"/>
584 <xsl:variable name="lower">abcdefghijklmnopqrstuvwxyz</xsl:variable>
585 <xsl:variable name="upper">ABCDEFGHIJKLMNOPQRSTUVWXYZ</xsl:variable>
586 <xsl:value-of select="translate($content, $upper, $lower)"/>
587 </xsl:template>
588
589 <!--
590 Helpers to convert between day numbers and names.
591 -->
592 <xsl:template name="day-number">
593 <xsl:param name="content"/>
594 <xsl:param name="name"/>
595 <xsl:choose>
596 <xsl:when test="$name = 'monday'">0</xsl:when>
597 <xsl:when test="$name = 'tuesday'">1</xsl:when>
598 <xsl:when test="$name = 'wednesday'">2</xsl:when>
599 <xsl:when test="$name = 'thursday'">3</xsl:when>
600 <xsl:when test="$name = 'friday'">4</xsl:when>
601 <xsl:when test="$name = 'saturday'">5</xsl:when>
602 <xsl:when test="$name = 'sunday'">6</xsl:when>
603 </xsl:choose>
604 </xsl:template>
605
606 <xsl:template name="day-name">
607 <xsl:param name="content"/>
608 <xsl:param name="number"/>
609 <xsl:choose>
610 <xsl:when test="$number = '0'">monday</xsl:when>
611 <xsl:when test="$number = '1'">tuesday</xsl:when>
612 <xsl:when test="$number = '2'">wednesday</xsl:when>
613 <xsl:when test="$number = '3'">thursday</xsl:when>
614 <xsl:when test="$number = '4'">friday</xsl:when>
615 <xsl:when test="$number = '5'">saturday</xsl:when>
616 <xsl:when test="$number = '6'">sunday</xsl:when>
617 </xsl:choose>
618 </xsl:template>
619
620 <!--
621 Helpers to convert between time in the format 'hhmm' and an integer
622 count of the minutes since midnight.
623 -->
624 <xsl:template name="time-minutes">
625 <xsl:param name="content"/>
626 <xsl:param name="hhmm"/>
627 <xsl:if test="string-length($hhmm) = 4 and format-number($hhmm, '0000') = $hhmm">
628 <xsl:variable name="hour" select="substring($hhmm, 1, 2)"/>
629 <xsl:variable name="min" select="substring($hhmm, 3, 2)"/>
630 <xsl:if test="$hour >= 0 and $hour &lt; 24 and $min >= 0 and $min &lt; 60">
631 <xsl:value-of select="$hour * 60 + $min"/>
632 </xsl:if>
633 </xsl:if>
634 </xsl:template>
635
636 <xsl:template name="time-hhmm">
637 <xsl:param name="content"/>
638 <xsl:param name="minutes"/>
639 <xsl:value-of select="format-number(floor($minutes div 60) * 100 + $minutes mod 60, '0000')"/>
640 </xsl:template>
641
642 <!--
643 Create schedulers.
644 -->
645 <xsl:template name="nightly-schedulers">
646 <xsl:param name="content"/>
647 <xsl:param name="name"/>
648 <xsl:param name="day"><day-number name="{$name}"/></xsl:param>
649 <xsl:param name="hour" select="0"/>
650 <xsl:param name="minute" select="0"/>
651 <xsl:param name="step" select="30"/>
652
653 <xsl:if test="$hour &lt; 24">
654 <nightly>
655 <name>
656 <xsl:value-of select="concat($name, '_', format-number($hour, '00'), format-number($minute, '00'))"/>
657 </name>
658 <hour>
659 <xsl:value-of select="$hour"/>
660 </hour>
661 <minute>
662 <xsl:value-of select="$minute"/>
663 </minute>
664 <xsl:if test="$day != ''">
665 <dayOfWeek>
666 <xsl:value-of select="$day"/>
667 </dayOfWeek>
668 </xsl:if>
669 </nightly>
670 <xsl:variable name="next" select="$hour * 60 + $minute + $step"/>
671 <xsl:call-template name="nightly-schedulers">
672 <xsl:with-param name="name" select="$name"/>
673 <xsl:with-param name="day" select="$day"/>
674 <xsl:with-param name="hour" select="floor($next div 60)"/>
675 <xsl:with-param name="minute" select="$next mod 60"/>
676 <xsl:with-param name="step" select="$step"/>
677 </xsl:call-template>
678 </xsl:if>
679 </xsl:template>
680
681 <!--
682 scheduler - provide default for the <scheduler> build element.
683 -->
684 <xsl:template name="scheduler">
685 <xsl:param name="content"/>
686 <xsl:param name="previous" select="get:property('scheduler', get:preceding-builds()[last()])"/>
687 <xsl:param name="step" select="60"/>
688
689 <xsl:choose>
690 <xsl:when test="exsl:node-set($content)/node()">
691 <scheduler>
692 <xsl:copy-of select="$content"/>
693 </scheduler>
694 </xsl:when>
695 <xsl:otherwise>
696 <xsl:for-each select="$previous">
697 <xsl:variable name="text">
698 <xsl:apply-templates select="."/>
699 </xsl:variable>
700 <scheduler>
701 <scheduler-subst text="{$text}" step="{$step}"/>
702 </scheduler>
703 </xsl:for-each>
704 </xsl:otherwise>
705 </xsl:choose>
706 </xsl:template>
707
708 <xsl:template name="scheduler-subst">
709 <xsl:param name="content"/>
710 <xsl:param name="text"/>
711 <xsl:param name="step"/>
712
713 <xsl:variable name="name" select="substring-before($text, '_')"/>
714 <xsl:variable name="hhmm" select="substring-after($text, '_')"/>
715 <xsl:variable name="day"><day-number name="{$name}"/></xsl:variable>
716 <xsl:variable name="mins"><time-minutes hhmm="{$hhmm}"/></xsl:variable>
717
718 <xsl:choose>
719 <xsl:when test="$mins = ''">
720 <xsl:value-of select="$text"/>
721 </xsl:when>
722 <xsl:when test="$day = ''">
723 <xsl:value-of select="$name"/>
724 <xsl:text>_</xsl:text>
725 <time-hhmm minutes="{$mins + $step}"/>
726 </xsl:when>
727 <xsl:otherwise>
728 <xsl:variable name="day-mins" select="24 * 60"/>
729 <xsl:variable name="week-mins" select="7 * $day-mins"/>
730 <xsl:variable name="tmp" select="($day + 1) * $day-mins + $mins"/>
731 <xsl:variable name="next" select="$tmp mod $week-mins + floor($tmp div $week-mins) * $step"/>
732 <day-name number="{floor($next div $day-mins)}"/>
733 <xsl:text>_</xsl:text>
734 <time-hhmm minutes="{$next mod $day-mins}"/>
735 </xsl:otherwise>
736 </xsl:choose>
737 </xsl:template>
738
739 <!--
740 email - substitute '@' for ' -at- ' in email addresses.
741 -->
742 <xsl:template name="emailfield">
743 <xsl:param name="content"/>
744 <xsl:param name="addr"/>
745 <xsl:variable name="at"> -at- </xsl:variable>
746 <xsl:choose>
747 <xsl:when test="contains($addr, $at)">
748 <xsl:value-of select="substring-before($addr, $at)"/>
749 <xsl:text>@</xsl:text>
750 <xsl:value-of select="substring-after($addr, $at)"/>
751 </xsl:when>
752 <xsl:otherwise>
753 <xsl:value-of select="$addr"/>
754 </xsl:otherwise>
755 </xsl:choose>
756 </xsl:template>
757
758 <xsl:template name="email">
759 <xsl:param name="content"/>
760 <xsl:param name="id"/>
761 <email id="{$id}"><emailfield addr="{$content}"/></email>
762 </xsl:template>
763
764 <xsl:template name="fromaddr">
765 <xsl:param name="content"/>
766 <fromaddr><emailfield addr="{$content}"/></fromaddr>
767 </xsl:template>
768
769 <xsl:template name="extraRecipient">
770 <xsl:param name="content"/>
771 <extraRecipient><emailfield addr="{$content}"/></extraRecipient>
772 </xsl:template>
773
774 <!--
775 mailnotifier - add a default value for <fromaddr> to <mailnotifier>
776 -->
777 <xsl:template name="mailnotifier">
778 <xsl:param name="content"/>
779 <mailnotifier>
780 <defaults content="{$content}">
781 <fromaddr>noreply -at- wxsite.net</fromaddr>
782 </defaults>
783 <xsl:copy-of select="$content"/>
784 </mailnotifier>
785 </xsl:template>
786
787 </bot>