diff --git a/src/tools/boostbook.jam b/src/tools/boostbook.jam index 60fa4b2e8..85c8cafac 100644 --- a/src/tools/boostbook.jam +++ b/src/tools/boostbook.jam @@ -29,12 +29,13 @@ feature.feature format : html onehtml man pdf ps docbook fo tests type.register DTDXML : dtdxml ; type.register XML : xml : : main ; -type.register DOCBOOK : docbook ; +type.register BOOSTBOOK : boostbook : XML ; +type.register DOCBOOK : docbook : XML ; type.register HTML : html ; -type.register FO : fo ; +type.register FO : fo : XML ; type.register PDF : pdf ; type.register PS : ps ; -type.register XSLT : xsl ; +type.register XSLT : xsl : XML ; type.register HTMLDIR ; type.register MANPAGES ; type.register TESTS : tests ; @@ -79,20 +80,18 @@ rule init ( docbook-xsl-dir ? : docbook-dtd-dir ? ) .docbook-dtd-dir = [ path.make $(docbook-dtd-dir) ] ; } - local search-dirs ; - if [ modules.peek : BOOST_ROOT ] { - local boost-root = [ path.make [ modules.peek : BOOST_ROOT ] ] ; - search-dirs = [ path.join $(boost-root) tools boostbook ] ; - } + local boost-root = [ path.make [ modules.peek : BOOST_ROOT ] ] ; local boost-build-root = [ sequence.transform path.make : [ modules.peek : BOOST_BUILD_PATH ] - ] ; - search-dirs += $(boost-build-root)/../boostbook ; + ] ; + local search-dirs = [ path.join $(boost-root) tools boostbook ] + $(boost-build-root)/../boostbook ; local native-search-dirs = [ sequence.transform path.native : $(search-dirs) ] ; local boostbook-xsl-dir = [ GLOB $(native-search-dirs) : xsl ] ; local boostbook-dtd-dir = [ GLOB $(native-search-dirs) : dtd ] ; + .boostbook-xsl-dir = [ path.make $(boostbook-xsl-dir[1]) ] ; .boostbook-dtd-dir = [ path.make $(boostbook-dtd-dir[1]) ] ; if ! $(.boostbook-xsl-dir) || ! $(.boostbook-dtd-dir) diff --git a/src/tools/doxygen.jam b/src/tools/doxygen.jam index 82a069809..2babe9cab 100644 --- a/src/tools/doxygen.jam +++ b/src/tools/doxygen.jam @@ -5,9 +5,7 @@ # to its suitability for any purpose. # This module defines rules to handle generation of BoostBook XML -# from Doxygen XML output. At the moment, this requires a special -# version of Doxygen that can output a single XML file instead of a -# set of XML files. +# from Doxygen XML output. import "class" : new ; import targets ; @@ -17,12 +15,19 @@ import generators ; import boostbook ; import type ; import path ; +import print ; +import regex ; -feature.feature recursive : off on ; -feature.feature pattern : : free ; -type.register DOXYGEN_XML : doxygen ; # Doxygen XML output +feature.feature doxygen:param : : free ; -generators.register-standard doxygen.xml-to-boostbook : DOXYGEN_XML : XML ; +type.register DOXYFILE : doxyfile ; # Doxygen input file +type.register DOXYGEN_XML_MULTIFILE : : XML ; # Doxygen XML multi-file output +type.register DOXYGEN_XML : doxygen : XML ; # Doxygen XML output + +generators.register-standard doxygen.headers-to-doxyfile : H HPP : DOXYFILE ; +generators.register-standard doxygen.run : DOXYFILE : DOXYGEN_XML_MULTIFILE ; +generators.register-standard doxygen.collect : DOXYGEN_XML_MULTIFILE : DOXYGEN_XML ; +generators.register-standard doxygen.xml-to-boostbook : DOXYGEN_XML : BOOSTBOOK ; # Initialize the Doxygen module. Parameters are: # name: the name of the 'doxygen' executable. If not specified, the name @@ -45,84 +50,92 @@ rule name ( ) return $(.doxygen) ; } -rule extract-xml ( target : sources * : properties * ) +# Runs Doxygen on the given Doxygen configuration file (the source) to +# generate Doxygen XML (in multiple files). The output is dumped +# according to the settings in the Doxygen configuration file, not +# according to the target! Because of this, we essentially "touch" the +# target file, in effect making it look like we've really written +# something useful to it. Anyone that uses this action must deal with +# this behavior. +actions doxygen-action { - local recursive = [ feature.get-values : $(properties) ] ; + "$(NAME:E=doxygen)" $(>) ; + echo "Stamped" > "$(<)" +} - if $(recursive) = "on" +# Generates a doxygen configuration file (doxyfile) given a set of C++ +# sources anda property list that may contain +# features. +rule headers-to-doxyfile ( target : sources * : properties * ) +{ + local text "# Generated by Boost.Build version 2" ; + + # Translate into command line flags. + for local param in [ feature.get-values : $(properties) ] { - RECURSIVE on $(target) = YES ; - } - else - { - RECURSIVE on $(target) = NO ; + local namevalue = [ regex.split $(param) "=" ] ; + text += "$(namevalue[1])=$(namevalue[2])" ; } - local index-target = $(target:B="xml/index":S=".xml") ; - PATTERNS on $(index-target) = - [ feature.get-values : $(properties) ] ; - NAME on $(index-target) = [ name ] ; - doxygen-action $(index-target) : $(>) ; + text += "GENERATE_HTML = NO" ; + text += "GENERATE_LATEX = NO" ; + text += "GENERATE_XML = YES" ; + text += "INPUT = $(sources:G=) " ; + print.output $(target) plain ; + print.text $(text) : true ; +} - local xsl-dir = [ boostbook.xsl-dir ] ; - local pwd = [ path.pwd ] ; - local collect-path = $(pwd)/$(index-target:G=:P) ; - DEPENDS $(target) : $(index-target) ; - xslt $(target) : $(index-target) "$(xsl-dir)/doxygen/collect.xsl" +# Run Doxygen. See doxygen-action for a description of the strange +# properties of this rule +rule run ( target : source : properties * ) +{ + doxygen-action $(target) : $(source) ; +} + +# Collect the set of Doxygen XML files into a single XML source file +# that can be handled by an XSLT processor. The source is completely +# ignored (see doxygen-action), because this action picks up the +# Doxygen XML index file xml/index.xml. This is because we can't teach +# Doxygen to act like a NORMAL program and take a "-o output.xml" +# argument (grrrr). The target of the collection will be a single +# Doxygen XML file. +rule collect ( target : source : properties * ) +{ + local collect-xsl-dir = [ path.native + [ path.join [ boostbook.xsl-dir ] doxygen collect ] + ] ; + local collect-path = [ path.join [ path.pwd ] xml ] ; + local real-source = [ path.native xml/index.xml ] ; + NOTFILE $(real-source) ; + xslt $(target) : $(real-source) $(collect-xsl-dir:S=.xsl) : doxygen.xml.path=$(collect-path) ; } -actions doxygen-action -{ - "$(NAME:E=doxygen)" -g doxyfile - echo "GENERATE_HTML = NO" >> doxyfile - echo "GENERATE_LATEX = NO" >> doxyfile - echo "GENERATE_XML = YES" >> doxyfile - echo "INPUT = $(>) " >> doxyfile - echo "RECURSIVE = $(RECURSIVE) " >> doxyfile - echo "FILE_PATTERNS = $(PATTERNS) " >> doxyfile - "$(NAME:E=doxygen)" doxyfile ; -} - +# Translate Doxygen XML into BoostBook rule xml-to-boostbook ( target : source : properties * ) { local xsl-dir = [ boostbook.xsl-dir ] ; + local d2b-xsl = [ path.native + [ path.join [ boostbook.xsl-dir ] doxygen + doxygen2boostbook.xsl ] ] ; - xslt $(target) : $(source) "$(xsl-dir)/doxygen/doxygen2boostbook.xsl" - : $(properties) - ; -} - -class doxygen-xml-target-class : basic-target -{ - rule __init__ ( name : project : sources * : requirements * - : default-build * ) - { - basic-target.__init__ $(name) : $(project) : $(sources) : $(requirements) - : $(default-build) ; - } - - - rule construct ( source-targets * : property-set ) - { - local target = - [ new file-target $(self.name) : DOXYGEN_XML : $(self.project) ] ; - local a = [ new action $(target) : $(source-targets) : doxygen.extract-xml - : $(property-set) ] ; - $(target).action $(a) ; - - return [ virtual-target.register $(target) ] ; - } + xslt $(target) : $(source) $(d2b-xsl) : $(properties) ; } +# User-level rule to generate BoostBook XML from a set of headers via Doxygen. rule doxygen ( target-name : sources * : requirements * : default-build * ) { local project = [ CALLER_MODULE ] ; - targets.main-target-alternative - [ new doxygen-xml-target-class $(target-name) : $(project) : $(sources) - : [ targets.main-target-requirements $(requirements) : $(project) ] + + local doxyfile = [ + new typed-target $(target-name) : $(project) : BOOSTBOOK + : [ targets.main-target-sources $(sources) : $(target-name) ] + : [ targets.main-target-requirements $(requirements) : $(project) ] : [ targets.main-target-default-build $(default-build) : $(project) ] ] ; + + targets.main-target-alternative $(doxyfile) ; + } IMPORT $(__name__) : doxygen : : doxygen ; \ No newline at end of file