Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/boost_1_33_1/tools/boostbook/xsl/testing/Jamfile.xsl @ 12

Last change on this file since 12 was 12, checked in by landauf, 18 years ago

added boost

File size: 8.3 KB
Line 
1<?xml version="1.0" encoding="utf-8"?>
2<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
3                version="1.0">
4  <xsl:include href="http://docbook.sourceforge.net/release/xsl/current/html/chunker.xsl"/>
5  <xsl:include href="http://docbook.sourceforge.net/release/xsl/current/common/common.xsl"/>
6
7  <!-- The root of the Boost directory -->
8  <xsl:param name="boost.root"/>
9
10  <!-- The number of columns in a source file line -->
11  <xsl:param name="boost.source.columns" select="78"/>
12
13  <xsl:output method="text"/>
14  <xsl:template match="/">
15    <xsl:if test="$boost.root">
16      <!-- Output testsuite Jamfiles -->
17      <xsl:apply-templates select="//testsuite" mode="Jamfile"/>
18
19      <!-- Output any source files that are written in XML -->
20      <xsl:apply-templates select="//source" mode="testsuite.generate"/>
21    </xsl:if>
22
23    <xsl:if test="not($boost.root)">
24      <xsl:message>
25        Please set the XSL stylesheet parameter "boost.root" to the top-level
26        Boost directory (i.e., BOOST_ROOT)
27      </xsl:message>
28    </xsl:if>
29  </xsl:template>
30
31  <xsl:template match="testsuite" mode="Jamfile">
32    <xsl:variable name="subproject"
33      select="concat('libs/',ancestor::library/attribute::dirname,'/test')"/>
34    <xsl:variable name="filename" 
35      select="concat($boost.root,'/libs/',ancestor::library/attribute::dirname,
36                     '/test/Jamfile')"/>
37    <xsl:call-template name="write.text.chunk">
38      <xsl:with-param name="filename" select="$filename"/>
39      <xsl:with-param name="content">
40        <xsl:call-template name="source.print.header">
41          <xsl:with-param name="prefix" select="'#'"/>
42        </xsl:call-template>
43
44# Testing Jamfile autogenerated from XML source
45subproject <xsl:value-of select="$subproject"/> ;
46
47# bring in rules for testing
48SEARCH on testing.jam = $(BOOST_BUILD_PATH) ;
49include testing.jam ;
50
51# Make tests run by default.
52DEPENDS all : test ;
53
54{
55  # look in BOOST_ROOT for sources first, just in this Jamfile
56  local SEARCH_SOURCE = $(BOOST_ROOT) $(SEARCH_SOURCE) ;
57
58  test-suite <xsl:value-of select="ancestor::library/attribute::dirname"/>
59    : <xsl:apply-templates mode="Jamfile"/> ;
60}
61      </xsl:with-param>
62    </xsl:call-template>
63  </xsl:template>
64
65  <xsl:template match="compile-test|link-test|run-test|compile-fail-test|link-fail-test|run-fail-test"
66    mode="Jamfile">
67    <xsl:variable name="fullname"
68      select="concat(substring-before(local-name(.), '-test'), ' libs/',
69                     ancestor::library/attribute::dirname, '/test/',
70                     @filename)"/>
71    <xsl:text>[ </xsl:text>
72    <xsl:value-of select="$fullname"/>
73    <xsl:apply-templates select="lib" mode="Jamfile"/>
74    <xsl:text> : </xsl:text>
75    <!-- ... -->
76    <xsl:text> : </xsl:text>
77    <!-- ... -->
78    <xsl:text> : </xsl:text>
79    <xsl:apply-templates select="requirement" mode="Jamfile"/>
80    <!-- ... -->
81    <xsl:text> : </xsl:text>
82    <xsl:if test="@name">
83      <xsl:value-of select="@name"/>
84    </xsl:if>
85    <xsl:text> ]</xsl:text>
86  </xsl:template>
87
88  <xsl:template match="lib" mode="Jamfile">
89    <xsl:text> &lt;lib&gt;</xsl:text><xsl:value-of select="text()"/>
90  </xsl:template>
91
92  <xsl:template match="requirement" mode="Jamfile">
93    <xsl:if test="count(preceding-sibling::requirement) &gt; 0">
94      <xsl:text> </xsl:text>
95    </xsl:if>
96    <xsl:value-of select="concat('&lt;', @name, '&gt;')"/>
97    <xsl:value-of select="."/>
98  </xsl:template>
99
100  <xsl:template match="source" mode="testsuite.generate">
101    <xsl:variable name="filename" 
102      select="concat($boost.root,'/libs/',ancestor::library/attribute::dirname,
103                     '/test/',../@filename)"/>
104
105    <xsl:variable name="prefix" select="'//'"/>
106
107    <xsl:call-template name="write.text.chunk">
108      <xsl:with-param name="filename" select="$filename"/>
109      <xsl:with-param name="content">
110        <xsl:call-template name="source.print.header">
111          <xsl:with-param name="prefix" select="'//'"/>
112        </xsl:call-template>
113        <!-- Source code -->
114        <xsl:apply-templates mode="testsuite.generate"/>
115      </xsl:with-param>
116    </xsl:call-template>
117  </xsl:template>
118
119  <xsl:template match="snippet" mode="testsuite.generate">
120    <xsl:variable name="snippet-name" select="@name"/>
121    <xsl:value-of select="//programlisting[@name=$snippet-name]"/>
122  </xsl:template>
123
124  <!-- Prints a header to a source file containing the library name,
125       copyright information, license information, and a link to the Boost
126       web site. The text is output using the "prefix" parameter at the
127       beginning of each line (it should denote a single-line comment) and
128       will only print up to boost.source.columns characters per line
129       (including the prefix). -->
130  <xsl:template name="source.print.header">
131    <xsl:param name="prefix"/>
132
133    <!-- Library name -->
134    <xsl:value-of select="concat($prefix, ' ',
135                                 ancestor::library/attribute::name,
136                                 ' library')"/>
137    <xsl:text>&#10;</xsl:text>
138   
139    <!-- Copyrights -->
140    <xsl:apply-templates select="ancestor::library/libraryinfo/copyright"
141      mode="testsuite.generate">
142      <xsl:with-param name="prefix" select="$prefix"/>
143    </xsl:apply-templates>
144       
145    <!-- Legal notice -->
146    <xsl:apply-templates select="ancestor::library/libraryinfo/legalnotice"
147      mode="testsuite.generate">
148      <xsl:with-param name="prefix" select="$prefix"/>
149    </xsl:apply-templates>
150   
151    <xsl:text>&#10;&#10;</xsl:text>
152   
153    <!-- For more information... -->
154    <xsl:value-of 
155      select="concat($prefix,
156              ' For more information, see http://www.boost.org/')"/>
157    <xsl:text>&#10;</xsl:text>
158  </xsl:template>
159
160  <xsl:template match="copyright" mode="testsuite.generate">
161    <xsl:param name="prefix"/>
162
163    <xsl:text>&#10;</xsl:text>
164
165    <xsl:value-of select="concat($prefix, ' Copyright (C) ')"/>
166    <xsl:call-template name="copyright.years">
167      <xsl:with-param name="years" select="year"/>
168      <xsl:with-param name="print.ranges" select="1"/>
169      <xsl:with-param name="single.year.ranges" select="1"/>
170    </xsl:call-template>
171
172    <xsl:text> </xsl:text>
173
174    <xsl:apply-templates select="holder" mode="titlepage.mode"/>
175  </xsl:template>
176
177  <xsl:template match="legalnotice" mode="testsuite.generate">
178    <xsl:param name="prefix"/>
179
180    <xsl:variable name="text" select="normalize-space(.)"/>
181
182    <xsl:text>&#10;&#10;</xsl:text>
183    <xsl:value-of select="concat($prefix, ' ')"/>
184
185    <xsl:call-template name="source.print.legalnotice">
186      <xsl:with-param name="prefix" select="$prefix"/>
187      <xsl:with-param name="text" select="$text"/>
188      <xsl:with-param name="column" select="string-length($prefix) + 1"/>
189    </xsl:call-template>
190  </xsl:template>
191
192  <xsl:template name="source.print.legalnotice">
193    <xsl:param name="prefix"/>
194    <xsl:param name="text"/>
195    <xsl:param name="column"/>
196
197    <xsl:if test="contains($text, ' ') or string-length($text) &gt; 0">
198      <xsl:variable name="word">
199        <xsl:choose>
200          <xsl:when test="contains($text, ' ')">
201            <xsl:value-of select="substring-before($text, ' ')"/>
202          </xsl:when>
203          <xsl:otherwise>
204            <xsl:value-of select="$text"/>
205          </xsl:otherwise>
206        </xsl:choose>
207      </xsl:variable>
208
209      <xsl:variable name="rest" select="substring-after($text, ' ')"/>
210
211      <xsl:choose>
212        <xsl:when 
213          test="$column + string-length($word) &gt; $boost.source.columns">
214          <xsl:text>&#10;</xsl:text>
215          <xsl:value-of select="concat($prefix, ' ')"/>
216          <xsl:call-template name="source.print.legalnotice">
217            <xsl:with-param name="prefix" select="$prefix"/>
218            <xsl:with-param name="text" select="$text"/>
219            <xsl:with-param name="column" select="string-length($prefix) + 1"/>
220          </xsl:call-template>
221        </xsl:when>
222        <xsl:otherwise>
223          <xsl:value-of select="concat($word, ' ')"/>
224          <xsl:call-template name="source.print.legalnotice">
225            <xsl:with-param name="prefix" select="$prefix"/>
226            <xsl:with-param name="text" select="$rest"/>
227            <xsl:with-param name="column" 
228              select="$column + string-length($word) + 1"/>
229          </xsl:call-template>
230        </xsl:otherwise>
231      </xsl:choose>
232    </xsl:if>
233  </xsl:template>
234
235  <xsl:template match="*" mode="testsuite.generate"/>
236</xsl:stylesheet>
Note: See TracBrowser for help on using the repository browser.