How to use the b2.build.feature function in b2

To help you get started, we’ve selected a few b2 examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github vslavik / poedit / tools / build / src / build / property.py View on Github external
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

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

    feature_name = get_grist(s)
    if not feature_name:
        if feature.is_implicit_value(s):
            f = feature.implied_feature(s)
            value = s
            p = Property(f, value, condition=condition)
        else:
            raise get_manager().errors()("Invalid property '%s' -- unknown feature" % s)
    else:
        value = get_value(s)
        if not value and not allow_missing_value:
            get_manager().errors()("Invalid property '%s' -- no value specified" % s)

        if feature.valid(feature_name):
            p = Property(feature.get(feature_name), value, condition=condition)
        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.
            #  is an unknown feature when using toolset Y.
            #
github ProteoWizard / pwiz / libraries / boost-build / build / build_request.py View on Github external
lresult = p.split(",")
            
        if p.find('-') == -1:
            # FIXME: first port property.validate
            # property.validate cannot handle subfeatures,
            # so we avoid the check here.
            #for p in lresult:
            #    property.validate(p)
            pass

        if not result:
            result = lresult
        else:
            result = [e1 + "/" + e2 for e1 in result for e2 in lresult]

    return [property_set.create(b2.build.feature.split(r)) for r in result]
github boostorg / build / src / build / property.py View on Github external
from b2.build import feature
from b2.util import sequence, qualify_jam_action, is_iterable_typed
import b2.util.set
from b2.manager import get_manager


__re_two_ampersands = re.compile ('&&')
__re_comma = re.compile (',')
__re_split_condition = re.compile ('(.*):(<.*)')
__re_split_conditional = re.compile (r'(.+):<(.+)')
__re_colon = re.compile (':')
__re_has_condition = re.compile (r':<')
__re_separate_condition_and_property = re.compile (r'(.*):(<.*)')

_not_applicable_feature='not-applicable-in-this-context'
feature.feature(_not_applicable_feature, [], ['free'])

__abbreviated_paths = False


class PropertyMeta(type):
    """
    This class exists to implement the isinstance() and issubclass()
    hooks for the Property class. Since we've introduce the concept of
    a LazyProperty, isinstance(p, Property) will fail when p is a LazyProperty.
    Implementing both __instancecheck__ and __subclasscheck__ will allow
    LazyProperty instances to pass the isinstance() and issubclass check for
    the Property class.

    Additionally, the __call__ method intercepts the call to the Property
    constructor to ensure that calling Property with the same arguments
    will always return the same Property instance.
github vslavik / poedit / tools / build / src / tools / builtin.py View on Github external
# If name is empty, it means we're called not from top-level.
        # In this case, we just fail immediately, because SearchedLibGenerator
        # cannot be used to produce intermediate targets.

        properties = prop_set.raw ()
        shared = 'shared' in properties

        a = virtual_target.NullAction (project.manager(), prop_set)

        real_name = feature.get_values ('', properties)
        if real_name:
            real_name = real_name[0]
        else:
            real_name = name
        search = feature.get_values('', properties)
        usage_requirements = property_set.create(['' + p for p in search])
        t = SearchedLibTarget(real_name, project, shared, search, a)

        # We return sources for a simple reason. If there's
        #    lib png : z : png ;
        # the 'z' target should be returned, so that apps linking to
        # 'png' will link to 'z', too.
        return(usage_requirements, [b2.manager.get_manager().virtual_targets().register(t)] + sources)
github clasp-developers / clasp / externals / boostbuild2 / src / build / property.py View on Github external
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.
            #  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  feature.
github PDAL / PDAL / boost / tools / build / v2 / tools / pch.py View on Github external
#
# Add cpp-pch to sources:
#
#    exe hello
#      : main.cpp hello.cpp mypch
#      ;

from b2.build import type, feature, generators
from b2.tools import builtin

type.register('PCH', ['pch'])
type.register('C_PCH', [], 'PCH')
type.register('CPP_PCH', [], 'PCH')

# Control precompiled header (PCH) generation.
feature.feature('pch',
                ['on', 'off'],
                ['propagated'])

feature.feature('pch-header', [], ['free', 'dependency'])
feature.feature('pch-file', [], ['free', 'dependency'])

class PchGenerator(generators.Generator):
    """
        Base PCH generator. The 'run' method has the logic to prevent this generator
        from being run unless it's being used for a top-level PCH target.
    """
    def action_class(self):
        return builtin.CompileAction

    def run(self, project, name, prop_set, sources):
        if not name:
github boostorg / build / src / build / property.py View on Github external
def remove(attributes, properties):
    """Returns a property sets which include all the elements
    in 'properties' that do not have attributes listed in 'attributes'."""
    
    result = []
    for e in properties:
        attributes_new = feature.attributes(get_grist(e))
        has_common_features = 0
        for a in attributes_new:
            if a in attributes:
                has_common_features = 1
                break

        if not has_common_features:
            result += e

    return result
github ProteoWizard / pwiz / libraries / boost-build / tools / builtin.py View on Github external
# If name is empty, it means we're called not from top-level.
        # In this case, we just fail immediately, because SearchedLibGenerator
        # cannot be used to produce intermediate targets.
        
        properties = prop_set.raw ()
        shared = 'shared' in properties

        a = virtual_target.NullAction (project.manager(), prop_set)
        
        real_name = feature.get_values ('', properties)
        if real_name:
            real_name = real_name[0]
        else:
            real_name = name
        search = feature.get_values('', properties)
        usage_requirements = property_set.create(['' + p for p in search])
        t = SearchedLibTarget(real_name, project, shared, search, a)

        # We return sources for a simple reason. If there's
        #    lib png : z : png ; 
        # the 'z' target should be returned, so that apps linking to
        # 'png' will link to 'z', too.
        return(usage_requirements, [b2.manager.get_manager().virtual_targets().register(t)] + sources)
github ProteoWizard / pwiz / libraries / boost-build / build / property_set.py View on Github external
def get (self, feature):
        """ Returns all values of 'feature'.
        """
        if type(feature) == type([]):
            feature = feature[0]
        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.value())

        return self.feature_map_.get(feature, [])
github SilverIce / JContainers / dep / boost / tools / build / src / build / property.py View on Github external
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.
            #  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  feature.
            #