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