+<?xml version="1.0" encoding="utf-8"?>
+
+<!--
+ Name: include.xml
+ Purpose: Common declarations for buildbot
+ Author: Mike Wetherell
+ RCS-ID: $Id$
+ Copyright: (c) 2007 Mike Wetherell
+ Licence: wxWidgets licence
+-->
+
+<bot xmlns:xi="http://www.w3.org/2001/XInclude"
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ xmlns:exsl="http://exslt.org/common"
+ xsl:version="1.0">
+
+<!--
+ Constants
+-->
+<xsl:template name="SVN_URL">http://svn.wxwidgets.org/svn/wx/wxWidgets/</xsl:template>
+<xsl:template name="STABLE_BRANCH">branches/WX_2_8_BRANCH</xsl:template>
+<xsl:variable name="STABLE_BRANCH"><STABLE_BRANCH/></xsl:variable>
+
+<!--
+ checkout - build step for source checkout.
+
+ Usage: as <svn> with defaults for <baseURL> and <defaultBranch>
+
+ Typically just:
+ <checkout/>
+ for the trunk, or:
+ <checkout branch="branches/WX_2_8_BRANCH"/>
+ to checkout a branch.
+-->
+<xsl:template name="checkout">
+ <xsl:param name="content"/>
+ <xsl:param name="branch" select="'trunk'"/>
+ <xsl:variable name="nodes" select="exsl:node-set($content)"/>
+ <svn>
+ <xsl:if test="not($nodes/svnurl)">
+ <xsl:if test="not($nodes/baseURL)">
+ <baseURL><SVN_URL/></baseURL>
+ </xsl:if>
+ <xsl:if test="not($nodes/defaultBranch)">
+ <defaultBranch><xsl:value-of select="$branch"/></defaultBranch>
+ </xsl:if>
+ </xsl:if>
+ <xsl:copy-of select="$content"/>
+ </svn>
+</xsl:template>
+
+<!--
+ configure - add the options attribute to <configure>
+
+ Usage: <configure options="-with-foobar"/>
+-->
+<xsl:template name="configure">
+ <xsl:param name="content"/>
+ <xsl:param name="options"/>
+ <configure>
+ <copy-with-defaults content="{$content}">
+ <command>./configure <xsl:value-of select="$options"/></command>
+ </copy-with-defaults>
+ </configure>
+</xsl:template>
+
+<!--
+ make - specify the make command.
+
+ Usage: <make>nmake -f makefile.vc SHARED=1</make>
+
+ Used as a child of <build> to specify the make command used by the
+ <compile> elements below, if omitted 'make' is used.
+-->
+<xsl:template name="make"/>
+
+<!--
+ compile - modifiy <compile> to default to the command given by <make>
+
+ Usage: as <compile>
+
+ The <make> element of <build> spcecifies the make command used by all
+ compile build steps in the build. If <make> is not given 'make' is used.
+
+ The command for a particular compile build step can be further overridden
+ using its <command> element:
+ <compile>
+ <command>myscript</command>
+ </compile>
+-->
+<xsl:template name="compile">
+ <xsl:param name="content"/>
+ <compile>
+ <copy-with-defaults content="{$content}">
+ <command><get name="make" default="make"/></command>
+ </copy-with-defaults>
+ </compile>
+</xsl:template>
+
+<!--
+ Compile build steps for the usual subdirectories.
+
+ Usage: as <compile>
+
+ Typically just:
+ <compile-msw/>
+ <compile-samples/>
+ <compile-utils/>
+ <compile-contrib/>
+ <compile-tests/>
+
+ By default the compile command produced is:
+ cd foobar && make
+ As above, the 'make' part can be overridden using the <make> element or
+ the whole command line can be replaced using <command>.
+
+ <compile-msw> and <compile-tests> halt the build on failure, the others
+ continue with the next step (can be overridden by <haltOnFailure>).
+-->
+<xsl:template name="compile-msw">
+ <xsl:param name="content"/>
+ <compile-subdir dir="build\msw" halt="true">
+ <xsl:copy-of select="$content"/>
+ </compile-subdir>
+</xsl:template>
+
+<xsl:template name="compile-samples">
+ <xsl:param name="content"/>
+ <compile-subdir dir="samples">
+ <xsl:copy-of select="$content"/>
+ </compile-subdir>
+</xsl:template>
+
+<xsl:template name="compile-utils">
+ <xsl:param name="content"/>
+ <compile-subdir dir="utils">
+ <xsl:copy-of select="$content"/>
+ </compile-subdir>
+</xsl:template>
+
+<xsl:template name="compile-contrib">
+ <xsl:param name="content"/>
+ <compile-subdir dir="contrib">
+ <xsl:copy-of select="$content"/>
+ </compile-subdir>
+</xsl:template>
+
+<xsl:template name="compile-tests">
+ <xsl:param name="content"/>
+ <compile-subdir dir="tests" halt="true">
+ <xsl:copy-of select="$content"/>
+ </compile-subdir>
+</xsl:template>
+
+<!--
+ compile-subdir - build step to compile a subdirectory.
+
+ Usage: as <compile> plus the following attributes,
+ <compile-subdir dir="foobar" [ halt="true" ]/>
+
+ Compiles the named subdirectory 'foobar'. Continues with the next build
+ step on failure, unless the optional attibute 'halt="true"' is given.
+ The make command used is as described for the compile steps above.
+-->
+<xsl:template name="compile-subdir">
+ <xsl:param name="content"/>
+ <xsl:param name="dir"/>
+ <xsl:param name="halt" select="'false'"/>
+ <compile>
+ <defaults content="{$content}">
+ <description>
+ compiling <xsl:value-of select="$dir"/>
+ </description>
+ <descriptionDone>
+ compile <xsl:value-of select="$dir"/>
+ </descriptionDone>
+ <haltOnFailure>
+ <xsl:value-of select="$halt"/>
+ </haltOnFailure>
+ <warnOnFailure/>
+ </defaults>
+ <copy-with-defaults content="{$content}">
+ <command>cd <xsl:value-of select="$dir"/> && <get name="make" default="make"/></command>
+ </copy-with-defaults>
+ </compile>
+</xsl:template>
+
+<!--
+ run-tests - build step to run the test suites.
+
+ Usage: as <test>
+
+ For unix builds typically just:
+ <run-tests/>
+ or for Windows builds, e.g.:
+ <run-tests>
+ <command>PATH=..\lib\vc_lib;%PATH%</command>
+ <command>cd tests && vc_msw\test</command>
+ </run-tests>
+-->
+<xsl:template name="run-tests">
+ <xsl:param name="content"/>
+ <test>
+ <defaults content="{$content}">
+ <description>running tests</description>
+ <descriptionDone>run tests</descriptionDone>
+ <warnOnFailure/>
+ </defaults>
+ <copy-with-defaults content="{$content}">
+ <command><xi:include href="run-tests.sh" parse="text"/></command>
+ </copy-with-defaults>
+ </test>
+</xsl:template>
+
+<!--
+ defaults - supply default content for an element.
+
+ Usage: <defaults content="{$content}">
+ <foo>foo</foo>
+ <bar>bar</bar>
+ </defaults>
+
+ Copies those child elements that do not already exist in $content.
+-->
+<xsl:template name="defaults">
+ <xsl:param name="defaults"/>
+ <xsl:param name="content"/>
+
+ <xsl:variable name="def-nodes" select="exsl:node-set($defaults)"/>
+ <xsl:variable name="cont-nodes" select="exsl:node-set($content)"/>
+
+ <xsl:for-each select="$def-nodes/*">
+ <xsl:if test="not($cont-nodes/*[name() = name(current())])">
+ <xsl:copy-of select="."/>
+ </xsl:if>
+ </xsl:for-each>
+</xsl:template>
+
+<!--
+ copy-with-defaults - copy elements supplying defaults for any that are
+ missing or empty.
+
+ Usage: <copy-with-defaults content="{$content}">
+ <foo>foo</foo>
+ <bar>bar</bar>
+ </copy-with-defaults>
+
+ Copies $content plus any child elements that do not exist in $content,
+ substituting empty elements in $content with any child elements of the
+ same name.
+-->
+<xsl:template name="copy-with-defaults">
+ <xsl:param name="defaults"/>
+ <xsl:param name="content"/>
+
+ <xsl:variable name="def-nodes" select="exsl:node-set($defaults)"/>
+ <xsl:variable name="cont-nodes" select="exsl:node-set($content)"/>
+
+ <xsl:for-each select="$def-nodes/*">
+ <xsl:if test="not($cont-nodes/*[name() = name(current())])">
+ <xsl:copy-of select="."/>
+ </xsl:if>
+ </xsl:for-each>
+
+ <xsl:for-each select="$cont-nodes/*">
+ <xsl:choose>
+ <xsl:when test="not(node())">
+ <xsl:copy-of select="$def-nodes/*[name() = name(current())]"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:copy-of select="."/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:for-each>
+</xsl:template>
+
+<!--
+ get - gets the value of a named element inside a <build>.
+
+ Usage: <get name="foobar" [ default="value" ]/>
+
+ Used inside a <build> evaluates to the value of the build's <foobar>
+ element, or to the value of the optional 'default' attribute if there is
+ no such element.
+-->
+<xsl:template name="get">
+ <xsl:param name="content"/>
+ <xsl:param name="name"/>
+ <xsl:param name="default"/>
+ <strip>
+ <xsl:choose>
+ <xsl:when test="ancestor-or-self::build/*[name() = $name]">
+ <xsl:apply-templates select="ancestor-or-self::build/*[name() = $name]/node()"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="$default"/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </strip>
+</xsl:template>
+
+<!--
+ strip - strips leading and trailing whitespace
+
+ Usage: <strip>
+ foobar
+ </strip>
+
+ Strips leading and trailing whitespace if the content is text only,
+ otherwise copies the content unchanged.
+-->
+<xsl:template name="strip">
+ <xsl:param name="content"/>
+ <xsl:variable name="len" select="string-length($content)"/>
+ <xsl:variable name="norm" select="normalize-space($content)"/>
+ <xsl:variable name="normlen" select="string-length($norm)"/>
+ <xsl:choose>
+ <xsl:when test="exsl:node-set($content)/*">
+ <xsl:copy-of select="$content"/>
+ </xsl:when>
+ <xsl:when test="substring($content, 1, 1) != substring($norm, 1, 1)">
+ <xsl:call-template name="strip">
+ <xsl:with-param name="content" select="substring($content, 2)"/>
+ </xsl:call-template>
+ </xsl:when>
+ <xsl:when test="substring($content, $len, 1) != substring($norm, $normlen, 1)">
+ <xsl:call-template name="strip">
+ <xsl:with-param name="content" select="substring($content, 1, $len - 1)"/>
+ </xsl:call-template>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="$content"/>
+ </xsl:otherwise>
+ </xsl:choose>
+</xsl:template>
+
+</bot>