コード例 #1
0
def compose(composite_property_s, component_properties_s):
    """ Sets the components of the given composite property.

    All paremeters are <feature>value strings
    """
    import property

    component_properties_s = to_seq(component_properties_s)
    composite_property = property.create_from_string(composite_property_s)
    f = composite_property.feature()

    if len(component_properties_s) > 0 and isinstance(
            component_properties_s[0], property.Property):
        component_properties = component_properties_s
    else:
        component_properties = [
            property.create_from_string(p) for p in component_properties_s
        ]

    if not f.composite():
        raise BaseException("'%s' is not a composite feature" % f)

    if __composite_properties.has_key(property):
        raise BaseException('components of "%s" already set: %s' %
                            (composite_property,
                             str(__composite_properties[composite_property])))

    if composite_property in component_properties:
        raise BaseException(
            'composite property "%s" cannot have itself as a component' %
            composite_property)

    __composite_properties[composite_property] = component_properties
コード例 #2
0
ファイル: feature.py プロジェクト: 0xDEC0DE8/mcsema
def compose (composite_property_s, component_properties_s):
    """ Sets the components of the given composite property.

    All paremeters are <feature>value strings
    """
    import property

    component_properties_s = to_seq (component_properties_s)
    composite_property = property.create_from_string(composite_property_s)
    f = composite_property.feature()

    if len(component_properties_s) > 0 and isinstance(component_properties_s[0], property.Property):
        component_properties = component_properties_s
    else:
        component_properties = [property.create_from_string(p) for p in component_properties_s]
                                       
    if not f.composite():
        raise BaseException ("'%s' is not a composite feature" % f)

    if __composite_properties.has_key(property):
        raise BaseException ('components of "%s" already set: %s' % (composite_property, str (__composite_properties[composite_property])))

    if composite_property in component_properties:
        raise BaseException ('composite property "%s" cannot have itself as a component' % composite_property)

    __composite_properties[composite_property] = component_properties
コード例 #3
0
def create(raw_properties=[]):
    """ Creates a new 'PropertySet' instance for the given raw properties,
        or returns an already existing one.
    """
    assert (is_iterable_typed(raw_properties, property.Property)
            or is_iterable_typed(raw_properties, basestring))
    # FIXME: propagate to callers.
    if len(raw_properties) > 0 and isinstance(raw_properties[0],
                                              property.Property):
        x = raw_properties
    else:
        x = [property.create_from_string(ps) for ps in raw_properties]

    # These two lines of code are optimized to the current state
    # of the Property class. Since this function acts as the caching
    # frontend to the PropertySet class modifying these two lines
    # could have a severe performance penalty. Be careful.
    # It would be faster to sort by p.id, but some projects may rely
    # on the fact that the properties are ordered alphabetically. So,
    # we maintain alphabetical sorting so as to maintain backward compatibility.
    x = sorted(set(x), key=lambda p: (p.feature.name, p.value, p.condition))
    key = tuple(p.id for p in x)

    if key not in __cache:
        __cache[key] = PropertySet(x)

    return __cache[key]
コード例 #4
0
ファイル: property_set.py プロジェクト: DanielaE/boost.build
def create (raw_properties = []):
    """ Creates a new 'PropertySet' instance for the given raw properties,
        or returns an already existing one.
    """
    assert (is_iterable_typed(raw_properties, property.Property)
            or is_iterable_typed(raw_properties, basestring))
    # FIXME: propagate to callers.
    if len(raw_properties) > 0 and isinstance(raw_properties[0], property.Property):
        x = raw_properties
    else:
        x = [property.create_from_string(ps) for ps in raw_properties]

    # These two lines of code are optimized to the current state
    # of the Property class. Since this function acts as the caching
    # frontend to the PropertySet class modifying these two lines
    # could have a severe performance penalty. Be careful.
    # It would be faster to sort by p.id, but some projects may rely
    # on the fact that the properties are ordered alphabetically. So,
    # we maintain alphabetical sorting so as to maintain backward compatibility.
    x = sorted(set(x), key=lambda p: (p.feature.name, p.value, p.condition))
    key = tuple(p.id for p in x)

    if key not in __cache:
        __cache [key] = PropertySet(x)

    return __cache [key]
