diff --git a/src/tools/boostbook.jam b/src/tools/boostbook.jam index b7f1965d9..71d6bdd2b 100644 --- a/src/tools/boostbook.jam +++ b/src/tools/boostbook.jam @@ -108,7 +108,53 @@ rule init ( # The same about Jamfile main target rules. IMPORT $(__name__) : boostbook : : boostbook ; - } + } + else + { + if $(docbook-xsl-dir) + { + modify-config ; + .docbook-xsl-dir = [ path.make $(docbook-xsl-dir) ] ; + check-docbook-xsl-dir ; + } + if $(docbook-dtd-dir) + { + modify-config ; + .docbook-dtd-dir = [ path.make $(docbook-dtd-dir) ] ; + check-docbook-dtd-dir ; + } + if $(boostbook-dir) + { + modify-config ; + check-boostbook-dir $(boostbook-dir) ; + local boostbook-xsl-dir = [ path.glob $(boostbook-dir) : xsl ] ; + local boostbook-dtd-dir = [ path.glob $(boostbook-dir) : dtd ] ; + .boostbook-xsl-dir = $(boostbook-xsl-dir[1]) ; + .boostbook-dtd-dir = $(boostbook-dtd-dir[1]) ; + check-boostbook-xsl-dir ; + check-boostbook-dtd-dir ; + } + } +} + +rule lock-config ( ) +{ + if ! $(.initialized) + { + errors.user-error "BoostBook has not been configured." ; + } + if ! $(.config-locked) + { + .config-locked = true ; + } +} + +rule modify-config ( ) +{ + if $(.config-locked) + { + errors.user-error "BoostBook configuration cannot be changed after it has been used." ; + } } rule find-boost-in-registry ( keys * ) @@ -127,6 +173,88 @@ rule find-boost-in-registry ( keys * ) return $(boost-root) ; } +rule check-docbook-xsl-dir ( ) +{ + if $(.docbook-xsl-dir) + { + if ! [ path.glob $(.docbook-xsl-dir) : common/common.xsl ] + { + errors.user-error "BoostBook: could not find docbook XSL stylesheets in:" [ path.native $(.docbook-xsl-dir) ] ; + } + else + { + if --debug-configuration in [ modules.peek : ARGV ] + { + ECHO "notice: BoostBook: found docbook XSL stylesheets in:" [ path.native $(.docbook-xsl-dir) ] ; + } + } + } +} + +rule check-docbook-dtd-dir ( ) +{ + if $(.docbook-dtd-dir) + { + if ! [ path.glob $(.docbook-dtd-dir) : docbookx.dtd ] + { + errors.user-error "error: BoostBook: could not find docbook DTD in:" [ path.native $(.docbook-dtd-dir) ] ; + } + else + { + if --debug-configuration in [ modules.peek : ARGV ] + { + ECHO "notice: BoostBook: found docbook DTD in:" [ path.native $(.docbook-dtd-dir) ] ; + } + } + } +} + +rule check-boostbook-xsl-dir ( ) +{ + if ! $(.boostbook-xsl-dir) + { + errors.user-error "error: BoostBook: could not find boostbook XSL stylesheets." ; + } + else if ! [ path.glob $(.boostbook-xsl-dir) : docbook.xsl ] + { + errors.user-error "error: BoostBook: could not find docbook XSL stylesheets in:" [ path.native $(.boostbook-xsl-dir) ] ; + } + else + { + if --debug-configuration in [ modules.peek : ARGV ] + { + ECHO "notice: BoostBook: found boostbook XSL stylesheets in:" [ path.native $(.boostbook-xsl-dir) ] ; + } + } +} + +rule check-boostbook-dtd-dir ( ) +{ + if ! $(.boostbook-dtd-dir) + { + errors.user-error "error: BoostBook: could not find boostbook DTD." ; + } + else if ! [ path.glob $(.boostbook-dtd-dir) : boostbook.dtd ] + { + errors.user-error "error: BoostBook: could not find boostbook DTD in:" [ path.native $(.boostbook-dtd-dir) ] ; + } + else + { + if --debug-configuration in [ modules.peek : ARGV ] + { + ECHO "notice: BoostBook: found boostbook DTD in:" [ path.native $(.boostbook-dtd-dir) ] ; + } + } +} + +rule check-boostbook-dir ( boostbook-dir ? ) +{ + if $(boostbook-dir) && ! [ path.glob $(boostbook-dir) : xsl ] + { + errors.user-error "error: BoostBook: could not find boostbook in:" [ path.native $(boostbook-dir) ] ; + } +} + rule find-tools ( docbook-xsl-dir ? : docbook-dtd-dir ? : boostbook-dir ? ) { docbook-xsl-dir ?= [ modules.peek : DOCBOOK_XSL_DIR ] ; @@ -234,101 +362,89 @@ rule find-tools ( docbook-xsl-dir ? : docbook-dtd-dir ? : boostbook-dir ? ) .boostbook-xsl-dir = $(boostbook-xsl-dir[1]) ; .boostbook-dtd-dir = $(boostbook-dtd-dir[1]) ; - if --debug-configuration in [ modules.peek : ARGV ] - { - if $(.docbook-xsl-dir) - { - ECHO "notice: Boost.Book: found docbook XSL stylesheets in:" [ path.native $(.docbook-xsl-dir) ] ; - } - if $(.docbook-dtd-dir) - { - ECHO "notice: Boost.Book: found docbook DTD in:" [ path.native $(.docbook-dtd-dir) ] ; - } - if $(.boostbook-xsl-dir) - { - ECHO "notice: Boost.Book: found boostbook XSL stylesheets in:" [ path.native $(.boostbook-xsl-dir) ] ; - } - if $(.boostbook-dtd-dir) - { - ECHO "notice: Boost.Book: found boostbook DTD in:" [ path.native $(.boostbook-dtd-dir) ] ; - } - } - - if ! $(.boostbook-xsl-dir) || ! $(.boostbook-dtd-dir) - { - errors.warning - "couldn't find BoostBook xsl or dtd directories;" - : please set \"BOOST_ROOT\" variable to the root directory of - your boost installation. Searched in: - : $(boostbook-dir:J=" -") ; - } + check-boostbook-dir $(boostbook-dir) ; + check-docbook-xsl-dir ; + check-docbook-dtd-dir ; + check-boostbook-xsl-dir ; + check-boostbook-dtd-dir ; } rule xsl-dir { + lock-config ; return $(.boostbook-xsl-dir) ; } rule dtd-dir { + lock-config ; return $(.boostbook-dtd-dir) ; } rule docbook-xsl-dir { + lock-config ; return $(.docbook-xsl-dir) ; } rule docbook-dtd-dir { + lock-config ; return $(.docbook-dtd-dir) ; } rule dtdxml-to-boostbook ( target : source : properties * ) { + lock-config ; xslt $(target) : $(source) "$(.boostbook-xsl-dir)/dtd/dtd2boostbook.xsl" : $(properties) ; } rule boostbook-to-docbook ( target : source : properties * ) { + lock-config ; local stylesheet = [ path.native $(.boostbook-xsl-dir)/docbook.xsl ] ; xslt $(target) : $(source) $(stylesheet) : $(properties) ; } rule docbook-to-onehtml ( target : source : properties * ) { + lock-config ; local stylesheet = [ path.native $(.boostbook-xsl-dir)/html-single.xsl ] ; xslt $(target) : $(source) $(stylesheet) : $(properties) ; } rule docbook-to-htmldir ( target : source : properties * ) { + lock-config ; local stylesheet = [ path.native $(.boostbook-xsl-dir)/html.xsl ] ; xslt-dir $(target) : $(source) $(stylesheet) : $(properties) : html ; } rule docbook-to-xhtmldir ( target : source : properties * ) { + lock-config ; local stylesheet = [ path.native $(.boostbook-xsl-dir)/xhtml.xsl ] ; xslt-dir $(target) : $(source) $(stylesheet) : $(properties) : xhtml ; } rule docbook-to-htmlhelp ( target : source : properties * ) { + lock-config ; local stylesheet = [ path.native $(.boostbook-xsl-dir)/html-help.xsl ] ; xslt-dir $(target) : $(source) $(stylesheet) : $(properties) : htmlhelp ; } rule docbook-to-manpages ( target : source : properties * ) { + lock-config ; local stylesheet = [ path.native $(.boostbook-xsl-dir)/manpages.xsl ] ; xslt-dir $(target) : $(source) $(stylesheet) : $(properties) : man ; } rule docbook-to-fo ( target : source : properties * ) { + lock-config ; local stylesheet = [ path.native $(.boostbook-xsl-dir)/fo.xsl ] ; xslt $(target) : $(source) $(stylesheet) : $(properties) ; } @@ -598,6 +714,7 @@ type.set-scanner XML : xinclude-scanner ; rule boostbook-to-tests ( target : source : properties * ) { + lock-config ; local boost_root = [ modules.peek : BOOST_ROOT ] ; local native-path = [ path.native [ path.join $(.boostbook-xsl-dir) testing Jamfile ] ] ;