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