2
0
mirror of https://github.com/boostorg/build.git synced 2026-02-21 02:52:12 +00:00
Files
build/src/tools/doxygen.jam
Vladimir Prus f408979299 Bugfix. Call 'xsltproc.xslt' instead of just 'xslt'. Now that main
target rule for xslt is automatically defined, this call uses that
rule, not the 'action rule' which is intended to call.

In addition, 'xslt' was called without including xslproc, and xsltproc
was injecting internal rules into global namespace.


[SVN r26481]
2004-12-09 13:52:19 +00:00

180 lines
5.9 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 BoostBook XML
# from Doxygen XML output.
import "class" : new ;
import targets ;
import feature ;
import property ;
import generators ;
import boostbook ;
import type ;
import path ;
import print ;
import regex ;
import stage ;
import project ;
import xsltproc ;
feature.feature doxygen:param : : free ;
feature.feature prefix : : free ;
feature.feature reftitle : : free ;
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
# Initialize the Doxygen module. Parameters are:
# name: the name of the 'doxygen' executable. If not specified, the name
# 'doxygen' will be used
rule init ( name ? )
{
if ! $(.initialized)
{
.initialized = true ;
if $(name)
{
.doxygen = $(name) ;
}
generators.register-composing doxygen.headers-to-doxyfile : H HPP : DOXYFILE ;
generators.register-standard doxygen.run : DOXYFILE : DOXYGEN_XML_MULTIFILE ;
generators.register-standard doxygen.xml-to-boostbook : DOXYGEN_XML : BOOSTBOOK ;
if ! [ boostbook.xsl-dir ]
{
ECHO "warning: Doxygen initialization: Boost.Build stylesheets not found " ;
ECHO "warning: Generation of single XML file won't be possible. " ;
}
else
{
generators.register-standard doxygen.collect : DOXYGEN_XML_MULTIFILE : DOXYGEN_XML ;
}
IMPORT $(__name__) : doxygen : : doxygen ;
}
}
rule name ( )
{
return $(.doxygen) ;
}
# 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
{
"$(NAME:E=doxygen)" $(>) ;
echo "Stamped" > "$(<)"
}
# Generates a doxygen configuration file (doxyfile) given a set of C++
# sources anda property list that may contain <doxygen:param>
# features.
rule headers-to-doxyfile ( target : sources * : properties * )
{
local text "# Generated by Boost.Build version 2" ;
# Translate <doxygen:param> into command line flags.
for local param in [ feature.get-values <doxygen:param> : $(properties) ]
{
local namevalue = [ regex.match ([^=]*)=(.*) : $(param) ] ;
text += "$(namevalue[1]) = $(namevalue[2])" ;
}
local headers = "" ;
for local source in $(sources:G=)
{
headers = "$(headers) $(source)" ;
}
text += "GENERATE_HTML = NO" ;
text += "GENERATE_LATEX = NO" ;
text += "GENERATE_XML = YES" ;
text += "INPUT = $(headers) " ;
print.output $(target) plain ;
print.text $(text) : true ;
}
# Run Doxygen. See doxygen-action for a description of the strange
# properties of this rule
rule run ( target : source : properties * )
{
doxygen-action $(target) : $(source) ;
NAME on $(target) = $(.doxygen) ;
}
# 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) ;
xsltproc.xslt $(target) : $(real-source) $(collect-xsl-dir:S=.xsl)
: <xsl:param>doxygen.xml.path=$(collect-path)
;
}
# 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 ] ] ;
local xslt-properties = $(properties) ;
for local prefix in [ feature.get-values <prefix> : $(properties) ]
{
xslt-properties += "<xsl:param>boost.doxygen.header.prefix=$(prefix)" ;
}
for local title in [ feature.get-values <reftitle> : $(properties) ]
{
xslt-properties += "<xsl:param>boost.doxygen.reftitle=\"$(title)\"" ;
}
xsltproc.xslt $(target) : $(source) $(d2b-xsl) : $(xslt-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 = [ project.current ] ;
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) ;
targets.main-target-alternative
[ new stage-target-class $(target-name:S=.xml) : $(project)
: [ $(doxyfile).name ]
: [ targets.main-target-requirements $(requirements) <location>. : $(project) ]
: [ targets.main-target-default-build $(default-build) : $(project) ]
] ;
}