]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/tools/build/src/tools/xsltproc.jam
bump version to 12.2.2-pve1
[ceph.git] / ceph / src / boost / tools / build / src / tools / xsltproc.jam
CommitLineData
7c673cae
FG
1# Copyright (C) 2003 Doug Gregor. Permission to copy, use, modify, sell and
2# distribute this software is granted provided this copyright notice appears in
3# all copies. This software is provided "as is" without express or implied
4# warranty, and with no claim as to its suitability for any purpose.
5
6# This module defines rules to apply an XSLT stylesheet to an XML file using the
7# xsltproc driver, part of libxslt.
8
9import common ;
10import feature ;
11import modules ;
12import os ;
13import path ;
14import regex ;
15import sequence ;
16
17
18feature.feature xsl:param : : free ;
19feature.feature xsl:path : : free ;
20feature.feature catalog : : free ;
21
22
23# Initialize xsltproc support. The parameters are:
24# xsltproc: The xsltproc executable
25#
26rule init ( xsltproc ? )
27{
28 if $(xsltproc)
29 {
30 modify-config ;
31 .xsltproc = $(xsltproc) ;
32 check-xsltproc ;
33 }
34}
35
36
37rule freeze-config ( )
38{
39 if ! $(.config-frozen)
40 {
41 .config-frozen = true ;
42 .xsltproc ?= [ modules.peek : XSLTPROC ] ;
43 .xsltproc ?= xsltproc ;
44 check-xsltproc ;
45 .is-cygwin = [ .is-cygwin $(.xsltproc) ] ;
46 }
47}
48
49
50rule modify-config ( )
51{
52 if $(.config-frozen)
53 {
54 import errors ;
55 errors.user-error
56 "xsltproc: Cannot change xsltproc command after it has been used." ;
57 }
58}
59
60
61rule check-xsltproc ( )
62{
63 if $(.xsltproc)
64 {
65 local status = [ SHELL "\"$(.xsltproc)\" -V" : no-output : exit-status ]
66 ;
67 if $(status[2]) != 0
68 {
69 import errors ;
70 errors.user-error "xsltproc: Could not run \"$(.xsltproc)\" -V." ;
71 }
72 }
73}
74
75
76# Returns a non-empty string if a cygwin xsltproc binary was specified.
77#
78rule is-cygwin ( )
79{
80 freeze-config ;
81 return $(.is-cygwin) ;
82}
83
84
85rule .is-cygwin ( xsltproc )
86{
87 if [ os.on-windows ]
88 {
89 local file = [ path.make [ modules.binding $(__name__) ] ] ;
90 local dir = [ path.native [ path.join [ path.parent $(file) ] xsltproc ]
91 ] ;
92 if [ os.name ] = CYGWIN
93 {
94 dir = $(dir:W) ;
95 }
96 local command =
97 "\"$(xsltproc)\" \"$(dir)\\test.xsl\" \"$(dir)\\test.xml\" 2>&1" ;
98 local status = [ SHELL $(command) : no-output : exit-status ] ;
99 if $(status[2]) != "0"
100 {
101 return true ;
102 }
103 }
104}
105
106
107rule compute-xslt-flags ( target : properties * )
108{
109 # Raw flags.
110 local flags = [ feature.get-values <flags> : $(properties) ] ;
111
112 # Translate <xsl:param> into command line flags.
113 for local param in [ feature.get-values <xsl:param> : $(properties) ]
114 {
115 local namevalue = [ regex.split $(param) "=" ] ;
116 flags += --stringparam $(namevalue[1]) \"$(namevalue[2])\" ;
117 }
118
119 # Translate <xsl:path>.
120 for local path in [ feature.get-values <xsl:path> : $(properties) ]
121 {
122 flags += --path \"$(path:G=)\" ;
123 }
124
125 # Take care of implicit dependencies.
126 local other-deps ;
127 for local dep in [ feature.get-values <implicit-dependency> : $(properties)
128 ]
129 {
130 other-deps += [ $(dep:G=).creating-subvariant ] ;
131 }
132
133 local implicit-target-directories ;
134 for local dep in [ sequence.unique $(other-deps) ]
135 {
136 implicit-target-directories += [ $(dep).all-target-directories ] ;
137 }
138
139 for local dir in $(implicit-target-directories)
140 {
141 flags += --path \"$(dir:T)\" ;
142 }
143
144 return $(flags) ;
145}
146
147
148local rule .xsltproc ( target : source stylesheet : properties * : dirname ? :
149 action )
150{
151 freeze-config ;
152 STYLESHEET on $(target) = $(stylesheet) ;
153 FLAGS on $(target) += [ compute-xslt-flags $(target) : $(properties) ] ;
154 NAME on $(target) = $(.xsltproc) ;
155
156 for local catalog in [ feature.get-values <catalog> : $(properties) ]
157 {
158 CATALOG = [ common.variable-setting-command XML_CATALOG_FILES :
159 $(catalog:T) ] ;
160 }
161
162 if [ os.on-windows ] && ! [ is-cygwin ]
163 {
164 action = $(action).windows ;
165 }
166
167 $(action) $(target) : $(source) ;
168}
169
170
171rule xslt ( target : source stylesheet : properties * )
172{
173 return [ .xsltproc $(target) : $(source) $(stylesheet) : $(properties) : :
174 xslt-xsltproc ] ;
175}
176
177
178rule xslt-dir ( target : source stylesheet : properties * : dirname )
179{
180 return [ .xsltproc $(target) : $(source) $(stylesheet) : $(properties) :
181 $(dirname) : xslt-xsltproc-dir ] ;
182}
183
184actions xslt-xsltproc.windows
185{
186 $(CATALOG) "$(NAME:E=xsltproc)" $(FLAGS) --xinclude -o "$(<)" "$(STYLESHEET:W)" "$(>:W)"
187}
188
189
190actions xslt-xsltproc bind STYLESHEET
191{
192 $(CATALOG) "$(NAME:E=xsltproc)" $(FLAGS) --xinclude -o "$(<)" "$(STYLESHEET:T)" "$(>:T)"
193}
194
195
196actions xslt-xsltproc-dir.windows bind STYLESHEET
197{
198 $(CATALOG) "$(NAME:E=xsltproc)" $(FLAGS) --xinclude -o "$(<:D)/" "$(STYLESHEET:W)" "$(>:W)"
199}
200
201
202actions xslt-xsltproc-dir bind STYLESHEET
203{
204 $(CATALOG) "$(NAME:E=xsltproc)" $(FLAGS) --xinclude -o "$(<:D)/" "$(STYLESHEET:T)" "$(>:T)"
205}