コード例 #5
0
def create_with_validation(raw_properties):
    """ Creates new 'PropertySet' instances after checking
        that all properties are valid and converting incidental
        properties into gristed form.
    """
    properties = [property.create_from_string(s) for s in raw_properties]
    property.validate(properties)

    return create(properties)
コード例 #6
0
ファイル: property_set.py プロジェクト: Lecton/COS-700
def create_with_validation (raw_properties):
    """ Creates new 'PropertySet' instances after checking
        that all properties are valid and converting implicit
        properties into gristed form.
    """
    properties = [property.create_from_string(s) for s in raw_properties]
    property.validate(properties)

    return create(properties)
コード例 #7
0
ファイル: property_set.py プロジェクト: spit4520/pwdmanlib
def create_with_validation (raw_properties):
    """ Creates new 'PropertySet' instances after checking
        that all properties are valid and converting implicit
        properties into gristed form.
    """
    assert is_iterable_typed(raw_properties, basestring)
    properties = [property.create_from_string(s) for s in raw_properties]
    property.validate(properties)

    return create(properties)
コード例 #8
0
ファイル: property_set.py プロジェクト: Lecton/COS-700
def create (raw_properties = []):
    """ Creates a new 'PropertySet' instance for the given raw properties,
        or returns an already existing one.
    """
    # FIXME: propagate to callers.
    if len(raw_properties) > 0 and isinstance(raw_properties[0], property.Property):
        x = raw_properties
    else:
        x = [property.create_from_string(ps) for ps in raw_properties]
    x.sort()
    x = unique (x)

    # FIXME: can we do better, e.g. by directly computing
    # hash value of the list?
    key = tuple(x)

    if not __cache.has_key (key):
        __cache [key] = PropertySet(x)

    return __cache [key]
コード例 #9
0
ファイル: property_set.py プロジェクト: fineshift/boost
def create (raw_properties = []):
    """ Creates a new 'PropertySet' instance for the given raw properties,
        or returns an already existing one.
    """
    # FIXME: propagate to callers.
    if len(raw_properties) > 0 and isinstance(raw_properties[0], property.Property):
        x = raw_properties
    else:
        x = [property.create_from_string(ps) for ps in raw_properties]
    x.sort()
    x = unique(x, stable=True)

    # FIXME: can we do better, e.g. by directly computing
    # hash value of the list?
    key = tuple(x)

    if not __cache.has_key (key):
        __cache [key] = PropertySet(x)

    return __cache [key]
コード例 #10
0
ファイル: toolset.py プロジェクト: Bandeira/sps
def flags(rule_or_module, variable_name, condition, values=[]):
    """ Specifies the flags (variables) that must be set on targets under certain
        conditions, described by arguments.
        rule_or_module:   If contains dot, should be a rule name.
                          The flags will be applied when that rule is
                          used to set up build actions.
                          
                          If does not contain dot, should be a module name.
                          The flags will be applied for all rules in that
                          module.
                          If module for rule is different from the calling
                          module, an error is issued.

         variable_name:   Variable that should be set on target
         
         condition        A condition when this flag should be applied.
                          Should be set of property sets. If one of
                          those property sets is contained in build
                          properties, the flag will be used.
                          Implied values are not allowed:
                          "<toolset>gcc" should be used, not just
                          "gcc". Subfeatures, like in "<toolset>gcc-3.2"
                          are allowed. If left empty, the flag will
                          always used.
                          
                          Propery sets may use value-less properties 
                          ('<a>'  vs. '<a>value') to match absent 
                          properties. This allows to separately match
                          
                             <architecture>/<address-model>64
                             <architecture>ia64/<address-model>
                          
                          Where both features are optional. Without this
                          syntax we'd be forced to define "default" value.

         values:          The value to add to variable. If <feature>
                          is specified, then the value of 'feature' 
                          will be added.
    """
    caller = bjam.caller()
    if not "." in rule_or_module and caller and caller[:-1].startswith("Jamfile"):
        # Unqualified rule name, used inside Jamfile. Most likely used with
        # 'make' or 'notfile' rules. This prevents setting flags on the entire
        # Jamfile module (this will be considered as rule), but who cares?
        # Probably, 'flags' rule should be split into 'flags' and
        # 'flags-on-module'.
        rule_or_module = qualify_jam_action(rule_or_module, caller)
    else:
        # FIXME: revive checking that we don't set flags for a different
        # module unintentionally
        pass

    if condition and not replace_grist(condition, ""):
        # We have condition in the form '<feature>', that is, without
        # value. That's a previous syntax:
        #
        #   flags gcc.link RPATH <dll-path> ;
        # for compatibility, convert it to
        #   flags gcc.link RPATH : <dll-path> ;
        values = [condition]
        condition = None

    if condition:
        transformed = []
        for c in condition:
            # FIXME: 'split' might be a too raw tool here.
            pl = [property.create_from_string(s, False, True) for s in c.split("/")]
            pl = feature.expand_subfeatures(pl)
            transformed.append(property_set.create(pl))
        condition = transformed

        property.validate_property_sets(condition)

    __add_flag(rule_or_module, variable_name, condition, values)
