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

More fixups

[SVN r64290]
This commit is contained in:
Vladimir Prus
2010-07-23 10:52:36 +00:00
parent 89fbab2f72
commit f6b618d47e
5 changed files with 41 additions and 58 deletions

View File

@@ -727,7 +727,7 @@ class ProjectAttributes:
# FIXME:
#errors.error "usage-requirements" $(specification) "have non-free properties" $(non-free) ;
t = property.translate_paths(specification, self.location)
t = property.translate_paths(property.create_from_strings(specification), self.location)
existing = self.__dict__.get("usage-requirements")
if existing:

View File

@@ -94,6 +94,10 @@ def create_from_string(s, allow_condition = False):
return Property(f, value, condition)
def create_from_strings(string_list, validate=False):
return [create_from_string(s, validate) for s in string_list]
def reset ():
""" Clear the module state. This is mainly for testing purposes.
"""
@@ -180,45 +184,39 @@ def translate_paths (properties, path):
result = []
for p in properties:
split = split_conditional (p)
condition = ''
if p.feature().path():
values = __re_two_ampersands.split(p.value())
new_value = "&&".join(os.path.join(path, v) for v in values)
if split:
condition = split [0]
p = split [1]
if get_grist (p) and 'path' in feature.attributes (get_grist (p)):
values = __re_two_ampersands.split (forward_slashes (replace_grist (p, "")))
t = [os.path.join(path, v) for v in values]
t = '&&'.join (t)
tp = replace_grist (t, get_grist (p)).replace("\\", "/")
result.append (condition + tp)
if new_value != p.value():
result.append(Property(p.feature(), new_value, p.condition()))
else:
result.append(p)
else:
result.append (condition + ":" + p)
result.append (p)
return result
def translate_indirect(specification, context_module):
def translate_indirect(properties, context_module):
"""Assumes that all feature values that start with '@' are
names of rules, used in 'context-module'. Such rules can be
either local to the module or global. Qualified local rules
with the name of the module."""
result = []
for px in specification:
p = get_value(px)
if p[0] == '@':
for p in properties:
if p.value()[0] == '@':
v = None
m = p[1:]
m = p.value()[1:]
if __re_indirect_rule.match(m):
# Rule is already in indirect format
# FIXME: it's not clear if this is necessary.
v = m
else:
if not '.' in p:
if not '.' in m:
# This is unqualified rule name. The user might want
# to set flags on this rule name, and toolset.flag
# auto-qualifies the rule name. Need to do the same
@@ -232,9 +230,9 @@ def translate_indirect(specification, context_module):
#v = indirect.make(m, context_module)
get_manager().engine().register_bjam_action(v)
result.append(get_grist(px) + "@" + m)
result.append(Property(p.feature(), "@" + m, p.condition()))
else:
result.append(px)
result.append(p)
return result
@@ -270,24 +268,6 @@ def expand_subfeatures_in_conditions (properties):
return result
def make (specification):
""" Converts implicit values into full properties.
"""
result = []
for e in specification:
if get_grist (e):
result.append (e)
elif feature.is_implicit_value (e):
f = feature.implied_feature (e)
result.append (f + e)
else:
raise InvalidProperty ("'%s' is not a valid for property specification" % e)
return result
# FIXME: this should go
def split_conditional (property):
""" If 'property' is conditional property, returns

View File

@@ -8,6 +8,7 @@
from b2.util.utility import *
import property, feature, string
import b2.build.feature
from b2.exceptions import *
from b2.util.sequence import unique
from b2.util.set import difference
@@ -64,10 +65,9 @@ def create_from_user_input(raw_properties, jamfile_module, location):
"""Creates a property-set from the input given by the user, in the
context of 'jamfile-module' at 'location'"""
specification = property.translate_paths(raw_properties, location)
specification = property.translate_indirect(specification, jamfile_module)
specification = property.make(specification)
properties = [property.create_from_string(s, True) for s in specification]
properties = property.create_from_strings(raw_properties, True)
properties = property.translate_paths(properties, location)
properties = property.translate_indirect(properties, jamfile_module)
properties = property.expand_subfeatures_in_conditions(properties)
return create(properties)
@@ -414,15 +414,18 @@ class PropertySet:
def get (self, feature):
""" Returns all properties for 'feature'.
""" Returns all values of 'feature'.
"""
if not isinstance(feature, b2.build.feature.Feature):
feature = b2.build.feature.get(feature)
if not self.feature_map_:
self.feature_map_ = {}
for v in self.all_:
if not self.feature_map_.has_key(v.feature()):
self.feature_map_[v.feature()] = []
self.feature_map_[v.feature()].append(v)
self.feature_map_[v.feature()].append(v.value())
return self.feature_map_.get(feature, [])

View File

@@ -163,7 +163,7 @@ def find_satisfied_condition(conditions, ps):
found = False
if i.value():
found = i in ps.get(i.feature())
found = i.value() in ps.get(i.feature())
else:
# Handle value-less properties like '<architecture>' (compare with
# '<architecture>x86').
@@ -310,32 +310,27 @@ def __handle_flag_value (manager, value, ps):
if get_grist (value):
f = feature.get(value)
properties = ps.get(f)
values = ps.get(f)
for p in properties:
value = p.value()
for value in values:
if f.dependency():
# the value of a dependency feature is a target
# and must be actualized
# FIXME: verify that 'find' actually works, ick!
result.append (manager.targets ().find (p.value()).actualize ())
result.append (manager.targets ().find(value).actualize ())
elif f.path() or f.free():
values = []
# Treat features with && in the value
# specially -- each &&-separated element is considered
# separate value. This is needed to handle searched
# libraries, which must be in specific order.
if not __re_two_ampersands.search(value):
values.append(value)
result.append(value)
else:
values.extend(value.split ('&&'))
result.extend(values)
result.extend(value.split ('&&'))
else:
result.append (ungristed)
else:

View File

@@ -290,6 +290,11 @@ def register_globals ():
'armv5t', 'armv5te', 'armv6', 'armv6j', 'iwmmxt', 'ep9312'],
['propagated', 'optional'])
feature.feature('conditional', [], ['incidental', 'free'])
# The value of 'no' prevents building of a target.
feature.feature('build', ['yes', 'no'], ['optional'])
# Windows-specific features
feature.feature ('user-interface', ['console', 'gui', 'wince', 'native', 'auto'], [])