1 # Copyright 2003 Dave Abrahams
2 # Copyright 2003, 2006 Rene Rivera
3 # Copyright 2003, 2006 Vladimir Prus
4 # Distributed under the Boost Software License, Version 1.0.
5 # (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
7 # This module is the plug-in handler for the --help and --help-.*
11 import doc : do-scan set-option set-output set-output-file print-help-usage print-help-top ;
20 # List of possible modules, but which really aren't.
23 boost-build bootstrap site-config test user-config
24 -tools allyourbase boost-base features python stlport testing unit-tests ;
26 # The help system options are parsed here and handed off to the doc
27 # module to translate into documentation requests and actions. The
28 # understood options are:
30 # --help-disable-<option>
32 # --help-enable-<option>
36 # --help-output <type>
37 # --help-output-file <file>
38 # --help [<module-or-class>]
42 : values * # The values, starting after the "=".
45 assert.result --help : MATCH ^(--help).* : $(command) ;
49 case --help-internal :
50 local path-to-modules = [ modules.peek : BOOST_BUILD_PATH ] ;
51 path-to-modules ?= . ;
52 local possible-modules = [ GLOB $(path-to-modules) : *\\.jam ] ;
53 local not-modules = [ GLOB $(path-to-modules) : *$(.not-modules)\\.jam ] ;
54 local modules-to-list =
55 [ sequence.insertion-sort
56 [ set.difference $(possible-modules:D=:S=) : $(not-modules:D=:S=) ] ] ;
57 local modules-to-scan ;
58 for local m in $(modules-to-list)
60 local module-files = [ GLOB $(path-to-modules) : $(m)\\.jam ] ;
61 modules-to-scan += $(module-files[1]) ;
63 do-scan $(modules-to-scan) : print-help-all ;
66 case --help-enable-* :
67 local option = [ MATCH --help-enable-(.*) : $(command) ] ; option = $(option:L) ;
68 set-option $(option) : enabled ;
71 case --help-disable-* :
72 local option = [ MATCH --help-disable-(.*) : $(command) ] ; option = $(option:L) ;
73 set-option $(option) ;
77 set-output $(values[1]) ;
80 case --help-output-file :
81 set-output-file $(values[1]) ;
84 case --help-doc-options :
85 local doc-module-spec = [ split-symbol doc ] ;
86 do-scan $(doc-module-spec[1]) : print-help-options ;
91 local BOOST_BUILD_PATH = [ modules.peek : BOOST_BUILD_PATH ] ;
92 local plugin-dir = options ;
93 local option-files = [ GLOB $(plugin-dir:D=$(BOOST_BUILD_PATH)) : *.jam ] ;
96 for local file in $(option-files)
98 do-scan $(file) : print-help-options ;
104 local spec = $(values[1]) ;
107 local spec-parts = [ split-symbol $(spec) ] ;
112 do-scan $(spec-parts[1]) : print-help-classes $(spec-parts[2]) ;
113 do-scan $(spec-parts[1]) : print-help-rules $(spec-parts[2]) ;
114 do-scan $(spec-parts[1]) : print-help-variables $(spec-parts[2]) ;
118 do-scan $(spec-parts[1]) : print-help-module ;
123 EXIT "Unrecognized help option '"$(command)" "$(spec)"'." ;
130 # First print documentation from the current Jamfile, if any.
131 # FIXME: Generally, this duplication of project.jam logic is bad.
132 local names = [ modules.peek project : JAMROOT ]
133 [ modules.peek project : JAMFILE ] ;
134 local project-file = [ path.glob . : $(names) ] ;
137 project-file = [ path.glob-in-parents . : $(names) ] ;
140 for local p in $(project-file)
142 do-scan $(p) : print-help-project $(p) ;
145 # Next any user-config help.
146 local user-path = [ os.home-directories ] [ os.environ BOOST_BUILD_PATH ] ;
147 local user-config = [ GLOB $(user-path) : user-config.jam ] ;
150 do-scan $(user-config[1]) : print-help-config user $(user-config[1]) ;
153 # Next any site-config help.
154 local site-config = [ GLOB $(user-path) : site-config.jam ] ;
157 do-scan $(site-config[1]) : print-help-config site $(site-config[1]) ;
160 # Then the overall help.
173 # Split a reference to a symbol into module and symbol parts.
175 local rule split-symbol (
176 symbol # The symbol to split.
179 local path-to-modules = [ modules.peek : BOOST_BUILD_PATH ] ;
180 path-to-modules ?= . ;
181 local module-name = $(symbol) ;
182 local symbol-name = ;
186 local module-path = [ GLOB $(path-to-modules) : $(module-name)\\.jam ] ;
189 # The 'module-name' in fact refers to module. Return the full
190 # module path and a symbol within it. If 'symbol' passed to this
191 # rule is already module, 'symbol-name' will be empty. Otherwise,
192 # it's initialized on the previous loop iteration.
193 # In case there are several modules by this name,
195 result = $(module-path[1]) $(symbol-name) ;
199 if ! $(module-name:S)
205 local next-symbol-part = [ MATCH ^.(.*) : $(module-name:S) ] ;
208 symbol-name = $(next-symbol-part).$(symbol-name) ;
212 symbol-name = $(next-symbol-part) ;
214 module-name = $(module-name:B) ;