2
0
mirror of https://github.com/boostorg/build.git synced 2026-02-13 12:22:17 +00:00

Unbreak conditional requirements work.

[SVN r64305]
This commit is contained in:
Vladimir Prus
2010-07-23 15:08:14 +00:00
parent 3cb344b107
commit e963e2842c
4 changed files with 47 additions and 38 deletions

View File

@@ -357,7 +357,7 @@ def __expand_subfeatures_aux (property, dont_validate = False):
return result
def expand_subfeatures (properties, dont_validate = False):
def expand_subfeatures(properties, dont_validate = False):
"""
Make all elements of properties corresponding to implicit features
explicit, and express all subfeature values as separate properties

View File

@@ -44,8 +44,10 @@ class Property(object):
return self._condition
def to_raw(self):
# FIXME: include condition!
return "<" + self._feature.name() + ">" + self._value
result = "<" + self._feature.name() + ">" + self._value
if self._condition:
result = ",".join(str(p) for p in self._condition) + ':' + result
return result
def __str__(self):
return self.to_raw()
@@ -253,17 +255,20 @@ def expand_subfeatures_in_conditions (properties):
if not p.condition():
result.append(p)
else:
expanded = []
for c in p.condition():
for c in p.condition():
if c.feature().name().startswith("toolset") or c.feature().name() == "os":
# It common that condition includes a toolset which
# was never defined, or mentiones subfeatures which
# were never defined. In that case, validation will
# only produce an spirious error, so don't validate.
expanded.extend(feature.expand_subfeatures ([c], True))
else:
expanded.extend(feature.expand_subfeatures([c]))
if c.feature().name().startswith("toolset") or c.feature().name() == "os":
# It common that condition includes a toolset which
# was never defined, or mentiones subfeatures which
# were never defined. In that case, validation will
# only produce an spirious error, so don't validate.
result.extend(feature.expand_subfeatures ([c], True))
else:
result.extend(feature.expand_subfeatures([c]))
result.append(Property(p.feature(), p.value(), expanded))
return result
@@ -311,26 +316,21 @@ def evaluate_conditionals_in_context (properties, context):
in conditions are looked up in 'context'
"""
base = []
conditionals = []
conditional = []
for p in properties:
if __re_has_condition.search (p):
conditionals.append (p)
if p.condition():
conditional.append (p)
else:
base.append (p)
result = base
for p in conditionals:
for p in conditional:
# Separate condition and property
s = __re_separate_condition_and_property.match (p)
# Split condition into individual properties
conditions = s.group (1).split (',')
# Evaluate condition
if b2.util.set.contains (conditions, context):
result.append (s.group (2))
# Evaluate condition
# FIXME: probably inefficient
if all(x in context for x in p.condition()):
result.append(Property(p.feature(), p.value()))
return result

View File

@@ -96,7 +96,7 @@ class TargetRegistry:
# Current indent for debugging messages
self.indent_ = ""
self.debug_building_ = "--debug-building" in bjam.variable("ARGV")
self.debug_building_ = "--debug-building" in bjam.variable("ARV")
def main_target_alternative (self, target):
""" Registers the specified target as a main target alternatives.
@@ -869,17 +869,24 @@ class BasicTarget (AbstractTarget):
common to dependency build request and target build
properties.
"""
# For optimization, we add free requirements directly,
# For optimization, we add free unconditional requirements directly,
# without using complex algorithsm.
# This gives the complex algorithm better chance of caching results.
free = requirements.free ()
non_free = property_set.create(requirements.base() + requirements.incidental())
key = (build_request, non_free)
# This gives the complex algorithm better chance of caching results.
# The exact effect of this "optimization" is no longer clear
free_unconditional = []
other = []
for p in requirements.all():
if p.feature().free() and not p.condition():
free_unconditional.append(p)
else:
other.append(p)
other = property_set.create(other)
key = (build_request, other)
if not self.request_cache.has_key(key):
self.request_cache[key] = self.__common_properties2 (build_request, non_free)
self.request_cache[key] = self.__common_properties2 (build_request, other)
return self.request_cache[key].add_raw(free)
return self.request_cache[key].add_raw(free_unconditional)
# Given 'context' -- a set of already present properties, and 'requirements',
# decide which extra properties should be applied to 'context'.
@@ -906,7 +913,7 @@ class BasicTarget (AbstractTarget):
# <threading>single
#
# might come from project's requirements.
unconditional = feature.expand(requirements.non_conditional())
raw = context.all()
@@ -974,14 +981,14 @@ class BasicTarget (AbstractTarget):
# TODO: There is possibility that we've added <foo>bar, which is composite
# and expands to <foo2>bar2, but default value of <foo2> is not bar2,
# in which case it's not clear what to do.
#
#
build_request = build_request.add_defaults()
# Featured added by 'add-default' can be composite and expand
# to features without default values -- so they are not added yet.
# It could be clearer/faster to expand only newly added properties
# but that's not critical.
build_request = build_request.expand()
return self.evaluate_requirements(requirements, build_request,
"refined")
@@ -1077,7 +1084,7 @@ class BasicTarget (AbstractTarget):
result = GenerateResult ()
properties = rproperties.non_dependency ()
(p, u) = self.generate_dependencies (rproperties.dependency (), rproperties)
properties += p
usage_requirements = u

View File

@@ -438,6 +438,8 @@ class Tester(TestCmd.TestCmd):
% os.path.join(self.original_workdir, "test-config.jam"))
if ignore_toolset_requirements:
kw['program'].append("--ignore-toolset-requirements")
if "--python" in sys.argv:
kw['program'].append("--python")
kw['chdir'] = subdir
apply(TestCmd.TestCmd.run, [self], kw)
except: