mirror of
https://github.com/boostorg/build.git
synced 2026-02-01 08:22:15 +00:00
virtual-target.jam.
- Added the missing explicit imports, now that we don't dump
everything into the global module with qualification
- stopped using the feature-space hack for temporary testing states of
the feature module. Instead we move its global variable definitions
to a temporary module.
- the way feature.action was invoking the rule it was being passed was
evil. Now you pass (even local) rules without qualification and
they are invoked in the source module context.
- module __test__ rules are always executed in a separate module, so
that their import dependencies can be separated from those of the
module being tested.
- better reporting of circular module-loading dependencies
implemented.
- minor changes:
property-set.jam: moved .empty initialization to avert circular
load dependency .
symlink.jam: fixed global variable naming.
[SVN r18407]
360 lines
11 KiB
Plaintext
360 lines
11 KiB
Plaintext
# Copyright (C) 2003 Doug Gregor. Permission to copy, use, modify,
|
|
# sell and distribute this software is granted provided this
|
|
# copyright notice appears in all copies. This software is provided
|
|
# "as is" without express or implied warranty, and with no claim as
|
|
# to its suitability for any purpose.
|
|
|
|
# This module defines rules to handle generation of documentation
|
|
# from BoostBook sources.
|
|
|
|
import class : class new ;
|
|
import common ;
|
|
import errors ;
|
|
import targets ;
|
|
import feature ;
|
|
import generators ;
|
|
import print ;
|
|
import property ;
|
|
import property-set ;
|
|
import regex ;
|
|
import scanner ;
|
|
import make ;
|
|
import type ;
|
|
|
|
feature.feature xsl:param : : free ;
|
|
feature.feature format : html onehtml man pdf ps docbook fo tests
|
|
: incidental implicit composite ;
|
|
|
|
type.register DTDXML : dtdxml ;
|
|
type.register XML : xml ;
|
|
type.register DOCBOOK : docbook ;
|
|
type.register HTML : html ;
|
|
type.register FO : fo ;
|
|
type.register PDF : pdf ;
|
|
type.register PS : ps ;
|
|
type.register XSLT : xsl ;
|
|
type.register HTMLDIR ;
|
|
type.register MANPAGES ;
|
|
type.register TESTS : tests ;
|
|
|
|
generators.register-standard boostbook.dtdxml-to-boostbook : DTDXML : XML ;
|
|
generators.register-standard boostbook.boostbook-to-docbook : XML : DOCBOOK ;
|
|
generators.register-standard boostbook.boostbook-to-tests : XML : TESTS ;
|
|
generators.register-standard boostbook.docbook-to-onehtml : DOCBOOK : HTML ;
|
|
generators.register-standard boostbook.docbook-to-htmldir : DOCBOOK : HTMLDIR ;
|
|
generators.register-standard boostbook.docbook-to-manpages : DOCBOOK : MANPAGES ;
|
|
generators.register-standard boostbook.docbook-to-fo : DOCBOOK : FO ;
|
|
|
|
# Initialize BoostBook support. The parameters are:
|
|
# docbook-xsl-dir: The DocBook XSL stylesheet directory. If not provided,
|
|
# we use DOCBOOK_XSL_DIR from the environment (if available). Otherwise,
|
|
# we let the XML processor load the stylesheets remotely.
|
|
#
|
|
# docbook-dtd-dir: The DocBook DTD directory. If not provided, we use
|
|
# DOCBOOK_DTD_DIR From the environment (if available). Otherwise, we let
|
|
# the XML processor load the DTD remotely.
|
|
rule init ( docbook-xsl-dir ? : docbook-dtd-dir ? )
|
|
{
|
|
if ! $(docbook-xsl-dir)
|
|
{
|
|
docbook-xsl-dir = [ modules.peek : DOCBOOK_XSL_DIR ] ;
|
|
}
|
|
|
|
if ! $(docbook-dtd-dir)
|
|
{
|
|
docbook-dtd-dir = [ modules.peek : DOCBOOK_DTD_DIR ] ;
|
|
}
|
|
|
|
if ! $(.initialized)
|
|
{
|
|
$(.initialized) = true ;
|
|
if $(docbook-xsl-dir)
|
|
{
|
|
.docbook-xsl-dir = [ path.make $(docbook-xsl-dir) ] ;
|
|
}
|
|
if $(docbook-dtd-dir)
|
|
{
|
|
.docbook-dtd-dir = [ path.make $(docbook-dtd-dir) ] ;
|
|
}
|
|
local boost-root = [ modules.peek : BOOST_ROOT ] ;
|
|
if $(boost-root)
|
|
{
|
|
local boost-root-path = [ path.make $(boost-root) ] ;
|
|
.boostbook-xsl-dir = [ path.join $(boost-root-path) tools boostbook xsl/ ] ;
|
|
.boostbook-dtd-dir = [ path.join $(boost-root-path) tools boostbook dtd/ ] ;
|
|
}
|
|
}
|
|
}
|
|
|
|
rule xsl-dir
|
|
{
|
|
return $(.boostbook-xsl-dir) ;
|
|
}
|
|
|
|
rule dtd-dir
|
|
{
|
|
return $(.boostbook-dtd-dir) ;
|
|
}
|
|
|
|
rule docbook-xsl-dir
|
|
{
|
|
return $(.docbook-xsl-dir) ;
|
|
}
|
|
|
|
rule docbook-dtd-dir
|
|
{
|
|
return $(.docbook-dtd-dir) ;
|
|
}
|
|
|
|
rule dtdxml-to-boostbook ( target : source : properties * )
|
|
{
|
|
xslt $(target) : $(source) "$(.boostbook-xsl-dir)/dtd/dtd2boostbook.xsl"
|
|
: $(properties) ;
|
|
}
|
|
|
|
rule boostbook-to-docbook ( target : source : properties * )
|
|
{
|
|
local native-path = [ path.native $(.boostbook-xsl-dir) ] ;
|
|
local stylesheet = $(native-path:B=docbook:S=.xsl) ;
|
|
xslt $(target) : $(source) $(stylesheet) : $(properties) ;
|
|
}
|
|
|
|
rule docbook-to-onehtml ( target : source : properties * )
|
|
{
|
|
local native-path = [ path.native $(.boostbook-xsl-dir) ] ;
|
|
local stylesheet = $(native-path:B=html-single:S=.xsl) ;
|
|
xslt $(target) : $(source) $(stylesheet) : $(properties) ;
|
|
}
|
|
|
|
rule docbook-to-htmldir ( target : source : properties * )
|
|
{
|
|
local native-path = [ path.native $(.boostbook-xsl-dir) ] ;
|
|
local stylesheet = $(native-path:B=html:S=.xsl) ;
|
|
xslt-dir $(target) : $(source) $(stylesheet) : $(properties) : html ;
|
|
}
|
|
|
|
rule docbook-to-manpages ( target : source : properties * )
|
|
{
|
|
local native-path = [ path.native $(.boostbook-xsl-dir) ] ;
|
|
local stylesheet = $(native-path:B=manpages:S=.xsl) ;
|
|
xslt-dir $(target) : $(source) $(stylesheet) : $(properties) : man ;
|
|
}
|
|
|
|
rule docbook-to-fo ( target : source : properties * )
|
|
{
|
|
local native-path = [ path.native $(.boostbook-xsl-dir) ] ;
|
|
local stylesheet = $(native-path:B=fo:S=.xsl) ;
|
|
xslt $(target) : $(source) $(stylesheet) : $(properties) ;
|
|
}
|
|
|
|
rule xml-catalog-action ( target : property-set ? : catalog-entries * )
|
|
{
|
|
action.__init__ $(target) : : generate-xml-catalog : $(property-set) ;
|
|
|
|
rule actualize ( )
|
|
{
|
|
if ! $(self.actualized)
|
|
{
|
|
self.actualized = true ;
|
|
local actual = [ $(self.targets[1]).actualize ] ;
|
|
local text = "<?xml version=\"1.0\"?>" ;
|
|
|
|
text += "<!DOCTYPE catalog " ;
|
|
text += " PUBLIC \"-//OASIS/DTD Entity Resolution XML Catalog V1.0//EN\"" ;
|
|
text += " \"http://www.oasis-open.org/committees/entity/release/1.0/catalog.dtd\">" ;
|
|
text += "<catalog xmlns=\"urn:oasis:names:tc:entity:xmlns:xml:catalog\">" ;
|
|
|
|
# BoostBook DTD catalog entry
|
|
local boostbook-dtd-dir = [ boostbook.dtd-dir ] ;
|
|
|
|
text += " <rewriteURI uriStartString=\"http://www.boost.org/tools/boostbook/dtd/\" rewritePrefix=\"file://$(boostbook-dtd-dir)/\"/>" ;
|
|
|
|
local docbook-xsl-dir = [ boostbook.docbook-xsl-dir ] ;
|
|
if ! $(docbook-xsl-dir)
|
|
{
|
|
ECHO "BoostBook warning: no DocBook XSL directory specified." ;
|
|
ECHO " If you have the DocBook XSL stylesheets installed, please " ;
|
|
ECHO " set DOCBOOK_XSL_DIR to the stylesheet directory on either " ;
|
|
ECHO " the command line (via -sDOCBOOK_XSL_DIR=...) or in a " ;
|
|
ECHO " Boost.Jam configuration file. The DocBook XSL stylesheets " ;
|
|
ECHO " are available here: http://docbook.sourceforge.net/ " ;
|
|
ECHO " Stylesheets will be downloaded on-the-fly (very slow!) " ;
|
|
}
|
|
else
|
|
{
|
|
text += " <rewriteURI uriStartString=\"http://docbook.sourceforge.net/release/xsl/current/\" rewritePrefix=\"file://$(docbook-xsl-dir)/\"/>" ;
|
|
}
|
|
|
|
local docbook-dtd-dir = [ boostbook.docbook-dtd-dir ] ;
|
|
if ! $(docbook-dtd-dir)
|
|
{
|
|
ECHO "BoostBook warning: no DocBook DTD directory specified." ;
|
|
ECHO " If you have the DocBook DTD installed, please set " ;
|
|
ECHO " DOCBOOK_DTD_DIR to the DTD directory on either " ;
|
|
ECHO " the command line (via -sDOCBOOK_DTD_DIR=...) or in a " ;
|
|
ECHO " Boost.Jam configuration file. The DocBook DTD is available " ;
|
|
ECHO " here: http://www.oasis-open.org/docbook/xml/4.2/index.shtml" ;
|
|
ECHO " The DTD will be downloaded on-the-fly (very slow!) " ;
|
|
}
|
|
else
|
|
{
|
|
text += " <rewriteURI uriStartString=\"http://www.oasis-open.org/docbook/xml/4.2/\" rewritePrefix=\"file://$(docbook-dtd-dir)/\"/>" ;
|
|
}
|
|
|
|
text += "</catalog>" ;
|
|
|
|
print.output $(actual) ;
|
|
print.text $(text) : true ;
|
|
|
|
# ALWAYS $(actual) ;
|
|
TEMPORARY $(actual) ;
|
|
NOUPDATE $(actual) ;
|
|
}
|
|
}
|
|
}
|
|
|
|
class xml-catalog-action : action ;
|
|
|
|
rule boostbook-target-class ( name : project : sources * : requirements *
|
|
: default-build * : catalog-entries * )
|
|
{
|
|
basic-target.__init__ $(name) : $(project) : $(sources) : $(requirements)
|
|
: $(default-build) ;
|
|
self.catalog-entries = $(catalog-entries) ;
|
|
|
|
rule construct ( source-targets * : property-set )
|
|
{
|
|
local path = [ project.attribute $(self.project) location ] ;
|
|
local catalog = [ new file-target catalog : XML : $(self.project) ] ;
|
|
$(catalog).action [ new xml-catalog-action $(catalog) : $(property-set)
|
|
: $(self.catalog-entries) ] ;
|
|
|
|
$(catalog).set-path $(path) ;
|
|
catalog = [ virtual-target.register $(catalog) ] ;
|
|
local properties = [ $(property-set).raw ] ;
|
|
|
|
local format = [ feature.get-values <format> : $(properties) ] ;
|
|
local targets = $(catalog) ;
|
|
|
|
local type = none ;
|
|
local manifest ;
|
|
switch $(format)
|
|
{
|
|
case html :
|
|
{
|
|
type = HTMLDIR ;
|
|
manifest = HTML.manifest ;
|
|
}
|
|
|
|
case onehtml : type = HTML ;
|
|
|
|
case man :
|
|
{
|
|
type = MANPAGES ;
|
|
manifest = man.manifest ;
|
|
}
|
|
|
|
case docbook : type = DOCBOOK ;
|
|
case fo : type = FO ;
|
|
case pdf : type = PDF ;
|
|
case ps : type = PS ;
|
|
case tests : type = TESTS ;
|
|
}
|
|
|
|
if $(manifest)
|
|
{
|
|
local base-target = [ generators.construct $(self.project)
|
|
: DOCBOOK : $(property-set) : $(source-targets) ] ;
|
|
$(base-target).depends $(catalog) ;
|
|
|
|
local target = [ generators.construct $(self.project) $(manifest)
|
|
: $(type) : $(property-set) : $(base-target) ] ;
|
|
$(target).set-path $(format) ;
|
|
|
|
targets += $(target) ;
|
|
}
|
|
else {
|
|
local target = [ generators.construct $(self.project)
|
|
: $(type) : $(property-set) : $(source-targets) ] ;
|
|
|
|
if ! $(target)
|
|
{
|
|
errors.error "Cannot build documentation type '$(format)'" ;
|
|
}
|
|
else
|
|
{
|
|
$(target).depends $(catalog) ;
|
|
targets += $(target) ;
|
|
}
|
|
}
|
|
|
|
return $(targets) ;
|
|
}
|
|
}
|
|
|
|
class boostbook-target-class : basic-target ;
|
|
|
|
rule boostbook ( target-name : sources * : requirements * : default-build * )
|
|
{
|
|
local project = [ CALLER_MODULE ] ;
|
|
|
|
targets.main-target-alternative
|
|
[ new boostbook-target-class $(target-name) : $(project) : $(sources)
|
|
: [ targets.main-target-requirements $(requirements) : $(project) ]
|
|
: [ targets.main-target-default-build $(default-build) : $(project) ]
|
|
] ;
|
|
}
|
|
|
|
#############################################################################
|
|
# Dependency scanners
|
|
#############################################################################
|
|
# XInclude scanner. Mostly stolen from c-scanner :)
|
|
# Note that this assumes an "xi" prefix for XIncludes. This isn't always the
|
|
# case for XML documents, but we'll assume it's true for anything we encounter.
|
|
rule xinclude-scanner ( includes * )
|
|
{
|
|
scanner.__init__ ;
|
|
|
|
rule pattern ( )
|
|
{
|
|
return "xi:include[ ]*href=\"([^\"]*)\"" ;
|
|
}
|
|
|
|
rule process ( target : matches * )
|
|
{
|
|
local target_path = [ path.native [ path.parent [ path.make
|
|
[ virtual-target.binding $(target) ] ] ] ] ;
|
|
|
|
for local i in $(matches)
|
|
{
|
|
local i2 = [ SEARCH_FOR_TARGET $(i) : $(target_path) ] ;
|
|
INCLUDES $(target) : $(i2) ;
|
|
}
|
|
|
|
BINDRULE on $(matches) = virtual-target.remember-binding ;
|
|
|
|
for local j in $(matches)
|
|
{
|
|
scanner.install $(__name__) : $(j) : $(target) ;
|
|
}
|
|
}
|
|
}
|
|
|
|
class xinclude-scanner : scanner ;
|
|
scanner.register xinclude-scanner ;
|
|
type.set-scanner XML : xinclude-scanner ;
|
|
|
|
#############################################################################
|
|
# Testsuite handling
|
|
#############################################################################
|
|
rule boostbook-to-tests ( target : source : properties * )
|
|
{
|
|
local boost_root = [ modules.peek : BOOST_ROOT ] ;
|
|
local native-path =
|
|
[ path.native [ path.join $(.boostbook-xsl-dir) testing/ ] ] ;
|
|
local stylesheet = $(native-path:B=Jamfile:S=.xsl) ;
|
|
xslt $(target) : $(source) $(stylesheet)
|
|
: $(properties) <xsl:param>boost.root=$(boost_root)
|
|
;
|
|
}
|