|
Boost-Commit : |
From: steven_at_[hidden]
Date: 2008-07-09 00:02:57
Author: steven_watanabe
Date: 2008-07-09 00:02:57 EDT (Wed, 09 Jul 2008)
New Revision: 47256
URL: http://svn.boost.org/trac/boost/changeset/47256
Log:
Start porting common.jam
Text files modified:
branches/build/python_port/python/boost/build/build/feature.py | 3
branches/build/python_port/python/boost/build/tools/common.py | 196 +++++++++++++++++++++++++++++++--------
branches/build/python_port/python/boost/build/tools/darwin.py | 2
branches/build/python_port/python/boost/build/tools/gcc.py | 4
4 files changed, 161 insertions(+), 44 deletions(-)
Modified: branches/build/python_port/python/boost/build/build/feature.py
==============================================================================
--- branches/build/python_port/python/boost/build/build/feature.py (original)
+++ branches/build/python_port/python/boost/build/build/feature.py 2008-07-09 00:02:57 EDT (Wed, 09 Jul 2008)
@@ -27,6 +27,7 @@
"""
global __all_attributes, __all_features, __implicit_features, __composite_properties
global __features_with_attributes, __subfeature_value_to_name, __all_top_features, __free_features
+ global __all_subfeatures
# The list with all attribute names.
__all_attributes = [ 'implicit',
@@ -71,6 +72,8 @@
# All free features
__free_features = []
+ __all_subfeatures = []
+
reset ()
def enumerate ():
Modified: branches/build/python_port/python/boost/build/tools/common.py
==============================================================================
--- branches/build/python_port/python/boost/build/tools/common.py (original)
+++ branches/build/python_port/python/boost/build/tools/common.py 2008-07-09 00:02:57 EDT (Wed, 09 Jul 2008)
@@ -1,9 +1,12 @@
+# Status: being ported by Steven Watanabe
+# Base revision: 47174
+#
# Copyright (C) Vladimir Prus 2002. 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.
-""" Provides actions common to all toolsets, for as making directories and
+""" Provides actions common to all toolsets, such as creating directories and
removing files.
"""
@@ -21,7 +24,9 @@
""" Clear the module state. This is mainly for testing purposes.
Note that this must be called _after_ resetting the module 'feature'.
"""
- global __had_unspecified_value, __had_value, __declared_subfeature, __all_signatures, __debug_configuration
+ global __had_unspecified_value, __had_value, __declared_subfeature
+ global __init_loc
+ global __all_signatures, __debug_configuration, __show_configuration
# Stores toolsets without specified initialization values.
__had_unspecified_value = {}
@@ -35,37 +40,128 @@
# Stores all signatures of the toolsets.
__all_signatures = {}
+ # Stores the initialization locations of each toolset
+ __init_loc = {}
+
__debug_configuration = '--debug-configuration' in bjam.variable('ARGV')
+ __show_configuration = '--show-configuration' in bjam.variable('ARGV')
-reset ()
+reset()
+
+# ported from trunk_at_47174
+class Configurations(object):
+ """
+ This class helps to manage toolset configurations. Each configuration
+ has a unique ID and one or more parameters. A typical example of a unique ID
+ is a condition generated by 'common.check-init-parameters' rule. Other kinds
+ of IDs can be used. Parameters may include any details about the configuration
+ like 'command', 'path', etc.
+
+ A toolset configuration may be in one of the following states:
+
+ - registered
+ Configuration has been registered (e.g. by autodetection code) but has
+ not yet been marked as used, i.e. 'toolset.using' rule has not yet been
+ called for it.
+ - used
+ Once called 'toolset.using' rule marks the configuration as 'used'.
+
+ The main difference between the states above 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 user code.
+ """
+
+ def __init__(self):
+ self.used_ = set()
+ self.all_ = set()
+ self.params = {}
+
+ def register(self, id):
+ """
+ Registers a configuration.
+
+ Returns True if the configuration has been added and False if
+ it already exists. Reports an error if the configuration is 'used'.
+ """
+ if id in self.used_:
+ #FIXME
+ errors.error("common: the configuration '$(id)' is in use")
+
+ if id not in self.all_:
+ self.all_ += [id]
+
+ # Indicate that a new configuration has been added.
+ return True
+ else:
+ return False
+
+ def use(self, id):
+ """
+ Mark a configuration as 'used'.
+
+ Returns True if the state of the configuration has been changed to
+ 'used' and False if it the state wasn't changed. Reports an error
+ if the configuration isn't known.
+ """
+ if id not in self.all_:
+ #FIXME:
+ errors.error("common: the configuration '$(id)' is not known")
+
+ if id not in self.used_:
+ self.used_ += [id]
+
+ # indicate that the configuration has been marked as 'used'
+ return True
+ else:
+ return False
+
+ def all(self):
+ """ Return all registered configurations. """
+ return self.all_
+
+ def used(self):
+ """ Return all used configurations. """
+ return self.used_
+
+ def get(self, id, param):
+ """ Returns the value of a configuration parameter. """
+ self.params_.getdefault(param, {}).getdefault(id, None)
+
+ def set (self, id, param, value):
+ """ Sets the value of a configuration parameter. """
+ self.params_.setdefault(param, {})[id] = value
+
+# Ported from trunk_at_47174
+def check_init_parameters (toolset, requirement, *args):
+ """ The rule for checking toolset parameters. Trailing parameters should all be
+ parameter name/value pairs. The rule will check that each parameter either has
+ a value in each invocation or has no value in each invocation. Also, the rule
+ will check that the combination of all parameter values is unique in all
+ invocations.
+
+ Each parameter name corresponds to a subfeature. This rule will declare a
+ subfeature the first time a non-empty parameter value is passed and will
+ extend it with all the values.
-def check_init_parameters (toolset, *args):
- """ The rule checks toolset parameters. Each trailing parameter
- should be a tuple of parameter name and parameter value.
- The rule will check that each parameter either has value in
- each invocation, or has no value in each invocation. Also,
- the rule will check that the combination of all parameter values is
- unique in all invocations.
-
- Each parameter name corresponds to subfeature. This rule will declare subfeature
- the first time non-empty parameter value is passed, and will extend it with
- all the values.
-
The return value from this rule is a condition to be used for flags settings.
"""
sig = toolset
- condition = replace_grist (toolset, '<toolset>')
+ condition = replace_grist(toolset, '<toolset>')
+ subcondition = []
for arg in args:
- name = arg [0]
- value = arg [1]
-
- str_toolset_name = str ((toolset, name))
+ name = arg[0]
+ value = arg[1]
- if value == '':
+ str_toolset_name = str((toolset, name))
+
+ # FIXME: is this the correct translation?
+ ### if $(value)-is-not-empty
+ if value is not None:
condition = condition + '-' + value
- if __had_unspecified_value.has_key (str_toolset_name):
- raise BaseException ("'%s' initialization: parameter '%s' inconsistent\n" \
+ if __had_unspecified_value.has_key(str_toolset_name):
+ raise BaseException("'%s' initialization: parameter '%s' inconsistent\n" \
"no value was specified in earlier initialization\n" \
"an explicit value is specified now" % (toolset, name))
@@ -76,47 +172,65 @@
# be impossible to register versionles intel-linux and
# intel-win of specific version.
t = toolset
- m = __re__before_first_dash.match (toolset)
+ m = __re__before_first_dash.match(toolset)
if m:
- t = m.group (1)
+ t = m.group(1)
- if not __had_value.has_key (str_toolset_name):
- if not __declared_subfeature.has_key (str (t, name)):
- feature.subfeature ('toolset', t, name, [], ['propagated'])
- __declared_subfeature [str (t, name)] = True
+ if not __had_value.has_key(str_toolset_name):
+ if not __declared_subfeature.has_key(str((t, name))):
+ feature.subfeature('toolset', t, name, [], ['propagated'])
+ __declared_subfeature[str((t, name))] = True
- __had_value [str_toolset_name] = True
+ __had_value[str_toolset_name] = True
- feature.extend_subfeature ('toolset', t, name, [value])
+ feature.extend_subfeature('toolset', t, name, [value])
+ subcondition += ['<toolset-' + t + ':' + name + '>' + value ]
else:
- if __had_value.has_key (str_toolset_name):
+ if __had_value.has_key(str_toolset_name):
raise BaseException ("'%s' initialization: parameter '%s' inconsistent\n" \
"an explicit value was specified in an earlier initialization\n" \
"no value is specified now" % (toolset, name))
- __had_unspecified_value [str_toolset_name] = True
+ __had_unspecified_value[str_toolset_name] = True
if value == None: value = ''
sig = sig + value + '-'
- if __all_signatures.has_key (sig):
+ if __all_signatures.has_key(sig):
message = "duplicate initialization of '%s' with the following parameters: " % toolset
for arg in args:
- name = arg [0]
- value = arg [1]
+ name = arg[0]
+ value = arg[1]
if value == None: value = '<unspecified>'
message += "'%s' = '%s'\n" % (name, value)
- raise BaseException (message)
-
- __all_signatures [sig] = True
+ raise BaseException(message)
- # FIXME: we actually don't add any subfeatures to the condition
- return [condition]
+ __all_signatures[sig] = True
+ # FIXME
+ __init_loc[sig] = "User location unknown" #[ errors.nearest-user-location ] ;
+
+ # If we have a requirement, this version should only be applied under that
+ # condition. To accomplish this we add a toolset requirement that imposes
+ # the toolset subcondition, which encodes the version.
+ if requirement:
+ r = ['<toolset>' + toolset, requirement]
+ r = ','.join(r)
+ toolset.add_requirements([r + ':' + c for c in subcondition])
+
+ # We add the requirements, if any, to the condition to scope the toolset
+ # variables and options to this specific version.
+ condition = [condition]
+ if requirement:
+ condition += [requirement]
+
+ if __show_configuration:
+ print "notice:", condition
+ return ['/'.join(condition)]
# Ported from trunk_at_47077
def get_invocation_command_nodefault(
Modified: branches/build/python_port/python/boost/build/tools/darwin.py
==============================================================================
--- branches/build/python_port/python/boost/build/tools/darwin.py (original)
+++ branches/build/python_port/python/boost/build/tools/darwin.py 2008-07-09 00:02:57 EDT (Wed, 09 Jul 2008)
@@ -20,7 +20,7 @@
def init (version = None, command = None, options = None):
options = to_seq (options)
- condition = common.check_init_parameters ('darwin', ('version', version))
+ condition = common.check_init_parameters ('darwin', None, ('version', version))
command = common.get_invocation_command ('darwin', 'g++', command)
Modified: branches/build/python_port/python/boost/build/tools/gcc.py
==============================================================================
--- branches/build/python_port/python/boost/build/tools/gcc.py (original)
+++ branches/build/python_port/python/boost/build/tools/gcc.py 2008-07-09 00:02:57 EDT (Wed, 09 Jul 2008)
@@ -136,11 +136,11 @@
condition = None
if flavor:
- condition = common.check_init_parameters('gcc',
+ condition = common.check_init_parameters('gcc', None,
('version', version),
('flavor', flavor))
else:
- condition = common.check_init_parameters('gcc',
+ condition = common.check_init_parameters('gcc', None,
('version', version))
if command:
Boost-Commit 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