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