From 6587f9cb97b28cf7960cb06d72eca848b0e30985 Mon Sep 17 00:00:00 2001 From: Rene Rivera Date: Mon, 24 Sep 2007 13:24:23 +0000 Subject: [PATCH] Make per target manifest files and a single global catalog files, so that one can have multiple boostbook targets in one project. [SVN r39506] --- v2/tools/boostbook.jam | 64 +++++++++++++++++++++++++++++++----------- 1 file changed, 47 insertions(+), 17 deletions(-) diff --git a/v2/tools/boostbook.jam b/v2/tools/boostbook.jam index 1d32e748f..5a54b49a2 100644 --- a/v2/tools/boostbook.jam +++ b/v2/tools/boostbook.jam @@ -1,6 +1,6 @@ # Copyright 2003, 2004, 2005 Dave Abrahams # Copyright 2003, 2004, 2005 Douglas Gregor -# Copyright 2005, 2006 Rene Rivera +# Copyright 2005, 2006, 2007 Rene Rivera # Copyright 2003, 2004, 2005 Vladimir Prus # Distributed under the Boost Software License, Version 1.0. # (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt) @@ -28,6 +28,11 @@ import build-system ; import xsltproc : xslt xslt-dir ; +# Make this module into a project. +project.initialize $(__name__) ; +project boostbook ; + + feature.feature format : html xhtml htmlhelp onehtml man pdf ps docbook fo tests : incidental implicit composite propagated ; @@ -254,11 +259,42 @@ rule generate-xml-catalog ( target : sources * : properties * ) print.text "" ; } +rule xml-catalog ( ) +{ + if ! $(.xml-catalog) + { + # The target is created as part of the root project. But ideally + # it would be created as part of the boostbook project. This is not + # current possible as such global projects don't inherit things like + # the build directory. + + # Find the root project. + local root-project = [ project.current ] ; + root-project = [ $(root-project).project-module ] ; + while + [ project.attribute $(root-project) parent-module ] && + [ project.attribute $(root-project) parent-module ] != user-config + { + root-project = [ project.attribute $(root-project) parent-module ] ; + } + .xml-catalog = [ new file-target boostbook_catalog + : XML + : [ project.target $(root-project) ] + : [ new action : boostbook.generate-xml-catalog ] + : + ] ; + .xml-catalog-file = [ $(.xml-catalog).path ] [ $(.xml-catalog).name ] ; + .xml-catalog-file = $(.xml-catalog-file:J=/) ; + } + return $(.xml-catalog) $(.xml-catalog-file) ; +} + class boostbook-generator : generator { import feature ; import virtual-target ; import generators ; + import boostbook ; rule __init__ ( * : * ) @@ -268,21 +304,13 @@ class boostbook-generator : generator rule run ( project name ? : property-set : sources * : multiple ? ) { - # Generate the catalog - local catalog = [ new file-target catalog - : XML - : $(project) - : [ new action - : boostbook.generate-xml-catalog - : $(property-set) ] ] ; - - # catalog = [ virtual-target.register $(catalog) ] ; + # Generate the catalog, but only once... + local global-catalog = [ boostbook.xml-catalog ] ; + local catalog = $(global-catalog[1]) ; + local catalog-file = $(global-catalog[2]) ; # Add the catalog to the property set - local catalog-path = [ $(catalog).path ] ; - property-set = [ $(property-set).add-raw $(catalog-path)/catalog.xml ] ; - - # local targets = $(catalog) ; + property-set = [ $(property-set).add-raw $(catalog-file) ] ; local type = none ; local manifest ; @@ -302,7 +330,6 @@ class boostbook-generator : generator case htmlhelp : { type = HTMLHELP ; - #manifest = HTML.manifest ; } case onehtml : type = HTML ; @@ -329,8 +356,11 @@ class boostbook-generator : generator $(base-target).depends $(catalog) ; # Generate HTML/PDF/PS from DOCBOOK. - local target = [ generators.construct $(project) $(manifest) - : $(type) : $(property-set) : $(base-target) ] ; + local target = [ generators.construct $(project) $(name)_$(manifest) + : $(type) + : [ $(property-set).add-raw + manifest=$(name)_$(manifest) ] + : $(base-target) ] ; local name = [ $(property-set).get ] ; name ?= $(format) ; $(target[2]).set-path $(name) ;