コード例 #11
0
ファイル: toolset.py プロジェクト: AishwaryaDoosa/Boost1.49
def flags(rule_or_module, variable_name, condition, values=[]):
    """ Specifies the flags (variables) that must be set on targets under certain
        conditions, described by arguments.
        rule_or_module:   If contains dot, should be a rule name.
                          The flags will be applied when that rule is
                          used to set up build actions.
                          
                          If does not contain dot, should be a module name.
                          The flags will be applied for all rules in that
                          module.
                          If module for rule is different from the calling
                          module, an error is issued.

         variable_name:   Variable that should be set on target
         
         condition        A condition when this flag should be applied.
                          Should be set of property sets. If one of
                          those property sets is contained in build
                          properties, the flag will be used.
                          Implied values are not allowed:
                          "<toolset>gcc" should be used, not just
                          "gcc". Subfeatures, like in "<toolset>gcc-3.2"
                          are allowed. If left empty, the flag will
                          always used.
                          
                          Propery sets may use value-less properties 
                          ('<a>'  vs. '<a>value') to match absent 
                          properties. This allows to separately match
                          
                             <architecture>/<address-model>64
                             <architecture>ia64/<address-model>
                          
                          Where both features are optional. Without this
                          syntax we'd be forced to define "default" value.

         values:          The value to add to variable. If <feature>
                          is specified, then the value of 'feature' 
                          will be added.
    """
    caller = bjam.caller()[:-1]
    if not '.' in rule_or_module and caller.startswith("Jamfile"):
        # Unqualified rule name, used inside Jamfile. Most likely used with
        # 'make' or 'notfile' rules. This prevents setting flags on the entire
        # Jamfile module (this will be considered as rule), but who cares?
        # Probably, 'flags' rule should be split into 'flags' and
        # 'flags-on-module'.
        rule_or_module = qualify_jam_action(rule_or_module, caller)
    else:
        # FIXME: revive checking that we don't set flags for a different
        # module unintentionally
        pass

    if condition and not replace_grist(condition, ''):
        # We have condition in the form '<feature>', that is, without
        # value. That's a previous syntax:
        #
        #   flags gcc.link RPATH <dll-path> ;
        # for compatibility, convert it to
        #   flags gcc.link RPATH : <dll-path> ;
        values = [condition]
        condition = None

    if condition:
        transformed = []
        for c in condition:
            # FIXME: 'split' might be a too raw tool here.
            pl = [property.create_from_string(s) for s in c.split('/')]
            pl = feature.expand_subfeatures(pl)
            transformed.append(property_set.create(pl))
        condition = transformed

        property.validate_property_sets(condition)

    __add_flag(rule_or_module, variable_name, condition, values)