2
0
mirror of https://github.com/boostorg/build.git synced 2026-02-16 13:22:11 +00:00
Files
build/options/help.jam
Rene Rivera 7f607820ce Some movement towards the new style of options for the help system.
- boostrap.jam; Modified the parsing of options to accept the syntax that the help system requires.
- doc.jam; Removed the option parsing code.
- doc.jam; Added some rules to set documentation options.
- help.jam; Move in code from doc.jam to parse options.


[SVN r18798]
2003-06-16 07:04:30 +00:00

169 lines
5.0 KiB
Plaintext
Executable File

# (C) Copyright David Abrahams 2003.
# (C) Copyright Rene Rivera 2003.
#
# 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 is the plug-in handler for the --help and --help-.*
# command-line options
import modules ;
import assert ;
import doc : do-scan set-option set-output set-output-file print-help-usage print-help-top ;
import sequence ;
import set ;
# List of possible modules, but which really aren't.
#
.not-modules = boost-build bootstrap site-config test user-config ;
# The help system options are parsed here and handed off to the doc
# module to translate into documentation requests and actions. The
# understood options are::
#
# --help-all
# --help-enable-<option>
# --help-disable-<option>
# --help-output <type>
# --help-output-file <file>
# --help-options
# --help-usage
# --help [<module-or-class>]
#
rule process (
command # The option.
: values * # The values, starting after the "=".
)
{
assert.result --help : MATCH ^(--help).* : $(command) ;
local did-help = ;
switch $(command)
{
case --help-all :
local path-to-modules = [ modules.peek : BOOST_BUILD_PATH ] ;
path-to-modules ?= . ;
local modules-to-list =
[ sequence.insertion-sort
[ set.difference
[ GLOB $(path-to-modules) : *\\.jam ] :
[ GLOB $(path-to-modules) : $(.not-modules)\\.jam ] ] ] ;
do-scan $(modules-to-list[1--2]) ;
do-scan $(modules-to-list[-1]) : print-help-all ;
did-help = true ;
case --help-enable-* :
local option = [ MATCH --help-enable-(.*) : $(command) ] ; option = $(option:L) ;
set-option $(option) : enabled ;
did-help = true ;
case --help-disable-* :
local option = [ MATCH --help-disable-(.*) : $(command) ] ; option = $(option:L) ;
set-option $(option) ;
did-help = true ;
case --help-output :
set-output $(values[1]) ;
did-help = true ;
case --help-output-file :
set-output-file $(values[1]) ;
did-help = true ;
case --help-options :
local doc-module-spec = [ split-symbol doc ] ;
do-scan $(doc-module-spec[1]) : print-help-options ;
did-help = true ;
case --help-usage :
print-help-usage ;
did-help = true ;
case --help :
local spec = $(values[1]) ;
if $(spec)
{
local spec-parts = [ split-symbol $(spec) ] ;
if $(spec-parts)
{
if $(spec-parts[2])
{
do-scan $(spec-parts[1]) : print-help-classes $(spec-parts[2]) ;
do-scan $(spec-parts[1]) : print-help-rules $(spec-parts[2]) ;
do-scan $(spec-parts[1]) : print-help-variables $(spec-parts[2]) ;
}
else
{
do-scan $(spec-parts[1]) : print-help-module ;
}
}
else
{
EXIT "Unrecognized help option '"$(command)" "$(spec)"'." ;
}
}
else
{
print-help-top ;
}
did-help = true ;
}
if $(did-help)
{
UPDATE all ;
}
return $(did-help) ;
}
# Split a reference to a symbol into module and symbol parts.
#
local rule split-symbol (
symbol # The symbol to split.
)
{
local path-to-modules = [ modules.peek : BOOST_BUILD_PATH ] ;
path-to-modules ?= . ;
local module-name = $(symbol) ;
local symbol-name = ;
local result = ;
while ! $(result)
{
local module-path = [ GLOB $(path-to-modules) : $(module-name)\\.jam ] ;
if $(module-path)
{
# The 'module-name' in fact refers to module. Return the full
# module path and a symbol within it. If 'symbol' passed to this
# rule is already module, 'symbol-name' will be empty. Otherwise,
# it's initialized on the previous loop iteration.
# In case there are several modules by this name,
# use the first one.
result = $(module-path[1]) $(symbol-name) ;
}
else
{
if ! $(module-name:S)
{
result = - ;
}
else
{
local next-symbol-part = [ MATCH ^.(.*) : $(module-name:S) ] ;
if $(symbol-name)
{
symbol-name = $(next-symbol-part).$(symbol-name) ;
}
else
{
symbol-name = $(next-symbol-part) ;
}
module-name = $(module-name:B) ;
}
}
}
if $(result) != -
{
return $(result) ;
}
}