]> git.saurik.com Git - wxWidgets.git/blob - build/buildbot/config/include/defs.xml
define a separate run-tests-with-timing tag
[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="msw"><is-msw/></xsl:param>
337 <test>
338 <defaults content="{$content}">
339 <description>running tests</description>
340 <descriptionDone>run tests</descriptionDone>
341 <warnOnFailure/>
342 </defaults>
343 <copy-with-defaults content="{$content}">
344 <command>
345 <xsl:choose>
346 <xsl:when test="$msw = 'true'">
347 <run-tests-win/>
348 </xsl:when>
349 <xsl:otherwise>
350 <run-tests-unix/>
351 </xsl:otherwise>
352 </xsl:choose>
353 </command>
354 </copy-with-defaults>
355 </test>
356 </xsl:template>
357
358 <!--
359 run-tests-with-timing - build step to run the test suites with extra timing
360 option.
361
362 Usage: as <test>
363
364 Typically just:
365 <run-tests-with-timing/>
366 -->
367 <xsl:template name="run-tests-with-timing">
368 <xsl:param name="content"/>
369 <xsl:param name="msw"><is-msw/></xsl:param>
370 <test>
371 <defaults content="{$content}">
372 <description>running tests with timing</description>
373 <descriptionDone>run tests with timing</descriptionDone>
374 <warnOnFailure/>
375 </defaults>
376 <copy-with-defaults content="{$content}">
377 <command>
378 <xsl:choose>
379 <xsl:when test="$msw = 'true'">
380 <run-tests-with-timing-win/>
381 </xsl:when>
382 <xsl:otherwise>
383 <run-tests-with-timing-unix/>
384 </xsl:otherwise>
385 </xsl:choose>
386 </command>
387 </copy-with-defaults>
388 </test>
389 </xsl:template>
390
391 <!--
392 We need to add something to the wxWidgets sources to run the tests with a
393 simple command so that these aren't necessary.
394 -->
395 <xsl:template name="run-tests-win">
396 <normalize-space>
397 cd tests &amp;&amp;
398 (for /d %x in (..\lib\*_dll) do @PATH=%x;%PATH%) &amp;&amp;
399 (for /d %x in (*) do @if exist %x\test.exe %x\test) &amp;&amp;
400 (for /d %x in (*) do @if exist %x\test_gui.exe %x\test_gui)
401 </normalize-space>
402 </xsl:template>
403
404 <xsl:template name="run-tests-unix">
405 <normalize-space>
406 cd tests &amp;&amp;
407 ./test &amp;&amp;
408 if [ -n "$DISPLAY" -a -x test_gui ]; then ./test_gui; fi
409 </normalize-space>
410 </xsl:template>
411
412 <xsl:template name="run-tests-with-timing-win">
413 <normalize-space>
414 cd tests &amp;&amp;
415 (for /d %x in (..\lib\*_dll) do @PATH=%x;%PATH%) &amp;&amp;
416 (for /d %x in (*) do @if exist %x\test.exe %x\test -t) &amp;&amp;
417 (for /d %x in (*) do @if exist %x\test_gui.exe %x\test_gui -t)
418 </normalize-space>
419 </xsl:template>
420
421 <xsl:template name="run-tests-with-timing-unix">
422 <normalize-space>
423 cd tests &amp;&amp;
424 ./test -t &amp;&amp;
425 if [ -n "$DISPLAY" -a -x test_gui ]; then ./test_gui; fi
426 </normalize-space>
427 </xsl:template>
428
429 <!--
430 defaults - supply default content for an element.
431
432 Usage: <defaults content="{$content}">
433 <foo>foo</foo>
434 <bar>bar</bar>
435 </defaults>
436
437 Copies those child elements that do not already exist in $content.
438 -->
439 <xsl:template name="defaults">
440 <xsl:param name="defaults"/>
441 <xsl:param name="content"/>
442
443 <xsl:variable name="def-nodes" select="exsl:node-set($defaults)"/>
444 <xsl:variable name="cont-nodes" select="exsl:node-set($content)"/>
445
446 <xsl:for-each select="$def-nodes/*">
447 <xsl:if test="not($cont-nodes/*[name() = name(current())])">
448 <xsl:copy-of select="."/>
449 </xsl:if>
450 </xsl:for-each>
451 </xsl:template>
452
453 <!--
454 copy-with-defaults - copy elements supplying defaults for any that are
455 missing or empty.
456
457 Usage: <copy-with-defaults content="{$content}">
458 <foo>foo</foo>
459 <bar>bar</bar>
460 </copy-with-defaults>
461
462 Copies $content plus any child elements that do not exist in $content,
463 substituting empty elements in $content with any child elements of the
464 same name.
465 -->
466 <xsl:template name="copy-with-defaults">
467 <xsl:param name="defaults"/>
468 <xsl:param name="content"/>
469
470 <xsl:variable name="def-nodes" select="exsl:node-set($defaults)"/>
471 <xsl:variable name="cont-nodes" select="exsl:node-set($content)"/>
472
473 <xsl:for-each select="$def-nodes/*">
474 <xsl:if test="not($cont-nodes/*[name() = name(current())])">
475 <xsl:copy-of select="."/>
476 </xsl:if>
477 </xsl:for-each>
478
479 <xsl:for-each select="$cont-nodes/*">
480 <xsl:choose>
481 <xsl:when test="not(node())">
482 <xsl:copy-of select="$def-nodes/*[name() = name(current())]"/>
483 </xsl:when>
484 <xsl:otherwise>
485 <xsl:copy-of select="."/>
486 </xsl:otherwise>
487 </xsl:choose>
488 </xsl:for-each>
489 </xsl:template>
490
491 <!--
492 get - gets the text from a child element of the current build.
493
494 Usage: <get name="foobar" [ default="value" ]/>
495
496 Gets the text from the <foobar> element of the current build, or returns
497 $default if there is not such element.
498 -->
499 <xsl:template name="get">
500 <xsl:param name="content"/>
501 <xsl:param name="build" select="get:build()"/>
502 <xsl:param name="name"/>
503 <xsl:param name="default"/>
504 <xsl:variable name="property" select="get:property($name, $build)"/>
505 <strip>
506 <xsl:choose>
507 <xsl:when test="$property">
508 <xsl:apply-templates select="$property/node()"/>
509 </xsl:when>
510 <xsl:otherwise>
511 <xsl:value-of select="$default"/>
512 </xsl:otherwise>
513 </xsl:choose>
514 </strip>
515 </xsl:template>
516
517 <!--
518 Accessors to get builds and their fields. XSLT code should use these
519 instead of traversing the input tree directly.
520 -->
521 <func:function name="get:build">
522 <func:result select="ancestor-or-self::build[last()]"/>
523 </func:function>
524
525 <func:function name="get:all-builds">
526 <func:result select="//build[not(ancestor::*[name() != name(/*)])]"/>
527 </func:function>
528
529 <func:function name="get:preceding-builds">
530 <func:result select="get:build()/preceding-sibling::build"/>
531 </func:function>
532
533 <func:function name="get:property">
534 <xsl:param name="name"/>
535 <xsl:param name="build" select="get:build()"/>
536 <func:result select="$build/*[name() = $name]"/>
537 </func:function>
538
539 <func:function name="get:step">
540 <xsl:param name="name"/>
541 <xsl:param name="build" select="get:build()"/>
542 <func:result select="get:property('steps', $build)/*[name() = $name]"/>
543 </func:function>
544
545 <!--
546 Returns true if this is an msw build.
547 -->
548 <xsl:template name="is-msw">
549 <xsl:param name="content"/>
550 <xsl:param name="build" select="get:build()"/>
551 <xsl:value-of select="not(get:step('configure', $build))"/>
552 </xsl:template>
553
554 <!--
555 Returns true if this a gui build.
556 -->
557 <xsl:template name="is-gui">
558 <xsl:param name="content"/>
559 <xsl:param name="build" select="get:build()"/>
560 <xsl:variable name="make"><get name="make" build="{$build}"/></xsl:variable>
561 <xsl:variable name="configure"><xsl:apply-templates select="get:step('configure', $build)"/></xsl:variable>
562 <xsl:value-of select="not(contains($make, 'USE_GUI=0') or contains($configure, '--disable-gui'))"/>
563 </xsl:template>
564
565 <!--
566 Returns true if the branch we're building has a contrib subdirectory.
567 -->
568 <xsl:template name="has-contrib">
569 <xsl:param name="content"/>
570 <xsl:param name="build" select="get:build()"/>
571 <xsl:variable name="checkout"><xsl:apply-templates select="get:step('checkout', $build)"/></xsl:variable>
572 <xsl:value-of select="contains($checkout, 'WX_2_') and not(contains($checkout, 'WX_2_9_'))"/>
573 </xsl:template>
574
575 <!--
576 Returns true if the build should build the test suite.
577 -->
578 <xsl:template name="has-tests">
579 <xsl:param name="content"/>
580 <xsl:param name="build" select="get:build()"/>
581 <xsl:variable name="configure"><xsl:apply-templates select="get:step('configure', $build)"/></xsl:variable>
582 <xsl:value-of select="get:step('run-tests', $build) or contains($configure, '--host=')"/>
583 </xsl:template>
584
585 <!--
586 strip - strips leading and trailing whitespace
587
588 Usage: <strip>
589 foobar
590 </strip>
591
592 Converts to text and strips leading and trailing whitespace.
593 -->
594 <xsl:template name="strip">
595 <xsl:param name="content"/>
596 <xsl:variable name="len" select="string-length($content)"/>
597 <xsl:variable name="norm" select="normalize-space($content)"/>
598 <xsl:variable name="normlen" select="string-length($norm)"/>
599 <xsl:choose>
600 <xsl:when test="substring($content, 1, 1) != substring($norm, 1, 1)">
601 <xsl:call-template name="strip">
602 <xsl:with-param name="content" select="substring($content, 2)"/>
603 </xsl:call-template>
604 </xsl:when>
605 <xsl:when test="substring($content, $len, 1) != substring($norm, $normlen, 1)">
606 <xsl:call-template name="strip">
607 <xsl:with-param name="content" select="substring($content, 1, $len - 1)"/>
608 </xsl:call-template>
609 </xsl:when>
610 <xsl:otherwise>
611 <xsl:value-of select="$content"/>
612 </xsl:otherwise>
613 </xsl:choose>
614 </xsl:template>
615
616 <!--
617 normalize-space - normalises whitespace.
618
619 Usage: <normalize-space>
620 foobar
621 </normalize-space>
622
623 Converts to text, strips leading and trailing whitespace and replaces
624 sequences of whitespace characters by a single space.
625 -->
626 <xsl:template name="normalize-space">
627 <xsl:param name="content"/>
628 <xsl:value-of select="normalize-space($content)"/>
629 </xsl:template>
630
631 <!--
632 lower-case - converts to lower case.
633
634 Usage: <lower-case>FooBar</lower-case>
635 -->
636 <xsl:template name="lower-case">
637 <xsl:param name="content"/>
638 <xsl:variable name="lower">abcdefghijklmnopqrstuvwxyz</xsl:variable>
639 <xsl:variable name="upper">ABCDEFGHIJKLMNOPQRSTUVWXYZ</xsl:variable>
640 <xsl:value-of select="translate($content, $upper, $lower)"/>
641 </xsl:template>
642
643 <!--
644 Helpers to convert between day numbers and names.
645 -->
646 <xsl:template name="day-number">
647 <xsl:param name="content"/>
648 <xsl:param name="name"/>
649 <xsl:choose>
650 <xsl:when test="$name = 'monday'">0</xsl:when>
651 <xsl:when test="$name = 'tuesday'">1</xsl:when>
652 <xsl:when test="$name = 'wednesday'">2</xsl:when>
653 <xsl:when test="$name = 'thursday'">3</xsl:when>
654 <xsl:when test="$name = 'friday'">4</xsl:when>
655 <xsl:when test="$name = 'saturday'">5</xsl:when>
656 <xsl:when test="$name = 'sunday'">6</xsl:when>
657 </xsl:choose>
658 </xsl:template>
659
660 <xsl:template name="day-name">
661 <xsl:param name="content"/>
662 <xsl:param name="number"/>
663 <xsl:choose>
664 <xsl:when test="$number = '0'">monday</xsl:when>
665 <xsl:when test="$number = '1'">tuesday</xsl:when>
666 <xsl:when test="$number = '2'">wednesday</xsl:when>
667 <xsl:when test="$number = '3'">thursday</xsl:when>
668 <xsl:when test="$number = '4'">friday</xsl:when>
669 <xsl:when test="$number = '5'">saturday</xsl:when>
670 <xsl:when test="$number = '6'">sunday</xsl:when>
671 </xsl:choose>
672 </xsl:template>
673
674 <!--
675 Helpers to convert between time in the format 'hhmm' and an integer
676 count of the minutes since midnight.
677 -->
678 <xsl:template name="time-minutes">
679 <xsl:param name="content"/>
680 <xsl:param name="hhmm"/>
681 <xsl:if test="string-length($hhmm) = 4 and format-number($hhmm, '0000') = $hhmm">
682 <xsl:variable name="hour" select="substring($hhmm, 1, 2)"/>
683 <xsl:variable name="min" select="substring($hhmm, 3, 2)"/>
684 <xsl:if test="$hour >= 0 and $hour &lt; 24 and $min >= 0 and $min &lt; 60">
685 <xsl:value-of select="$hour * 60 + $min"/>
686 </xsl:if>
687 </xsl:if>
688 </xsl:template>
689
690 <xsl:template name="time-hhmm">
691 <xsl:param name="content"/>
692 <xsl:param name="minutes"/>
693 <xsl:value-of select="format-number(floor($minutes div 60) * 100 + $minutes mod 60, '0000')"/>
694 </xsl:template>
695
696 <!--
697 Create schedulers.
698 -->
699 <xsl:template name="nightly-schedulers">
700 <xsl:param name="content"/>
701 <xsl:param name="name"/>
702 <xsl:param name="day"><day-number name="{$name}"/></xsl:param>
703 <xsl:param name="hour" select="0"/>
704 <xsl:param name="minute" select="0"/>
705 <xsl:param name="step" select="30"/>
706
707 <xsl:if test="$hour &lt; 24">
708 <nightly>
709 <name>
710 <xsl:value-of select="concat($name, '_', format-number($hour, '00'), format-number($minute, '00'))"/>
711 </name>
712 <hour>
713 <xsl:value-of select="$hour"/>
714 </hour>
715 <minute>
716 <xsl:value-of select="$minute"/>
717 </minute>
718 <xsl:if test="$day != ''">
719 <dayOfWeek>
720 <xsl:value-of select="$day"/>
721 </dayOfWeek>
722 </xsl:if>
723 </nightly>
724 <xsl:variable name="next" select="$hour * 60 + $minute + $step"/>
725 <xsl:call-template name="nightly-schedulers">
726 <xsl:with-param name="name" select="$name"/>
727 <xsl:with-param name="day" select="$day"/>
728 <xsl:with-param name="hour" select="floor($next div 60)"/>
729 <xsl:with-param name="minute" select="$next mod 60"/>
730 <xsl:with-param name="step" select="$step"/>
731 </xsl:call-template>
732 </xsl:if>
733 </xsl:template>
734
735 <!--
736 scheduler - provide default for the <scheduler> build element.
737 -->
738 <xsl:template name="scheduler">
739 <xsl:param name="content"/>
740 <xsl:param name="previous" select="get:property('scheduler', get:preceding-builds()[last()])"/>
741 <xsl:param name="step" select="60"/>
742
743 <xsl:choose>
744 <xsl:when test="exsl:node-set($content)/node()">
745 <scheduler>
746 <xsl:copy-of select="$content"/>
747 </scheduler>
748 </xsl:when>
749 <xsl:otherwise>
750 <xsl:for-each select="$previous">
751 <xsl:variable name="text">
752 <xsl:apply-templates select="."/>
753 </xsl:variable>
754 <scheduler>
755 <scheduler-subst text="{$text}" step="{$step}"/>
756 </scheduler>
757 </xsl:for-each>
758 </xsl:otherwise>
759 </xsl:choose>
760 </xsl:template>
761
762 <xsl:template name="scheduler-subst">
763 <xsl:param name="content"/>
764 <xsl:param name="text"/>
765 <xsl:param name="step"/>
766
767 <xsl:variable name="name" select="substring-before($text, '_')"/>
768 <xsl:variable name="hhmm" select="substring-after($text, '_')"/>
769 <xsl:variable name="day"><day-number name="{$name}"/></xsl:variable>
770 <xsl:variable name="mins"><time-minutes hhmm="{$hhmm}"/></xsl:variable>
771
772 <xsl:choose>
773 <xsl:when test="$mins = ''">
774 <xsl:value-of select="$text"/>
775 </xsl:when>
776 <xsl:when test="$day = ''">
777 <xsl:value-of select="$name"/>
778 <xsl:text>_</xsl:text>
779 <time-hhmm minutes="{$mins + $step}"/>
780 </xsl:when>
781 <xsl:otherwise>
782 <xsl:variable name="day-mins" select="24 * 60"/>
783 <xsl:variable name="week-mins" select="7 * $day-mins"/>
784 <xsl:variable name="tmp" select="($day + 1) * $day-mins + $mins"/>
785 <xsl:variable name="next" select="$tmp mod $week-mins + floor($tmp div $week-mins) * $step"/>
786 <day-name number="{floor($next div $day-mins)}"/>
787 <xsl:text>_</xsl:text>
788 <time-hhmm minutes="{$next mod $day-mins}"/>
789 </xsl:otherwise>
790 </xsl:choose>
791 </xsl:template>
792
793 <!--
794 email - substitute '@' for ' -at- ' in email addresses.
795 -->
796 <xsl:template name="emailfield">
797 <xsl:param name="content"/>
798 <xsl:param name="addr"/>
799 <xsl:variable name="at"> -at- </xsl:variable>
800 <xsl:choose>
801 <xsl:when test="contains($addr, $at)">
802 <xsl:value-of select="substring-before($addr, $at)"/>
803 <xsl:text>@</xsl:text>
804 <xsl:value-of select="substring-after($addr, $at)"/>
805 </xsl:when>
806 <xsl:otherwise>
807 <xsl:value-of select="$addr"/>
808 </xsl:otherwise>
809 </xsl:choose>
810 </xsl:template>
811
812 <xsl:template name="email">
813 <xsl:param name="content"/>
814 <xsl:param name="id"/>
815 <email id="{$id}"><emailfield addr="{$content}"/></email>
816 </xsl:template>
817
818 <xsl:template name="fromaddr">
819 <xsl:param name="content"/>
820 <fromaddr><emailfield addr="{$content}"/></fromaddr>
821 </xsl:template>
822
823 <xsl:template name="extraRecipient">
824 <xsl:param name="content"/>
825 <extraRecipient><emailfield addr="{$content}"/></extraRecipient>
826 </xsl:template>
827
828 <!--
829 mailnotifier - add a default value for <fromaddr> to <mailnotifier>
830 -->
831 <xsl:template name="mailnotifier">
832 <xsl:param name="content"/>
833 <mailnotifier>
834 <defaults content="{$content}">
835 <fromaddr>noreply -at- wxsite.net</fromaddr>
836 </defaults>
837 <xsl:copy-of select="$content"/>
838 </mailnotifier>
839 </xsl:template>
840
841 </bot>