summaryrefslogtreecommitdiff
path: root/tools/build/src/build/build_request.py
diff options
context:
space:
mode:
Diffstat (limited to 'tools/build/src/build/build_request.py')
-rw-r--r--tools/build/src/build/build_request.py76
1 files changed, 41 insertions, 35 deletions
diff --git a/tools/build/src/build/build_request.py b/tools/build/src/build/build_request.py
index 118033e1e1..1942516887 100644
--- a/tools/build/src/build/build_request.py
+++ b/tools/build/src/build/build_request.py
@@ -11,18 +11,20 @@ import b2.build.feature
feature = b2.build.feature
from b2.util.utility import *
+from b2.util import is_iterable_typed
import b2.build.property_set as property_set
def expand_no_defaults (property_sets):
""" Expand the given build request by combining all property_sets which don't
specify conflicting non-free features.
"""
+ assert is_iterable_typed(property_sets, property_set.PropertySet)
# First make all features and subfeatures explicit
expanded_property_sets = [ps.expand_subfeatures() for ps in property_sets]
-
+
# Now combine all of the expanded property_sets
product = __x_product (expanded_property_sets)
-
+
return [property_set.create(p) for p in product]
@@ -30,6 +32,7 @@ def __x_product (property_sets):
""" Return the cross-product of all elements of property_sets, less any
that would contain conflicting values for single-valued features.
"""
+ assert is_iterable_typed(property_sets, property_set.PropertySet)
x_product_seen = set()
return __x_product_aux (property_sets, x_product_seen)[0]
@@ -42,8 +45,10 @@ def __x_product_aux (property_sets, seen_features):
Returns a tuple of:
- list of lists of Property instances, such that within each list, no two Property instance
have the same feature, and no Property is for feature in seen_features.
- - set of features we saw in property_sets
+ - set of features we saw in property_sets
"""
+ assert is_iterable_typed(property_sets, property_set.PropertySet)
+ assert isinstance(seen_features, set)
if not property_sets:
return ([], set())
@@ -76,7 +81,7 @@ def __x_product_aux (property_sets, seen_features):
result.append(properties + inner)
else:
result.append(properties)
-
+
if inner_seen & these_features:
# Some of elements in property_sets[1:] conflict with elements of property_sets[0],
# Try again, this time omitting elements of property_sets[0]
@@ -85,11 +90,12 @@ def __x_product_aux (property_sets, seen_features):
return (result, inner_seen | these_features)
-
+
def looks_like_implicit_value(v):
"""Returns true if 'v' is either implicit value, or
the part before the first '-' symbol is implicit value."""
+ assert isinstance(v, basestring)
if feature.is_implicit_value(v):
return 1
else:
@@ -104,7 +110,7 @@ def from_command_line(command_line):
and constructs build request from it. Returns a list of two
lists. First is the set of targets specified in the command line,
and second is the set of requested build properties."""
-
+ assert is_iterable_typed(command_line, basestring)
targets = []
properties = []
@@ -112,17 +118,17 @@ def from_command_line(command_line):
if e[:1] != "-":
# Build request spec either has "=" in it, or completely
# consists of implicit feature values.
- if e.find("=") != -1 or looks_like_implicit_value(e.split("/")[0]):
- properties += convert_command_line_element(e)
+ if e.find("=") != -1 or looks_like_implicit_value(e.split("/")[0]):
+ properties.append(e)
elif e:
targets.append(e)
return [targets, properties]
-
+
# Converts one element of command line build request specification into
# internal form.
def convert_command_line_element(e):
-
+ assert isinstance(e, basestring)
result = None
parts = e.split("/")
for p in parts:
@@ -133,7 +139,7 @@ def convert_command_line_element(e):
lresult = [("<%s>%s" % (feature, v)) for v in values]
else:
lresult = p.split(",")
-
+
if p.find('-') == -1:
# FIXME: first port property.validate
# property.validate cannot handle subfeatures,
@@ -149,68 +155,68 @@ def convert_command_line_element(e):
return [property_set.create(b2.build.feature.split(r)) for r in result]
-###
+###
### rule __test__ ( )
### {
### import assert feature ;
-###
+###
### feature.prepare-test build-request-test-temp ;
-###
+###
### import build-request ;
### import build-request : expand_no_defaults : build-request.expand_no_defaults ;
### import errors : try catch ;
### import feature : feature subfeature ;
-###
+###
### feature toolset : gcc msvc borland : implicit ;
### subfeature toolset gcc : version : 2.95.2 2.95.3 2.95.4
### 3.0 3.0.1 3.0.2 : optional ;
-###
+###
### feature variant : debug release : implicit composite ;
### feature inlining : on off ;
### feature "include" : : free ;
-###
+###
### feature stdlib : native stlport : implicit ;
-###
+###
### feature runtime-link : dynamic static : symmetric ;
-###
-###
+###
+###
### local r ;
-###
-### r = [ build-request.from-command-line bjam debug runtime-link=dynamic ] ;
+###
+### r = [ build-request.from-command-line bjam debug runtime-link=dynamic ] ;
### assert.equal [ $(r).get-at 1 ] : ;
### assert.equal [ $(r).get-at 2 ] : debug <runtime-link>dynamic ;
-###
+###
### try ;
### {
-###
+###
### build-request.from-command-line bjam gcc/debug runtime-link=dynamic/static ;
### }
### catch \"static\" is not a value of an implicit feature ;
-###
-###
+###
+###
### r = [ build-request.from-command-line bjam -d2 --debug debug target runtime-link=dynamic ] ;
### assert.equal [ $(r).get-at 1 ] : target ;
### assert.equal [ $(r).get-at 2 ] : debug <runtime-link>dynamic ;
-###
+###
### r = [ build-request.from-command-line bjam debug runtime-link=dynamic,static ] ;
### assert.equal [ $(r).get-at 1 ] : ;
### assert.equal [ $(r).get-at 2 ] : debug <runtime-link>dynamic <runtime-link>static ;
-###
+###
### r = [ build-request.from-command-line bjam debug gcc/runtime-link=dynamic,static ] ;
### assert.equal [ $(r).get-at 1 ] : ;
-### assert.equal [ $(r).get-at 2 ] : debug gcc/<runtime-link>dynamic
+### assert.equal [ $(r).get-at 2 ] : debug gcc/<runtime-link>dynamic
### gcc/<runtime-link>static ;
-###
+###
### r = [ build-request.from-command-line bjam msvc gcc,borland/runtime-link=static ] ;
### assert.equal [ $(r).get-at 1 ] : ;
-### assert.equal [ $(r).get-at 2 ] : msvc gcc/<runtime-link>static
+### assert.equal [ $(r).get-at 2 ] : msvc gcc/<runtime-link>static
### borland/<runtime-link>static ;
-###
+###
### r = [ build-request.from-command-line bjam gcc-3.0 ] ;
### assert.equal [ $(r).get-at 1 ] : ;
### assert.equal [ $(r).get-at 2 ] : gcc-3.0 ;
-###
+###
### feature.finish-test build-request-test-temp ;
### }
-###
-###
+###
+###