# This module defines rules to apply an XSLT stylesheet to an XML file using the
# xsltproc driver, part of libxslt.
+import "class" : new ;
import common ;
import feature ;
+import generators ;
import modules ;
import os ;
import path ;
import regex ;
import sequence ;
+import toolset ;
+import virtual-target ;
-
-feature.feature xsl:param : : free ;
-feature.feature xsl:path : : free ;
+feature.feature "xsl:param" : : free ;
+feature.feature "xsl:path" : : free ;
feature.feature catalog : : free ;
}
}
-
-rule compute-xslt-flags ( target : properties * )
+class xsltproc-action : action
{
- # Raw flags.
- local flags = [ feature.get-values <flags> : $(properties) ] ;
-
- # Translate <xsl:param> into command line flags.
- for local param in [ feature.get-values <xsl:param> : $(properties) ]
+ rule adjust-properties ( property-set )
{
- local namevalue = [ regex.split $(param) "=" ] ;
- flags += --stringparam $(namevalue[1]) \"$(namevalue[2])\" ;
+ local s = [ $(self.targets[1]).creating-subvariant ] ;
+ if $(s)
+ {
+ return [ $(property-set).add-raw
+ [ $(s).implicit-includes "xsl:path" : XML ] ] ;
+ }
+ else
+ {
+ return $(property-set) ;
+ }
}
+}
- # Translate <xsl:path>.
- for local path in [ feature.get-values <xsl:path> : $(properties) ]
+class xsltproc-generator : generator
+{
+ rule action-class ( )
{
- flags += --path \"$(path:G=)\" ;
+ return xsltproc-action ;
}
+}
- # Take care of implicit dependencies.
- local other-deps ;
- for local dep in [ feature.get-values <implicit-dependency> : $(properties)
- ]
+rule register-generator ( id : source-types + : target-types + : requirements * )
+{
+ if ! $(id) in $(.known-rules)
{
- other-deps += [ $(dep:G=).creating-subvariant ] ;
+ .known-rules += $(id) ;
+ flags $(id) ;
}
+ generators.register [ new xsltproc-generator $(id) :
+ $(source-types) : $(target-types) : $(requirements) ] ;
+}
- local implicit-target-directories ;
- for local dep in [ sequence.unique $(other-deps) ]
- {
- implicit-target-directories += [ $(dep).all-target-directories ] ;
- }
+IMPORT xsltproc : register-generator : : generators.register-xslt ;
+
+rule flags ( rulename )
+{
+ toolset.uses-features $(rulename) : <xsl:param> <catalog> : unchecked ;
+ toolset.flags $(rulename) XSL-PATH : <xsl:path> : unchecked ;
+ toolset.flags $(rulename) FLAGS : <flags> : unchecked ;
+}
- for local dir in $(implicit-target-directories)
+rule compute-xslt-flags ( target : properties * )
+{
+ local flags ;
+ # Translate <xsl:param> into command line flags.
+ for local param in [ feature.get-values <xsl:param> : $(properties) ]
{
- flags += --path \"$(dir:T)\" ;
+ local namevalue = [ regex.split $(param) "=" ] ;
+ flags += --stringparam $(namevalue[1]) \"$(namevalue[2])\" ;
}
return $(flags) ;
$(dirname) : xslt-xsltproc-dir ] ;
}
+_ = " " ;
+
actions xslt-xsltproc.windows
{
- $(CATALOG) "$(NAME:E=xsltproc)" $(FLAGS) --xinclude -o "$(<)" "$(STYLESHEET:W)" "$(>:W)"
+ $(CATALOG) "$(NAME:E=xsltproc)" $(FLAGS) --path$(_)"$(XSL-PATH:W)" --xinclude -o "$(<)" "$(STYLESHEET:W)" "$(>:W)"
}
actions xslt-xsltproc bind STYLESHEET
{
- $(CATALOG) "$(NAME:E=xsltproc)" $(FLAGS) --xinclude -o "$(<)" "$(STYLESHEET:T)" "$(>:T)"
+ $(CATALOG) "$(NAME:E=xsltproc)" $(FLAGS) --path$(_)"$(XSL-PATH:T)" --xinclude -o "$(<)" "$(STYLESHEET:T)" "$(>:T)"
}
actions xslt-xsltproc-dir.windows bind STYLESHEET
{
- $(CATALOG) "$(NAME:E=xsltproc)" $(FLAGS) --xinclude -o "$(<:D)/" "$(STYLESHEET:W)" "$(>:W)"
+ $(CATALOG) "$(NAME:E=xsltproc)" $(FLAGS) --path$(_)"$(XSL-PATH:W)" --xinclude -o "$(<:D)/" "$(STYLESHEET:W)" "$(>:W)"
}
actions xslt-xsltproc-dir bind STYLESHEET
{
- $(CATALOG) "$(NAME:E=xsltproc)" $(FLAGS) --xinclude -o "$(<:D)/" "$(STYLESHEET:T)" "$(>:T)"
+ $(CATALOG) "$(NAME:E=xsltproc)" $(FLAGS) --path$(_)"$(XSL-PATH:T)" --xinclude -o "$(<:D)/" "$(STYLESHEET:T)" "$(>:T)"
}