Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/boost_1_34_1/tools/build/v2/options/help.jam @ 32

Last change on this file since 32 was 29, checked in by landauf, 17 years ago

updated boost from 1_33_1 to 1_34_1

File size: 6.6 KB
Line 
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)
6
7# This module is the plug-in handler for the --help and --help-.*
8# command-line options
9import modules ;
10import assert ;
11import doc : do-scan set-option set-output set-output-file print-help-usage print-help-top ;
12import sequence ;
13import set ;
14import project ;
15import print ;
16import os ;
17import version ;
18import path ;
19
20# List of possible modules, but which really aren't.
21#
22.not-modules =
23    boost-build bootstrap site-config test user-config
24    -tools allyourbase boost-base features python stlport testing unit-tests ;
25
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::
29#
30#    --help-all
31#    --help-enable-<option>
32#    --help-disable-<option>
33#    --help-output <type>
34#    --help-output-file <file>
35#    --help-options
36#    --help-usage
37#    --help [<module-or-class>]
38#
39rule process (
40    command # The option.
41    : values * # The values, starting after the "=".
42    )
43{
44    assert.result --help : MATCH ^(--help).* : $(command) ;
45    local did-help = ;
46    switch $(command)
47    {
48        case --help-internal :
49        local path-to-modules = [ modules.peek : BOOST_BUILD_PATH ] ;
50        path-to-modules ?= . ;
51        local possible-modules = [ GLOB $(path-to-modules) : *\\.jam ] ;
52        local not-modules = [ GLOB $(path-to-modules) : *$(.not-modules)\\.jam ] ;
53        local modules-to-list =
54            [ sequence.insertion-sort
55                [ set.difference $(possible-modules:D=:S=) : $(not-modules:D=:S=) ] ] ;
56        local modules-to-scan ;
57        for local m in $(modules-to-list)
58        {
59            local module-files = [ GLOB $(path-to-modules) : $(m)\\.jam ] ;
60            modules-to-scan += $(module-files[1]) ;
61        }
62        do-scan $(modules-to-scan) : print-help-all ;
63        did-help = true ;
64
65        case --help-enable-* :
66        local option = [ MATCH --help-enable-(.*) : $(command) ] ; option = $(option:L) ;
67        set-option $(option) : enabled ;
68        did-help = true ;
69
70        case --help-disable-* :
71        local option = [ MATCH --help-disable-(.*) : $(command) ] ; option = $(option:L) ;
72        set-option $(option) ;
73        did-help = true ;
74
75        case --help-output :
76        set-output $(values[1]) ;
77        did-help = true ;
78
79        case --help-output-file :
80        set-output-file $(values[1]) ;
81        did-help = true ;
82
83        case --help-doc-options :
84        local doc-module-spec = [ split-symbol doc ] ;
85        do-scan $(doc-module-spec[1]) : print-help-options ;
86        did-help = true ;
87
88        case --help-options :
89        print-help-usage ;
90        did-help = true ;
91
92        case --help :
93        local spec = $(values[1]) ;
94        if $(spec)
95        {
96            local spec-parts = [ split-symbol $(spec) ] ;
97            if $(spec-parts)
98            {
99                if $(spec-parts[2])
100                {
101                    do-scan $(spec-parts[1]) : print-help-classes $(spec-parts[2]) ;
102                    do-scan $(spec-parts[1]) : print-help-rules $(spec-parts[2]) ;
103                    do-scan $(spec-parts[1]) : print-help-variables $(spec-parts[2]) ;
104                }
105                else
106                {
107                    do-scan $(spec-parts[1]) : print-help-module ;
108                }
109            }
110            else
111            {
112                EXIT "Unrecognized help option '"$(command)" "$(spec)"'." ;
113            }
114        }
115        else
116        {
117            version.print ;
118            ECHO ;
119            # First print documentation from the current Jamfile, if any.           
120            # FIXME: Generally, this duplication of project.jam logic is bad.
121            local names = [ modules.peek project : JAMROOT ]
122              [ modules.peek project : JAMFILE ] ;
123            local project-file = [ path.glob . : $(names) ] ;
124            if ! $(project-file)
125            {
126                project-file = [ path.glob-in-parents . : $(names) ] ;
127            }
128           
129            for local p in $(project-file)
130            {
131                do-scan $(p) : print-help-project $(p) ;
132            }
133           
134            # Next any user-config help.
135            local user-path = [ os.home-directories ] [ os.environ BOOST_BUILD_PATH ] ;
136            local user-config = [ GLOB $(user-path) : user-config.jam ] ;
137            if $(user-config)
138            {
139                do-scan $(user-config[1]) : print-help-config user $(user-config[1]) ;
140            }
141           
142            # Next any site-config help.
143            local site-config = [ GLOB $(user-path) : site-config.jam ] ;
144            if $(site-config)
145            {
146                do-scan $(site-config[1]) : print-help-config site $(site-config[1]) ;
147            }
148
149            # Then the overall help.
150            print-help-top ;
151        }
152        did-help = true ;
153    }
154    if $(did-help)
155    {
156        UPDATE all ;
157        NOCARE all ;
158    }
159    return $(did-help) ;
160}
161
162# Split a reference to a symbol into module and symbol parts.
163#
164local rule split-symbol (
165    symbol # The symbol to split.
166    )
167{
168    local path-to-modules = [ modules.peek : BOOST_BUILD_PATH ] ;
169    path-to-modules ?= . ;
170    local module-name = $(symbol) ;
171    local symbol-name = ;
172    local result = ;
173    while ! $(result)
174    {
175        local module-path = [ GLOB $(path-to-modules) : $(module-name)\\.jam ] ;
176        if $(module-path)
177        {
178            # The 'module-name' in fact refers to module. Return the full
179            # module path and a symbol within it. If 'symbol' passed to this
180            # rule is already module, 'symbol-name' will be empty. Otherwise,
181            # it's initialized on the previous loop iteration.
182            # In case there are several modules by this name,
183            # use the first one.
184            result = $(module-path[1]) $(symbol-name) ;
185        }
186        else
187        {
188            if ! $(module-name:S)
189            {
190                result = - ;
191            }
192            else
193            {
194                local next-symbol-part = [ MATCH ^.(.*) : $(module-name:S) ] ;
195                if $(symbol-name)
196                {
197                    symbol-name = $(next-symbol-part).$(symbol-name) ;
198                }
199                else
200                {
201                    symbol-name = $(next-symbol-part) ;
202                }
203                module-name = $(module-name:B) ;
204            }
205        }
206    }
207    if $(result) != -
208    {
209        return $(result) ;
210    }
211}
Note: See TracBrowser for help on using the repository browser.