Boost logo

Boost-Build :

From: Alexey Pakhunov (alexeypa_at_[hidden])
Date: 2005-08-31 11:20:31


Alexey Pakhunov wrote:

The attached .diffs cover two changes in common.jam:

> 3. configurations class
> 4. modification of check-init-parameters rule

Short explanation:

- The configuration class is used to keep track of toolset
configurations detected automatically or defined by a user. Typical
sequence is the following:

1. A toolset is imported;
1.1. Autodetection code is executed. It registers some configurations;
2. 'toolset.usage' (or its equivalent) is called;
2.1. If the parameters passed to 'init' define a new configuration
is is registered;
2.2. If the parameters refer to an existing configuration, already
registered configuration is used;
2.3. If the configuration is marked as used nothing happens.
2.3. Otherwise the configuration is marked as used and the rest of
initialization is performed.

Benefits of using 'configurations' class:
- Peacefully co-existing autodetection code and user-defined
configurations;
- Multiple identical 'using' are safely processed;

- Changes in 'check-init-parameters' simply enable calling of this rule
from pseudo-toolsets like 'stlport' or 'msplatformsdk'. Both of them use
own feature for be enabled, not '<toolset>'.

Best regards/Venlig hilsen,
Alexey Pakhunov.
 --------------020307010302070107030309 Content-Type: text/plain;
name="common.1.diff"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="common.1.diff"

Index: common.jam
===================================================================
RCS file: /cvsroot/boost/boost/tools/build/v2/tools/common.jam,v
retrieving revision 1.39
diff -c -3 -r1.39 common.jam
*** common.jam 6 Jun 2005 10:21:41 -0000 1.39
--- common.jam 31 Aug 2005 15:38:04 -0000
***************
*** 30,39 ****
# all the values.
#
# The return value from this rule is a condition to be used for flags settings.
! rule check-init-parameters ( toolset : * )
{
local sig = $(toolset) ;
! local condition = <toolset>$(toolset) ;
for local index in 2 3 4 5 6 7 8 9
{
local name = $($(index)[1]) ;
--- 30,41 ----
# all the values.
#
# The return value from this rule is a condition to be used for flags settings.
! rule check-init-parameters ( toolset toolset-feature ? : * )
{
+ toolset-feature ?= toolset ;
+
local sig = $(toolset) ;
! local condition = <$(toolset-feature)>$(toolset) ;
for local index in 2 3 4 5 6 7 8 9
{
local name = $($(index)[1]) ;
***************
*** 65,76 ****
{
if ! $(.declared-subfeature.$(t).$(name))
{
! feature.subfeature toolset $(t) : $(name) : : propagated ;
.declared-subfeature.$(t).$(name) = true ;
}
.had-value.$(toolset).$(name) = true ;
}
! feature.extend-subfeature toolset $(t) : $(name) : $(value) ;
}
else
{
--- 67,78 ----
{
if ! $(.declared-subfeature.$(t).$(name))
{
! feature.subfeature $(toolset-feature) $(t) : $(name) : : propagated ;
.declared-subfeature.$(t).$(name) = true ;
}
.had-value.$(toolset).$(name) = true ;
}
! feature.extend-subfeature $(toolset-feature) $(t) : $(name) : $(value) ;
}
else
{
 --------------020307010302070107030309 Content-Type: text/plain;
name="common.2.diff"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="common.2.diff"

Index: common.jam
===================================================================
RCS file: /cvsroot/boost/boost/tools/build/v2/tools/common.jam,v
retrieving revision 1.39
diff -c -3 -r1.39 common.jam
*** common.jam 6 Jun 2005 10:21:41 -0000 1.39
--- common.jam 31 Aug 2005 16:17:59 -0000
***************
*** 16,21 ****
--- 16,111 ----
import path ;
import sequence ;
import toolset ;
+ import regex ;
+
+
+ # Configurations
+ #
+ # The following class helps to manage toolset configurations. Each configuration
+ # used 'condition' as a key (for example '<toolset>msvc-8.0') and the list of
+ # options. Options may include any details about the configuration like
+ # 'command', 'path', etc. A configuration may be in one of two states:
+ #
+ # - registered - a configuration is listed but none of toolsets is using it yet;
+ # - used - a configuration is used by a toolset.
+ #
+ # The main difference between the states is that while a configuration is
+ # 'registered' its options can be freely changed. This is useful in particular
+ # for autodetection code - all detected configurations may be safely overwritten
+ # by a user.
+
+ class configurations
+ {
+ import errors : error ;
+
+ rule __init__ ( )
+ {
+ }
+
+ # Registers a configuration
+ rule register ( id )
+ {
+ if $(id) in $(self.used)
+ {
+ error "common: the configuration '$(id)' is in use" ;
+ }
+
+ local retval ;
+
+ if ! $(id) in $(self.all)
+ {
+ self.all += $(id) ;
+
+ # indicate that a new configuration has been added
+ retval = true ;
+ }
+
+ return $(retval) ;
+ }
+
+ # Mark a configuration as 'used'
+ rule use ( id )
+ {
+ if ! $(id) in $(self.all)
+ {
+ error "common: the configuration '$(id)' is not known" ;
+ }
+
+ local retval ;
+
+ if ! $(id) in $(self.used)
+ {
+ self.used += $(id) ;
+
+ # indicate that the configuration has been marked as 'used'
+ retval = true ;
+ }
+
+ return $(retval) ;
+ }
+
+ # Return all registered configurations
+ rule all ( )
+ {
+ return $(self.all) ;
+ }
+
+ # Return all used configurations
+ rule used ( )
+ {
+ return $(self.used) ;
+ }
+
+ rule get ( id : param )
+ {
+ return $(self.$(param).$(id)) ;
+ }
+
+ rule set ( id : param : value * )
+ {
+ self.$(param).$(id) = $(value) ;
+ }
+ }

# The rule checks toolset parameters. Each trailing parameter
 --------------020307010302070107030309--


Boost-Build list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk