Beispiel #1
0
def create_from_string(s, allow_condition=False, allow_missing_value=False):
    assert isinstance(s, basestring)
    assert isinstance(allow_condition, bool)
    assert isinstance(allow_missing_value, bool)
    condition = []
    import types
    if not isinstance(s, types.StringType):
        print type(s)
    if __re_has_condition.search(s):

        if not allow_condition:
            raise BaseException(
                "Conditional property is not allowed in this context")

        m = __re_separate_condition_and_property.match(s)
        condition = m.group(1)
        s = m.group(2)

    # FIXME: break dependency cycle
    from b2.manager import get_manager

    feature_name = get_grist(s)
    if not feature_name:
        if feature.is_implicit_value(s):
            f = feature.implied_feature(s)
            value = s
        else:
            raise get_manager().errors()(
                "Invalid property '%s' -- unknown feature" % s)
    else:
        if feature.valid(feature_name):
            f = feature.get(feature_name)
            value = get_value(s)
        else:
            # In case feature name is not known, it is wrong to do a hard error.
            # Feature sets change depending on the toolset. So e.g.
            # <toolset-X:version> is an unknown feature when using toolset Y.
            #
            # Ideally we would like to ignore this value, but most of
            # Boost.Build code expects that we return a valid Property. For this
            # reason we use a sentinel <not-applicable-in-this-context> feature.
            #
            # The underlying cause for this problem is that python port Property
            # is more strict than its Jam counterpart and must always reference
            # a valid feature.
            f = feature.get(__not_applicable_feature)
            value = s

        if not value and not allow_missing_value:
            get_manager().errors()(
                "Invalid property '%s' -- no value specified" % s)

    if condition:
        condition = [create_from_string(x) for x in condition.split(',')]

    return Property(f, value, condition)
Beispiel #2
0
def create_from_string(s, allow_condition=False,allow_missing_value=False):
    assert isinstance(s, basestring)
    assert isinstance(allow_condition, bool)
    assert isinstance(allow_missing_value, bool)
    condition = []
    import types
    if not isinstance(s, types.StringType):
        print type(s)
    if __re_has_condition.search(s):

        if not allow_condition:
            raise BaseException("Conditional property is not allowed in this context")

        m = __re_separate_condition_and_property.match(s)
        condition = m.group(1)
        s = m.group(2)

    # FIXME: break dependency cycle
    from b2.manager import get_manager

    feature_name = get_grist(s)
    if not feature_name:
        if feature.is_implicit_value(s):
            f = feature.implied_feature(s)
            value = s
        else:
            raise get_manager().errors()("Invalid property '%s' -- unknown feature" % s)
    else:
        if feature.valid(feature_name):
            f = feature.get(feature_name)
            value = get_value(s)
        else:
            # In case feature name is not known, it is wrong to do a hard error.
            # Feature sets change depending on the toolset. So e.g.
            # <toolset-X:version> is an unknown feature when using toolset Y.
            #
            # Ideally we would like to ignore this value, but most of
            # Boost.Build code expects that we return a valid Property. For this
            # reason we use a sentinel <not-applicable-in-this-context> feature.
            #
            # The underlying cause for this problem is that python port Property
            # is more strict than its Jam counterpart and must always reference
            # a valid feature.
            f = feature.get(__not_applicable_feature)
            value = s

        if not value and not allow_missing_value:
            get_manager().errors()("Invalid property '%s' -- no value specified" % s)


    if condition:
        condition = [create_from_string(x) for x in condition.split(',')]

    return Property(f, value, condition)
Beispiel #3
0
 def __getattr__(self, item):
     if self.__feature is None:
         try:
             self.__feature = feature.get(self.__name)
             self.__property = Property(self.__feature, self.__value, self.__condition)
         except KeyError:
             pass
     return getattr(self.__property, item)
Beispiel #4
0
 def __init__(self, f, value, condition=[]):
     if type(f) == type(""):
         f = feature.get(f)
     # At present, single property has a single value.
     assert type(value) != type([])
     assert f.free() or value.find(":") == -1
     self._feature = f
     self._value = value
     self._condition = condition
Beispiel #5
0
 def __init__(self, f, value, condition=[]):
     if type(f) == type(""):
         f = feature.get(f)
     # At present, single property has a single value.
     assert type(value) != type([])
     assert (f.free() or value.find(':') == -1)
     self._feature = f
     self._value = value
     self._condition = condition
Beispiel #6
0
 def __getattr__(self, item):
     if self.__feature is None:
         try:
             self.__feature = feature.get(self.__name)
             self.__property = Property(self.__feature, self.__value,
                                        self.__condition)
         except KeyError:
             pass
     return getattr(self.__property, item)
Beispiel #7
0
    def __init__(self, feature_name, value, condition=None):
        if condition is None:
            condition = []

        self.__property = Property(
            feature.get(_not_applicable_feature), feature_name + value, condition=condition)
        self.__name = feature_name
        self.__value = value
        self.__condition = condition
        self.__feature = None
Beispiel #8
0
    def __init__(self, feature_name, value, condition=None):
        if condition is None:
            condition = []

        self.__property = Property(feature.get(_not_applicable_feature),
                                   feature_name + value,
                                   condition=condition)
        self.__name = feature_name
        self.__value = value
        self.__condition = condition
        self.__feature = None
