• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright (c) 2002 Douglas Gregor <doug.gregor -at- gmail.com>
2# Copyright (c) 2016-2018 Rene Rivera
3#
4# Distributed under the Boost Software License, Version 1.0.
5# (See accompanying file LICENSE_1_0.txt or copy at
6# http://www.boost.org/LICENSE_1_0.txt)
7
8project boost/doc
9    : requirements
10    <xsl:param>boost.libraries=../../libs/libraries.htm
11    <format>html:<xsl:param>chunker.output.doctype-public="-//W3C//DTD HTML 4.01 Transitional//EN"
12    <format>html:<xsl:param>chunker.output.doctype-system="http://www.w3.org/TR/html4/loose.dtd"
13    ;
14
15import boostbook : boostbook ;
16import project ;
17import targets ;
18import print ;
19import type ;
20import generators ;
21import sequence ;
22import path ;
23import "class" : is-a ;
24import regex ;
25
26path-constant BOOST_DOC : . ;
27
28local lib-docs = [ path.glob [ path.glob $(BOOST_DOC)/../libs $(BOOST_DOC)/../tools : */doc ]
29    : [ modules.peek project : JAMFILE ] ] ;
30
31local rule find-target-of-class-or-type ( root-target : klass ? : type ? )
32{
33    local result ;
34    if ! $(result) && $(klass) && [ is-a $(root-target) : $(klass) ]
35    {
36        result ?= $(root-target) $(klass) ;
37    }
38    if ! $(result) && $(type) && $(type:U) = [ modules.peek $(root-target) : self.type ]
39    {
40        result ?= $(root-target) $(type:U) ;
41    }
42    local alternatives = [ modules.peek $(root-target) : self.alternatives ] ;
43    if ! $(result)
44    {
45        for local alternative in $(alternatives)
46        {
47            if $(result) { break ; }
48            result ?= [ find-target-of-class-or-type $(alternative) : $(klass) : $(type) ] ;
49        }
50    }
51    if ! $(result)
52    {
53        for local alternative in $(alternatives)
54        {
55            if $(result) { break ; }
56            local sources = [ modules.peek $(alternative) : self.sources ] ;
57            for local source in [ $(alternative).sources ]
58            {
59                if $(result) { break ; }
60                result ?= [ find-target-of-class-or-type $(source) : $(klass) : $(type) ] ;
61            }
62        }
63    }
64    return $(result) ;
65}
66
67local rule docbook-target-spec ( main-target )
68{
69    local spec ;
70    local doc-sub-target
71        = [ find-target-of-class-or-type $(main-target) : boostbook-target-class : XML ] ;
72    if $(doc-sub-target)
73    {
74        #ECHO *** $(main-target) ;
75        #ECHO " ::" [ $(main-target).full-name ] ;
76        #ECHO " ::" $(doc-sub-target) :: [ $(doc-sub-target[0]).full-name ] ;
77        local full-name = [ $(doc-sub-target[0]).full-name ] ;
78        local target-path = $(full-name:D) ;
79        local target-name = $(full-name:B) ;
80        local this-path = [ path.root [ project.attribute $(__name__) location ] [ path.pwd ] ] ;
81        target-path = [ path.relative-to $(this-path) $(target-path) ] ;
82        #ECHO " ::" $(target-path) :: $(target-name) ;
83        spec = $(target-path)//$(target-name) ;
84    }
85    return $(spec) ;
86}
87
88local exclude-libs = [ MATCH "^--exclude-libraries=(.*)" : [ modules.peek : ARGV ] ] ;
89exclude-libs = [ regex.split-list $(exclude-libs) : "," ] ;
90
91#ECHO "=== --exclude-libraries:" $(exclude-libs) ;
92
93local lib-doc-boostdoc-refs ;
94local lib-doc-boostrelease-refs ;
95
96local this-path = [ path.root [ project.attribute $(__name__) location ] [ path.pwd ] ] ;
97for local lib-doc in $(lib-docs)
98{
99    #ECHO === $(lib-doc) ... ;
100    local doc-project = $(lib-doc:D) ;
101
102    local lib-dir = $(doc-project:D) ;
103    local lib-name = $(lib-dir:BS) ;
104
105    #ECHO "=== lib-name:" $(lib-name) ... ;
106
107    if $(lib-name) in $(exclude-libs)
108    {
109        ECHO "-- Excluded library" '$(lib-name)' ;
110    }
111    else
112    {
113        local doc-module = [ project.find $(doc-project)
114            : [ project.attribute $(__name__) location ] ] ;
115        local doc-target = [ project.target $(doc-module) ] ;
116        $(doc-target).build-main-targets ;
117        local boostrelease-target = [ $(doc-target).main-target boostrelease ] ;
118        if $(boostrelease-target)
119        {
120            local full-name = [ $(boostrelease-target).full-name ] ;
121            local target-path = [ path.relative-to $(this-path) $(full-name:D) ] ;
122            lib-doc-boostrelease-refs += $(target-path)//boostrelease ;
123            #ECHO "  ::" $(target-path)//boostrelease ;
124        }
125        local boostdoc-target = [ $(doc-target).main-target boostdoc ] ;
126        if $(boostdoc-target)
127        {
128            local full-name = [ $(boostdoc-target).full-name ] ;
129            local target-path = [ path.relative-to $(this-path) $(full-name:D) ] ;
130            lib-doc-boostdoc-refs += $(target-path)//boostdoc ;
131            #ECHO "  ::" $(target-path)//boostdoc ;
132        }
133    }
134}
135
136# Build non-integrated library docs for release.
137if "--release-build" in [ modules.peek : ARGV ]
138{
139    alias release-build : $(lib-doc-boostrelease-refs) ;
140}
141
142local rule component-order ( x y )
143{
144    local a = [ MATCH "(/libs/[^/]+)" "(/tools/[^/]+)" : $(x:G) $(x:G=) ] ;
145    local b = [ MATCH "(/libs/[^/]+)" "(/tools/[^/]+)" : $(y:G) $(y:G=) ] ;
146    if $(a[1]) < $(b[1])
147    {
148        return true ;
149    }
150    else if $(a[1]) = $(b[1]) && $(x) < $(y)
151    {
152        return true ;
153    }
154}
155
156rule xinclude-generator ( target : sources * : properties * )
157{
158    print.output $(target) ;
159    local includes ;
160    sources = [ sequence.insertion-sort $(sources) : component-order ] ;
161    locate = [ path.root [ on $(target) return $(LOCATE) ] [ path.pwd ] ] ;
162    for local xml in $(sources)
163    {
164        local dir ;
165        dir ?= [ on $(xml) return $(LOCATE) ] ;
166        dir ?= [ on $(xml) return $(SEARCH) ] ;
167        dir ?= "" ;
168        dir = [ path.root $(dir[1]) [ path.pwd ] ] ;
169        dir = [ path.relative-to $(locate) $(dir) ] ;
170        includes += "<xi:include href=\"$(dir[1])/$(xml:G=)\"/>" ;
171    }
172    print.text
173        "<?xml version=\"1.0\" encoding=\"utf-8\"?>"
174        "<xml xmlns:xi=\"http://www.w3.org/2003/XInclude\">"
175        $(includes)
176        "</xml>"
177        : overwrite ;
178}
179type.register XINCLUDE_XML : xinclude : XML ;
180generators.register-composing $(__name__).xinclude-generator : XML : XINCLUDE_XML ;
181
182rule xinclude ( name : sources * : requirements * : default-build * : usage-requirements *  )
183{
184    targets.create-typed-target XINCLUDE_XML
185        : [ project.current ]
186        : $(name)
187        : $(sources)
188        : $(requirements)
189        : $(default-build)
190        : $(usage-requirements)
191        ;
192}
193
194xinclude libraries :
195    $(lib-doc-boostdoc-refs)
196    ;
197explicit libraries ;
198
199xinclude tools :
200    ../tools/quickbook/doc//quickbook
201    ../tools/boostbook/doc/boostbook.xml
202    ;
203explicit tools ;
204
205boostbook doc
206    :
207    src/boost.xml
208    :
209    <xsl:param>generate.consistent.ids=1
210    <use>$(lib-doc-boostdoc-refs)
211    <dependency>libraries
212    <implicit-dependency>libraries
213    <dependency>tools
214    <implicit-dependency>tools
215
216    <dependency>images
217    <dependency>callouts
218    <xsl:path>$(BOOST_DOC)
219    ;
220
221install images : [ glob src/images/*.png ] : <location>html/images ;
222explicit images ;
223install callouts : [ glob src/images/callouts/*.png ] : <location>html/images/callouts ;
224explicit callouts ;
225