Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/boost_1_34_1/tools/build/v2/util/option.jam @ 45

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

updated boost from 1_33_1 to 1_34_1

File size: 2.7 KB
Line 
1#  Copyright (c) 2005 Vladimir Prus.
2#
3#  Use, modification and distribution is subject to the Boost Software
4#  License Version 1.0. (See accompanying file LICENSE_1_0.txt or
5#  http://www.boost.org/LICENSE_1_0.txt)
6
7import modules ;
8
9rule get ( name : default-value ? )
10{
11    local m = [ MATCH --$(name)=(.*) : [ modules.peek : ARGV ] ] ;
12    if $(m)
13    {
14        return $(m[1]) ;
15    }
16    else
17    {
18        return $(default-value) ;
19    }       
20}
21
22
23rule process ( )
24{
25    # Check command-line args as soon as possible.  For each option try
26    # to load module named after option. Is that succeeds, invoke 'process'
27    # rule in the module. The rule may return "true" to indicate that the
28    # regular built process should not be attempted.
29    #
30    # Options take the general form of: --<name>[=<value>] [<value>]
31    #
32   
33    local ARGV = [ modules.peek : ARGV ] ;
34    local BOOST_BUILD_PATH = [ modules.peek : BOOST_BUILD_PATH ] ;
35   
36    local dont-build ;
37    local args = $(ARGV) ;
38    while $(args)
39    {
40        local arg = [ MATCH ^--(.*) : $(args[1]) ] ;
41        while $(args[2-]) && ! $(arg)
42        {
43            args = $(args[2-]) ;
44            arg = [ MATCH ^--(.*) : $(args[1]) ] ;
45        }
46        args = $(args[2-]) ;
47
48        if $(arg)
49        {
50            local split = [ MATCH ^(([^-=]+)[^=]*)(=?)(.*)$ : $(arg) ] ;
51            local full-name = $(split[1]) ;
52            local prefix = $(split[2]) ;
53            local values ;
54
55            if $(split[3])
56            {
57                values = $(split[4]) ;
58            }
59            if $(args) && ! [ MATCH ^(--).* : $(args[1]) ]
60            {
61                values += $(args[1]) ;
62                args = $(args[2-]) ;
63            }
64
65            # look in options subdirectories of BOOST_BUILD_PATH for modules
66            # matching the full option name and then its prefix.
67            local plugin-dir = options ;
68            local option-files = [
69              GLOB $(plugin-dir:D=$(BOOST_BUILD_PATH)) : $(full-name).jam $(prefix).jam
70            ] ;
71
72            if $(option-files)
73            {
74                # load the file into a module named for the option
75                local f = $(option-files[1]) ;
76                local module-name = --$(f:D=:S=) ;
77                modules.load $(module-name) : $(f:D=) : $(f:D) ;
78
79                # if there's a process rule, call it with the full option name
80                # and its value (if any).  If there was no "=" in the option,
81                # the value will be empty.
82                if process in [ RULENAMES $(module-name) ]
83                {
84                    dont-build +=
85                      [ modules.call-in $(module-name) : process --$(full-name) : $(values) ] ;
86                }
87            }
88        }
89    }
90
91    return $(dont-build) ;
92}
93
Note: See TracBrowser for help on using the repository browser.