]>
Commit | Line | Data |
---|---|---|
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 | |
526954c5 | 9 | Licence: wxWindows licence |
801be649 MW |
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 | 28 | |
4fcffaf0 MW |
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 | ||
801be649 MW |
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'"> | |
229 | <xsl:choose> | |
230 | <xsl:when test="$gui = 'true'">utils</xsl:when> | |
231 | <xsl:otherwise>utils/tex2rtf/src ../../HelpGen/src</xsl:otherwise> | |
232 | </xsl:choose> | |
233 | <xsl:text> </xsl:text> | |
234 | </xsl:if> | |
235 | ||
236 | <xsl:if test="$demos = 'true' and $gui = 'true'">demos </xsl:if> | |
237 | ||
238 | <xsl:if test="$contrib = 'true' and $gui = 'true'">contrib </xsl:if> | |
239 | ||
240 | <xsl:if test="$tests = 'true'">tests</xsl:if> | |
241 | </xsl:template> | |
242 | ||
243 | <!-- | |
244 | compile-subdir - build step to compile a subdirectory. | |
245 | ||
246 | Usage: as <compile> plus the following attributes, | |
247 | <compile-subdir dir="foobar" [ halt="true" ]/> | |
248 | ||
249 | Compiles the named subdirectory 'foobar'. Continues with the next build | |
250 | step on failure, unless the optional attibute 'halt="true"' is given. | |
251 | The make command used is as described for the compile step above. | |
252 | --> | |
253 | <xsl:template name="compile-subdir"> | |
254 | <xsl:param name="content"/> | |
255 | <xsl:param name="dir"/> | |
256 | <xsl:param name="halt" select="'false'"/> | |
257 | <compile-subdirs name="{$dir}" dirs="{$dir}" halt="{$halt}"> | |
258 | <xsl:copy-of select="$content"/> | |
259 | </compile-subdirs> | |
260 | </xsl:template> | |
261 | ||
262 | <!-- | |
263 | compile-subdirs - adds a compile build step for each directory in a list. | |
264 | ||
265 | Usage: as <compile> plus the following attributes, | |
266 | <compile-subdir dirs="foobar1 foobar2" | |
267 | [ name="foobars" ] | |
268 | [ sep=" " ] | |
269 | [ halt="true" ]/> | |
270 | ||
271 | Compiles the named subdirectories. Continues with the next build | |
272 | step on failure, unless the optional attibute 'halt="true"' is given. | |
273 | The make command used is as described for the compile step above. | |
274 | The 'name' attribute can be used to give a collective name for the | |
275 | subdirectories, and the 'sep' attibute can be used to specify the | |
276 | separator in the 'dirs' list (defaults to space). | |
277 | --> | |
278 | <xsl:template name="compile-subdirs"> | |
279 | <xsl:param name="content"/> | |
280 | <xsl:param name="name"/> | |
281 | <xsl:param name="dirs"/> | |
282 | <xsl:param name="sep" select="' '"/> | |
283 | <xsl:param name="halt" select="'false'"/> | |
284 | <xsl:if test="translate($dirs, $sep, '')"> | |
285 | <compile> | |
286 | <defaults content="{$content}"> | |
287 | <name> | |
288 | <xsl:value-of select="normalize-space(concat('compile ', $name))"/> | |
289 | </name> | |
290 | <description> | |
291 | <xsl:value-of select="normalize-space(concat('compiling ', $name))"/> | |
292 | </description> | |
293 | <descriptionDone> | |
294 | <xsl:value-of select="normalize-space(concat('compile ', $name))"/> | |
295 | </descriptionDone> | |
296 | <haltOnFailure> | |
297 | <xsl:value-of select="$halt"/> | |
298 | </haltOnFailure> | |
299 | <warnOnFailure/> | |
300 | </defaults> | |
301 | <copy-with-defaults content="{$content}"> | |
302 | <command> | |
303 | <compile-subdirs-cmd dirs="{$dirs}" sep="{$sep}"/> | |
304 | </command> | |
305 | </copy-with-defaults> | |
306 | </compile> | |
307 | </xsl:if> | |
308 | </xsl:template> | |
309 | ||
310 | <xsl:template name="compile-subdirs-cmd"> | |
311 | <xsl:param name="content"/> | |
312 | <xsl:param name="dirs"/> | |
313 | <xsl:param name="sep"/> | |
314 | <xsl:choose> | |
315 | <xsl:when test="contains($dirs, $sep)"> | |
316 | <xsl:variable name="before" select="substring-before($dirs, $sep)"/> | |
317 | <xsl:variable name="after" select="substring-after($dirs, $sep)"/> | |
318 | ||
319 | <xsl:call-template name="compile-subdirs-cmd"> | |
320 | <xsl:with-param name="dirs" select="$before"/> | |
321 | <xsl:with-param name="sep" select="$sep"/> | |
322 | </xsl:call-template> | |
323 | ||
324 | <xsl:if test="$after and substring($after, 1, 1) != ' '"> | |
325 | <xsl:text> && </xsl:text> | |
326 | </xsl:if> | |
327 | ||
328 | <xsl:call-template name="compile-subdirs-cmd"> | |
329 | <xsl:with-param name="dirs" select="$after"/> | |
330 | <xsl:with-param name="sep" select="$sep"/> | |
331 | </xsl:call-template> | |
332 | </xsl:when> | |
333 | <xsl:when test="string($dirs)"> | |
334 | <xsl:if test="$dirs != '.'">cd <xsl:value-of select="$dirs"/> && </xsl:if> | |
335 | <get name="make" default="make"/> | |
336 | </xsl:when> | |
337 | </xsl:choose> | |
338 | </xsl:template> | |
339 | ||
340 | <!-- | |
341 | run-tests - build step to run the test suites. | |
342 | ||
343 | Usage: as <test> | |
344 | ||
345 | Typically just: | |
346 | <run-tests/> | |
347 | --> | |
348 | <xsl:template name="run-tests"> | |
349 | <xsl:param name="content"/> | |
9c0e333c MW |
350 | <xsl:param name="options" select="'-t'"/> |
351 | <xsl:param name="guioptions" select="$options"/> | |
801be649 MW |
352 | <xsl:param name="msw"><is-msw/></xsl:param> |
353 | <test> | |
354 | <defaults content="{$content}"> | |
355 | <description>running tests</description> | |
356 | <descriptionDone>run tests</descriptionDone> | |
357 | <warnOnFailure/> | |
358 | </defaults> | |
359 | <copy-with-defaults content="{$content}"> | |
360 | <command> | |
361 | <xsl:choose> | |
362 | <xsl:when test="$msw = 'true'"> | |
9c0e333c | 363 | <run-tests-win options="{$options}" guioptions="{$guioptions}"/> |
a2e0a94b VZ |
364 | </xsl:when> |
365 | <xsl:otherwise> | |
9c0e333c | 366 | <run-tests-unix options="{$options}" guioptions="{$guioptions}"/> |
a2e0a94b VZ |
367 | </xsl:otherwise> |
368 | </xsl:choose> | |
369 | </command> | |
370 | </copy-with-defaults> | |
371 | </test> | |
372 | </xsl:template> | |
373 | ||
801be649 | 374 | <xsl:template name="run-tests-win"> |
9820211f | 375 | <xsl:param name="options"/> |
9c0e333c | 376 | <xsl:param name="guioptions"/> |
801be649 | 377 | <normalize-space> |
1dd8319a | 378 | cd tests && runtests.bat |
801be649 MW |
379 | </normalize-space> |
380 | </xsl:template> | |
381 | ||
382 | <xsl:template name="run-tests-unix"> | |
9820211f | 383 | <xsl:param name="options"/> |
9c0e333c | 384 | <xsl:param name="guioptions"/> |
c96ce989 | 385 | ERR=0 |
695ad1e6 | 386 | cd tests || exit 0 |
9c0e333c MW |
387 | ulimit -c unlimited |
388 | ||
389 | try() | |
390 | { | |
391 | rm -f core | |
392 | echo Running: "$@" | |
393 | "$@" || ERR=$? | |
394 | ||
395 | if [ -f core -a -x "`which gdb`" ]; then | |
396 | echo Crashed, attempting to display backtrace: | |
397 | gdb -batch -c core -ex 'set pagination off' -ex bt "$1" | |
398 | fi | |
399 | ||
400 | echo | |
401 | } | |
402 | ||
403 | try ./test <xsl:value-of select="normalize-space($options)"/> | |
404 | ||
ab333251 MW |
405 | test -x test_gui || exit $ERR |
406 | ||
407 | if [ -z "$DISPLAY" ]; then | |
408 | echo '$DISPLAY is not set, skipping GUI tests.' | |
409 | exit $ERR | |
410 | fi | |
411 | ||
412 | echo 'Checking window manager:' | |
413 | WINDOW_MANAGER=$(xprop -root 32x '\n$0\n' _NET_SUPPORTING_WM_CHECK | grep ^0x) | |
414 | ||
415 | if [ -z "$WINDOW_MANAGER" ]; then | |
416 | echo 'Window manager not present, skipping GUI tests.' | |
417 | exit $ERR | |
9c0e333c MW |
418 | fi |
419 | ||
ab333251 MW |
420 | xprop -id $WINDOW_MANAGER 8s _NET_WM_NAME |
421 | echo | |
422 | ||
423 | try ./test_gui <xsl:value-of select="normalize-space($guioptions)"/> | |
424 | ||
c96ce989 | 425 | exit $ERR |
801be649 MW |
426 | </xsl:template> |
427 | ||
428 | <!-- | |
429 | defaults - supply default content for an element. | |
430 | ||
431 | Usage: <defaults content="{$content}"> | |
432 | <foo>foo</foo> | |
433 | <bar>bar</bar> | |
434 | </defaults> | |
435 | ||
436 | Copies those child elements that do not already exist in $content. | |
437 | --> | |
438 | <xsl:template name="defaults"> | |
439 | <xsl:param name="defaults"/> | |
440 | <xsl:param name="content"/> | |
441 | ||
442 | <xsl:variable name="def-nodes" select="exsl:node-set($defaults)"/> | |
443 | <xsl:variable name="cont-nodes" select="exsl:node-set($content)"/> | |
444 | ||
445 | <xsl:for-each select="$def-nodes/*"> | |
446 | <xsl:if test="not($cont-nodes/*[name() = name(current())])"> | |
447 | <xsl:copy-of select="."/> | |
448 | </xsl:if> | |
449 | </xsl:for-each> | |
450 | </xsl:template> | |
451 | ||
452 | <!-- | |
453 | copy-with-defaults - copy elements supplying defaults for any that are | |
454 | missing or empty. | |
455 | ||
456 | Usage: <copy-with-defaults content="{$content}"> | |
457 | <foo>foo</foo> | |
458 | <bar>bar</bar> | |
459 | </copy-with-defaults> | |
460 | ||
461 | Copies $content plus any child elements that do not exist in $content, | |
462 | substituting empty elements in $content with any child elements of the | |
463 | same name. | |
464 | --> | |
465 | <xsl:template name="copy-with-defaults"> | |
466 | <xsl:param name="defaults"/> | |
467 | <xsl:param name="content"/> | |
468 | ||
469 | <xsl:variable name="def-nodes" select="exsl:node-set($defaults)"/> | |
470 | <xsl:variable name="cont-nodes" select="exsl:node-set($content)"/> | |
471 | ||
472 | <xsl:for-each select="$def-nodes/*"> | |
473 | <xsl:if test="not($cont-nodes/*[name() = name(current())])"> | |
474 | <xsl:copy-of select="."/> | |
475 | </xsl:if> | |
476 | </xsl:for-each> | |
477 | ||
478 | <xsl:for-each select="$cont-nodes/*"> | |
479 | <xsl:choose> | |
480 | <xsl:when test="not(node())"> | |
481 | <xsl:copy-of select="$def-nodes/*[name() = name(current())]"/> | |
482 | </xsl:when> | |
483 | <xsl:otherwise> | |
484 | <xsl:copy-of select="."/> | |
485 | </xsl:otherwise> | |
486 | </xsl:choose> | |
487 | </xsl:for-each> | |
488 | </xsl:template> | |
489 | ||
490 | <!-- | |
491 | get - gets the text from a child element of the current build. | |
492 | ||
493 | Usage: <get name="foobar" [ default="value" ]/> | |
494 | ||
495 | Gets the text from the <foobar> element of the current build, or returns | |
496 | $default if there is not such element. | |
497 | --> | |
498 | <xsl:template name="get"> | |
499 | <xsl:param name="content"/> | |
500 | <xsl:param name="build" select="get:build()"/> | |
501 | <xsl:param name="name"/> | |
502 | <xsl:param name="default"/> | |
503 | <xsl:variable name="property" select="get:property($name, $build)"/> | |
504 | <strip> | |
505 | <xsl:choose> | |
506 | <xsl:when test="$property"> | |
507 | <xsl:apply-templates select="$property/node()"/> | |
508 | </xsl:when> | |
509 | <xsl:otherwise> | |
510 | <xsl:value-of select="$default"/> | |
511 | </xsl:otherwise> | |
512 | </xsl:choose> | |
513 | </strip> | |
514 | </xsl:template> | |
515 | ||
516 | <!-- | |
517 | Accessors to get builds and their fields. XSLT code should use these | |
518 | instead of traversing the input tree directly. | |
519 | --> | |
520 | <func:function name="get:build"> | |
521 | <func:result select="ancestor-or-self::build[last()]"/> | |
522 | </func:function> | |
523 | ||
524 | <func:function name="get:all-builds"> | |
525 | <func:result select="//build[not(ancestor::*[name() != name(/*)])]"/> | |
526 | </func:function> | |
527 | ||
528 | <func:function name="get:preceding-builds"> | |
529 | <func:result select="get:build()/preceding-sibling::build"/> | |
530 | </func:function> | |
531 | ||
532 | <func:function name="get:property"> | |
533 | <xsl:param name="name"/> | |
534 | <xsl:param name="build" select="get:build()"/> | |
535 | <func:result select="$build/*[name() = $name]"/> | |
536 | </func:function> | |
537 | ||
538 | <func:function name="get:step"> | |
539 | <xsl:param name="name"/> | |
540 | <xsl:param name="build" select="get:build()"/> | |
541 | <func:result select="get:property('steps', $build)/*[name() = $name]"/> | |
542 | </func:function> | |
543 | ||
544 | <!-- | |
545 | Returns true if this is an msw build. | |
546 | --> | |
547 | <xsl:template name="is-msw"> | |
548 | <xsl:param name="content"/> | |
549 | <xsl:param name="build" select="get:build()"/> | |
550 | <xsl:value-of select="not(get:step('configure', $build))"/> | |
551 | </xsl:template> | |
552 | ||
553 | <!-- | |
554 | Returns true if this a gui build. | |
555 | --> | |
556 | <xsl:template name="is-gui"> | |
557 | <xsl:param name="content"/> | |
558 | <xsl:param name="build" select="get:build()"/> | |
559 | <xsl:variable name="make"><get name="make" build="{$build}"/></xsl:variable> | |
560 | <xsl:variable name="configure"><xsl:apply-templates select="get:step('configure', $build)"/></xsl:variable> | |
561 | <xsl:value-of select="not(contains($make, 'USE_GUI=0') or contains($configure, '--disable-gui'))"/> | |
562 | </xsl:template> | |
563 | ||
564 | <!-- | |
565 | Returns true if the branch we're building has a contrib subdirectory. | |
566 | --> | |
567 | <xsl:template name="has-contrib"> | |
568 | <xsl:param name="content"/> | |
569 | <xsl:param name="build" select="get:build()"/> | |
570 | <xsl:variable name="checkout"><xsl:apply-templates select="get:step('checkout', $build)"/></xsl:variable> | |
571 | <xsl:value-of select="contains($checkout, 'WX_2_') and not(contains($checkout, 'WX_2_9_'))"/> | |
572 | </xsl:template> | |
573 | ||
574 | <!-- | |
575 | Returns true if the build should build the test suite. | |
576 | --> | |
577 | <xsl:template name="has-tests"> | |
578 | <xsl:param name="content"/> | |
579 | <xsl:param name="build" select="get:build()"/> | |
580 | <xsl:variable name="configure"><xsl:apply-templates select="get:step('configure', $build)"/></xsl:variable> | |
581 | <xsl:value-of select="get:step('run-tests', $build) or contains($configure, '--host=')"/> | |
582 | </xsl:template> | |
583 | ||
584 | <!-- | |
585 | strip - strips leading and trailing whitespace | |
586 | ||
587 | Usage: <strip> | |
588 | foobar | |
589 | </strip> | |
590 | ||
591 | Converts to text and strips leading and trailing whitespace. | |
592 | --> | |
593 | <xsl:template name="strip"> | |
594 | <xsl:param name="content"/> | |
595 | <xsl:variable name="len" select="string-length($content)"/> | |
596 | <xsl:variable name="norm" select="normalize-space($content)"/> | |
597 | <xsl:variable name="normlen" select="string-length($norm)"/> | |
598 | <xsl:choose> | |
599 | <xsl:when test="substring($content, 1, 1) != substring($norm, 1, 1)"> | |
600 | <xsl:call-template name="strip"> | |
601 | <xsl:with-param name="content" select="substring($content, 2)"/> | |
602 | </xsl:call-template> | |
603 | </xsl:when> | |
604 | <xsl:when test="substring($content, $len, 1) != substring($norm, $normlen, 1)"> | |
605 | <xsl:call-template name="strip"> | |
606 | <xsl:with-param name="content" select="substring($content, 1, $len - 1)"/> | |
607 | </xsl:call-template> | |
608 | </xsl:when> | |
609 | <xsl:otherwise> | |
610 | <xsl:value-of select="$content"/> | |
611 | </xsl:otherwise> | |
612 | </xsl:choose> | |
613 | </xsl:template> | |
614 | ||
615 | <!-- | |
616 | normalize-space - normalises whitespace. | |
617 | ||
618 | Usage: <normalize-space> | |
619 | foobar | |
620 | </normalize-space> | |
621 | ||
622 | Converts to text, strips leading and trailing whitespace and replaces | |
623 | sequences of whitespace characters by a single space. | |
624 | --> | |
625 | <xsl:template name="normalize-space"> | |
626 | <xsl:param name="content"/> | |
627 | <xsl:value-of select="normalize-space($content)"/> | |
628 | </xsl:template> | |
629 | ||
630 | <!-- | |
631 | lower-case - converts to lower case. | |
632 | ||
633 | Usage: <lower-case>FooBar</lower-case> | |
634 | --> | |
635 | <xsl:template name="lower-case"> | |
636 | <xsl:param name="content"/> | |
637 | <xsl:variable name="lower">abcdefghijklmnopqrstuvwxyz</xsl:variable> | |
638 | <xsl:variable name="upper">ABCDEFGHIJKLMNOPQRSTUVWXYZ</xsl:variable> | |
639 | <xsl:value-of select="translate($content, $upper, $lower)"/> | |
640 | </xsl:template> | |
641 | ||
642 | <!-- | |
643 | Helpers to convert between day numbers and names. | |
644 | --> | |
645 | <xsl:template name="day-number"> | |
646 | <xsl:param name="content"/> | |
647 | <xsl:param name="name"/> | |
648 | <xsl:choose> | |
808ac867 MW |
649 | <xsl:when test="$name = 'monday'">0</xsl:when> |
650 | <xsl:when test="$name = 'tuesday'">1</xsl:when> | |
651 | <xsl:when test="$name = 'wednesday'">2</xsl:when> | |
652 | <xsl:when test="$name = 'thursday'">3</xsl:when> | |
653 | <xsl:when test="$name = 'friday'">4</xsl:when> | |
654 | <xsl:when test="$name = 'saturday'">5</xsl:when> | |
655 | <xsl:when test="$name = 'sunday'">6</xsl:when> | |
801be649 MW |
656 | </xsl:choose> |
657 | </xsl:template> | |
658 | ||
659 | <xsl:template name="day-name"> | |
660 | <xsl:param name="content"/> | |
661 | <xsl:param name="number"/> | |
662 | <xsl:choose> | |
808ac867 MW |
663 | <xsl:when test="$number = '0'">monday</xsl:when> |
664 | <xsl:when test="$number = '1'">tuesday</xsl:when> | |
665 | <xsl:when test="$number = '2'">wednesday</xsl:when> | |
666 | <xsl:when test="$number = '3'">thursday</xsl:when> | |
667 | <xsl:when test="$number = '4'">friday</xsl:when> | |
668 | <xsl:when test="$number = '5'">saturday</xsl:when> | |
669 | <xsl:when test="$number = '6'">sunday</xsl:when> | |
801be649 MW |
670 | </xsl:choose> |
671 | </xsl:template> | |
672 | ||
673 | <!-- | |
674 | Helpers to convert between time in the format 'hhmm' and an integer | |
675 | count of the minutes since midnight. | |
676 | --> | |
677 | <xsl:template name="time-minutes"> | |
678 | <xsl:param name="content"/> | |
679 | <xsl:param name="hhmm"/> | |
680 | <xsl:if test="string-length($hhmm) = 4 and format-number($hhmm, '0000') = $hhmm"> | |
681 | <xsl:variable name="hour" select="substring($hhmm, 1, 2)"/> | |
682 | <xsl:variable name="min" select="substring($hhmm, 3, 2)"/> | |
683 | <xsl:if test="$hour >= 0 and $hour < 24 and $min >= 0 and $min < 60"> | |
684 | <xsl:value-of select="$hour * 60 + $min"/> | |
685 | </xsl:if> | |
686 | </xsl:if> | |
687 | </xsl:template> | |
688 | ||
689 | <xsl:template name="time-hhmm"> | |
690 | <xsl:param name="content"/> | |
691 | <xsl:param name="minutes"/> | |
692 | <xsl:value-of select="format-number(floor($minutes div 60) * 100 + $minutes mod 60, '0000')"/> | |
693 | </xsl:template> | |
694 | ||
695 | <!-- | |
696 | Create schedulers. | |
697 | --> | |
698 | <xsl:template name="nightly-schedulers"> | |
699 | <xsl:param name="content"/> | |
700 | <xsl:param name="name"/> | |
701 | <xsl:param name="day"><day-number name="{$name}"/></xsl:param> | |
702 | <xsl:param name="hour" select="0"/> | |
703 | <xsl:param name="minute" select="0"/> | |
704 | <xsl:param name="step" select="30"/> | |
705 | ||
706 | <xsl:if test="$hour < 24"> | |
707 | <nightly> | |
708 | <name> | |
709 | <xsl:value-of select="concat($name, '_', format-number($hour, '00'), format-number($minute, '00'))"/> | |
710 | </name> | |
711 | <hour> | |
712 | <xsl:value-of select="$hour"/> | |
713 | </hour> | |
714 | <minute> | |
715 | <xsl:value-of select="$minute"/> | |
716 | </minute> | |
717 | <xsl:if test="$day != ''"> | |
718 | <dayOfWeek> | |
719 | <xsl:value-of select="$day"/> | |
720 | </dayOfWeek> | |
721 | </xsl:if> | |
722 | </nightly> | |
723 | <xsl:variable name="next" select="$hour * 60 + $minute + $step"/> | |
724 | <xsl:call-template name="nightly-schedulers"> | |
725 | <xsl:with-param name="name" select="$name"/> | |
726 | <xsl:with-param name="day" select="$day"/> | |
727 | <xsl:with-param name="hour" select="floor($next div 60)"/> | |
728 | <xsl:with-param name="minute" select="$next mod 60"/> | |
729 | <xsl:with-param name="step" select="$step"/> | |
730 | </xsl:call-template> | |
731 | </xsl:if> | |
732 | </xsl:template> | |
733 | ||
734 | <!-- | |
735 | scheduler - provide default for the <scheduler> build element. | |
736 | --> | |
737 | <xsl:template name="scheduler"> | |
738 | <xsl:param name="content"/> | |
739 | <xsl:param name="previous" select="get:property('scheduler', get:preceding-builds()[last()])"/> | |
740 | <xsl:param name="step" select="60"/> | |
741 | ||
742 | <xsl:choose> | |
743 | <xsl:when test="exsl:node-set($content)/node()"> | |
744 | <scheduler> | |
745 | <xsl:copy-of select="$content"/> | |
746 | </scheduler> | |
747 | </xsl:when> | |
748 | <xsl:otherwise> | |
749 | <xsl:for-each select="$previous"> | |
750 | <xsl:variable name="text"> | |
751 | <xsl:apply-templates select="."/> | |
752 | </xsl:variable> | |
753 | <scheduler> | |
754 | <scheduler-subst text="{$text}" step="{$step}"/> | |
755 | </scheduler> | |
756 | </xsl:for-each> | |
757 | </xsl:otherwise> | |
758 | </xsl:choose> | |
759 | </xsl:template> | |
760 | ||
761 | <xsl:template name="scheduler-subst"> | |
762 | <xsl:param name="content"/> | |
763 | <xsl:param name="text"/> | |
764 | <xsl:param name="step"/> | |
765 | ||
766 | <xsl:variable name="name" select="substring-before($text, '_')"/> | |
767 | <xsl:variable name="hhmm" select="substring-after($text, '_')"/> | |
768 | <xsl:variable name="day"><day-number name="{$name}"/></xsl:variable> | |
769 | <xsl:variable name="mins"><time-minutes hhmm="{$hhmm}"/></xsl:variable> | |
770 | ||
771 | <xsl:choose> | |
772 | <xsl:when test="$mins = ''"> | |
773 | <xsl:value-of select="$text"/> | |
774 | </xsl:when> | |
775 | <xsl:when test="$day = ''"> | |
776 | <xsl:value-of select="$name"/> | |
777 | <xsl:text>_</xsl:text> | |
778 | <time-hhmm minutes="{$mins + $step}"/> | |
779 | </xsl:when> | |
780 | <xsl:otherwise> | |
781 | <xsl:variable name="day-mins" select="24 * 60"/> | |
782 | <xsl:variable name="week-mins" select="7 * $day-mins"/> | |
783 | <xsl:variable name="tmp" select="($day + 1) * $day-mins + $mins"/> | |
784 | <xsl:variable name="next" select="$tmp mod $week-mins + floor($tmp div $week-mins) * $step"/> | |
785 | <day-name number="{floor($next div $day-mins)}"/> | |
786 | <xsl:text>_</xsl:text> | |
787 | <time-hhmm minutes="{$next mod $day-mins}"/> | |
788 | </xsl:otherwise> | |
789 | </xsl:choose> | |
790 | </xsl:template> | |
791 | ||
274e7157 MW |
792 | <!-- |
793 | email - substitute '@' for ' -at- ' in email addresses. | |
794 | --> | |
795 | <xsl:template name="emailfield"> | |
796 | <xsl:param name="content"/> | |
797 | <xsl:param name="addr"/> | |
798 | <xsl:variable name="at"> -at- </xsl:variable> | |
799 | <xsl:choose> | |
800 | <xsl:when test="contains($addr, $at)"> | |
801 | <xsl:value-of select="substring-before($addr, $at)"/> | |
802 | <xsl:text>@</xsl:text> | |
803 | <xsl:value-of select="substring-after($addr, $at)"/> | |
804 | </xsl:when> | |
805 | <xsl:otherwise> | |
806 | <xsl:value-of select="$addr"/> | |
807 | </xsl:otherwise> | |
808 | </xsl:choose> | |
809 | </xsl:template> | |
810 | ||
811 | <xsl:template name="email"> | |
812 | <xsl:param name="content"/> | |
813 | <xsl:param name="id"/> | |
814 | <email id="{$id}"><emailfield addr="{$content}"/></email> | |
815 | </xsl:template> | |
816 | ||
817 | <xsl:template name="fromaddr"> | |
818 | <xsl:param name="content"/> | |
819 | <fromaddr><emailfield addr="{$content}"/></fromaddr> | |
820 | </xsl:template> | |
821 | ||
822 | <xsl:template name="extraRecipient"> | |
823 | <xsl:param name="content"/> | |
824 | <extraRecipient><emailfield addr="{$content}"/></extraRecipient> | |
825 | </xsl:template> | |
826 | ||
827 | <!-- | |
828 | mailnotifier - add a default value for <fromaddr> to <mailnotifier> | |
829 | --> | |
830 | <xsl:template name="mailnotifier"> | |
831 | <xsl:param name="content"/> | |
832 | <mailnotifier> | |
833 | <defaults content="{$content}"> | |
58faf9dd | 834 | <fromaddr>noreply -at- wxsite.net</fromaddr> |
274e7157 MW |
835 | </defaults> |
836 | <xsl:copy-of select="$content"/> | |
837 | </mailnotifier> | |
838 | </xsl:template> | |
839 | ||
801be649 | 840 | </bot> |