Beispiel #9
0
    def __call__(mcs, f, value, condition=None):
        """
        This intercepts the call to the Property() constructor.

        This exists so that the same arguments will always return the same Property
        instance. This allows us to give each instance a unique ID.
        """
        from b2.build.feature import Feature
        if not isinstance(f, Feature):
            f = feature.get(f)
        if condition is None:
            condition = []
        key = (f, value) + tuple(sorted(condition))
        if key not in mcs._registry:
            instance = super(PropertyMeta, mcs).__call__(f, value, condition)
            mcs._registry[key] = instance
        return mcs._registry[key]
Beispiel #10
0
    def __call__(mcs, f, value, condition=None):
        """
        This intercepts the call to the Property() constructor.

        This exists so that the same arguments will always return the same Property
        instance. This allows us to give each instance a unique ID.
        """
        from b2.build.feature import Feature
        if not isinstance(f, Feature):
            f = feature.get(f)
        if condition is None:
            condition = []
        key = (f, value) + tuple(sorted(condition))
        if key not in mcs._registry:
            instance = super(PropertyMeta, mcs).__call__(f, value, condition)
            mcs._registry[key] = instance
        return mcs._registry[key]
Beispiel #11
0
    def generate(self, ps):
        global top_level_targets
        top_level_targets.append(self.name())

        if build_type == "minimal":

            os = ps.get('target-os')
            # Because we completely override parent's 'generate'
            # we need to check for default value of feature ourself.
            if not os:
                os = feature.get('target-os').default()

            if os == "windows":
                expanded = targets.apply_default_build(
                    ps, self.minimal_properties_win)
            else:
                expanded = targets.apply_default_build(ps,
                                                       self.minimal_properties)
            return self.build_multiple(expanded)

        elif build_type == "complete":

            expanded = targets.apply_default_build(ps,
                                                   self.complete_properties)

            # Filter inappopriate combinations
            filtered = []
            for p in expanded:

                # See comment in handle-static-runtime regarding this logic.
                if ps.get("link") == ["shared"] and p.get("runtime-link") == ["static"] \
                   and p.get("toolset") != ["cw"]:
                    # Skip this
                    pass
                else:
                    filtered.append(p)

            return build_multiple(filtered)

        else:

            get_manager().errors("Unknown build type")
Beispiel #12
0
def create_from_string(s, allow_condition=False):

    condition = []
    import types
    if not isinstance(s, types.StringType):
        print type(s)
    if __re_has_condition.search(s):

        if not allow_condition:
            raise BaseException(
                "Conditional property is not allowed in this context")

        m = __re_separate_condition_and_property.match(s)
        condition = m.group(1)
        s = m.group(2)

    # FIXME: break dependency cycle
    from b2.manager import get_manager

    feature_name = get_grist(s)
    if not feature_name:
        if feature.is_implicit_value(s):
            f = feature.implied_feature(s)
            value = s
        else:
            raise get_manager().errors()(
                "Invalid property '%s' -- unknown feature" % s)
    else:
        f = feature.get(feature_name)

        value = get_value(s)
        if not value:
            get_manager().errors()(
                "Invalid property '%s' -- no value specified" % s)

    if condition:
        condition = [create_from_string(x) for x in condition.split(',')]

    return Property(f, value, condition)
Beispiel #13
0
    def generate(self, ps):
        global top_level_targets
        top_level_targets.append(self.name())

        if build_type == "minimal":

            os = ps.get('target-os')
            # Because we completely override parent's 'generate'
            # we need to check for default value of feature ourself.
            if not os:
                os = feature.get('target-os').default()

            if os == "windows":
                expanded = targets.apply_default_build(ps, self.minimal_properties_win)
            else:
                expanded = targets.apply_default_build(ps, self.minimal_properties)
            return self.build_multiple(expanded)

        elif build_type == "complete":

            expanded = targets.apply_default_build(ps, self.complete_properties)
            
            # Filter inappopriate combinations
            filtered = []
            for p in expanded:

                # See comment in handle-static-runtime regarding this logic.
                if ps.get("link") == ["shared"] and p.get("runtime-link") == ["static"] \
                   and p.get("toolset") != ["cw"]:
                    # Skip this
                    pass
                else:
                    filtered.append(p)
                    
            return build_multiple(filtered)

        else:

            get_manager().errors("Unknown build type")
Beispiel #14
0
def create_from_string(s, allow_condition=False, allow_missing_value=False):

    condition = []
    import types

    if not isinstance(s, types.StringType):
        print type(s)
    if __re_has_condition.search(s):

        if not allow_condition:
            raise BaseException("Conditional property is not allowed in this context")

        m = __re_separate_condition_and_property.match(s)
        condition = m.group(1)
        s = m.group(2)

    # FIXME: break dependency cycle
    from b2.manager import get_manager

    feature_name = get_grist(s)
    if not feature_name:
        if feature.is_implicit_value(s):
            f = feature.implied_feature(s)
            value = s
        else:
            raise get_manager().errors()("Invalid property '%s' -- unknown feature" % s)
    else:
        f = feature.get(feature_name)

        value = get_value(s)
        if not value and not allow_missing_value:
            get_manager().errors()("Invalid property '%s' -- no value specified" % s)

    if condition:
        condition = [create_from_string(x) for x in condition.split(",")]

    return Property(f, value, condition)