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