Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/boost_1_33_1/tools/build/v2/options/help.jam @ 12

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

added boost

  • Property svn:executable set to *
File size: 5.2 KB
Line 
1# (C) Copyright David Abrahams, 2003.
2# (C) Copyright Rene Rivera, 2003.
3#
4# See accompanying license for terms and conditions of use.
5#
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 ;
14
15
16# List of possible modules, but which really aren't.
17#
18.not-modules =
19    boost-build bootstrap site-config test user-config
20    -tools allyourbase boost-base features python stlport testing unit-tests ;
21
22# The help system options are parsed here and handed off to the doc
23# module to translate into documentation requests and actions. The
24# understood options are::
25#
26#    --help-all
27#    --help-enable-<option>
28#    --help-disable-<option>
29#    --help-output <type>
30#    --help-output-file <file>
31#    --help-options
32#    --help-usage
33#    --help [<module-or-class>]
34#
35rule process (
36    command # The option.
37    : values * # The values, starting after the "=".
38    )
39{
40    assert.result --help : MATCH ^(--help).* : $(command) ;
41    local did-help = ;
42    switch $(command)
43    {
44        case --help-all :
45        local path-to-modules = [ modules.peek : BOOST_BUILD_PATH ] ;
46        path-to-modules ?= . ;
47        local possible-modules = [ GLOB $(path-to-modules) : *\\.jam ] ;
48        local not-modules = [ GLOB $(path-to-modules) : *$(.not-modules)\\.jam ] ;
49        local modules-to-list =
50            [ sequence.insertion-sort
51                [ set.difference $(possible-modules:D=:S=) : $(not-modules:D=:S=) ] ] ;
52        local modules-to-scan ;
53        for local m in $(modules-to-list)
54        {
55            local module-files = [ GLOB $(path-to-modules) : $(m)\\.jam ] ;
56            modules-to-scan += $(module-files[1]) ;
57        }
58        do-scan $(modules-to-scan[1--2]) ;
59        do-scan $(modules-to-scan[-1]) : print-help-all ;
60        did-help = true ;
61       
62        case --help-enable-* :
63        local option = [ MATCH --help-enable-(.*) : $(command) ] ; option = $(option:L) ;
64        set-option $(option) : enabled ;
65        did-help = true ;
66       
67        case --help-disable-* :
68        local option = [ MATCH --help-disable-(.*) : $(command) ] ; option = $(option:L) ;
69        set-option $(option) ;
70        did-help = true ;
71       
72        case --help-output :
73        set-output $(values[1]) ;
74        did-help = true ;
75       
76        case --help-output-file :
77        set-output-file $(values[1]) ;
78        did-help = true ;
79       
80        case --help-options :
81        local doc-module-spec = [ split-symbol doc ] ;
82        do-scan $(doc-module-spec[1]) : print-help-options ;
83        did-help = true ;
84       
85        case --help-usage :
86        print-help-usage ;
87        did-help = true ;
88       
89        case --help :
90        local spec = $(values[1]) ;
91        if $(spec)
92        {
93            local spec-parts = [ split-symbol $(spec) ] ;
94            if $(spec-parts)
95            {
96                if $(spec-parts[2])
97                {
98                    do-scan $(spec-parts[1]) : print-help-classes $(spec-parts[2]) ;
99                    do-scan $(spec-parts[1]) : print-help-rules $(spec-parts[2]) ;
100                    do-scan $(spec-parts[1]) : print-help-variables $(spec-parts[2]) ;
101                }
102                else
103                {
104                    do-scan $(spec-parts[1]) : print-help-module ;
105                }
106            }
107            else
108            {
109                EXIT "Unrecognized help option '"$(command)" "$(spec)"'." ;
110            }
111        }
112        else
113        {
114            print-help-top ;
115        }
116        did-help = true ;
117    }
118    if $(did-help)
119    {
120        UPDATE all ;
121    }
122    return $(did-help) ;
123}
124
125# Split a reference to a symbol into module and symbol parts.
126#
127local rule split-symbol (
128    symbol # The symbol to split.
129    )
130{
131    local path-to-modules = [ modules.peek : BOOST_BUILD_PATH ] ;
132    path-to-modules ?= . ;
133    local module-name = $(symbol) ;
134    local symbol-name = ;
135    local result = ;
136    while ! $(result)
137    {
138        local module-path = [ GLOB $(path-to-modules) : $(module-name)\\.jam ] ;
139        if $(module-path)
140        {
141            # The 'module-name' in fact refers to module. Return the full
142            # module path and a symbol within it. If 'symbol' passed to this
143            # rule is already module, 'symbol-name' will be empty. Otherwise,
144            # it's initialized on the previous loop iteration.
145            # In case there are several modules by this name,
146            # use the first one.
147            result = $(module-path[1]) $(symbol-name) ;
148        }
149        else
150        {
151            if ! $(module-name:S)
152            {
153                result = - ;
154            }
155            else
156            {
157                local next-symbol-part = [ MATCH ^.(.*) : $(module-name:S) ] ;
158                if $(symbol-name)
159                {
160                    symbol-name = $(next-symbol-part).$(symbol-name) ;
161                }
162                else
163                {
164                    symbol-name = $(next-symbol-part) ;
165                }
166                module-name = $(module-name:B) ;
167            }
168        }
169    }
170    if $(result) != -
171    {
172        return $(result) ;
173    }
174}
Note: See TracBrowser for help on using the repository browser.