Exemplo n.º 1
0
    def import_(self, name, names_to_import=None, local_names=None):

        name = name[0]
        py_name = name
        if py_name == "os":
            py_name = "os_j"
        jamfile_module = self.registry.current().project_module()
        attributes = self.registry.attributes(jamfile_module)
        location = attributes.get("location")

        saved = self.registry.current()

        m = self.registry.load_module(py_name, [location])

        for f in m.__dict__:
            v = m.__dict__[f]
            f = f.replace("_", "-")
            if callable(v):
                qn = name + "." + f
                self._import_rule(jamfile_module, qn, v)
                record_jam_to_value_mapping(qualify_jam_action(qn, jamfile_module), v)


        if names_to_import:
            if not local_names:
                local_names = names_to_import

            if len(names_to_import) != len(local_names):
                self.registry.manager.errors()(
"""The number of names to import and local names do not match.""")

            for n, l in zip(names_to_import, local_names):
                self._import_rule(jamfile_module, l, m.__dict__[n])
                
        self.registry.set_current(saved)
    def import_(self, name, names_to_import=None, local_names=None):

        name = name[0]
        py_name = name
        if py_name == "os":
            py_name = "os_j"
        jamfile_module = self.registry.current().project_module()
        attributes = self.registry.attributes(jamfile_module)
        location = attributes.get("location")

        saved = self.registry.current()

        m = self.registry.load_module(py_name, [location])

        for f in m.__dict__:
            v = m.__dict__[f]
            f = f.replace("_", "-")
            if callable(v):
                qn = name + "." + f
                self._import_rule(jamfile_module, qn, v)
                record_jam_to_value_mapping(qualify_jam_action(qn, jamfile_module), v)

        if names_to_import:
            if not local_names:
                local_names = names_to_import

            if len(names_to_import) != len(local_names):
                self.registry.manager.errors()(
                    """The number of names to import and local names do not match.""")

            for n, l in zip(names_to_import, local_names):
                self._import_rule(jamfile_module, l, m.__dict__[n])

        self.registry.set_current(saved)
Exemplo n.º 3
0
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 p in properties:
        if p.value()[0] == "@":
            q = qualify_jam_action(p.value()[1:], context_module)
            get_manager().engine().register_bjam_action(q)
            result.append(Property(p.feature(), "@" + q, p.condition()))
        else:
            result.append(p)

    return result
Exemplo n.º 4
0
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 p in properties:
        if p.value()[0] == '@':
            q = qualify_jam_action(p.value()[1:], context_module)
            get_manager().engine().register_bjam_action(q)
            result.append(Property(p.feature(), '@' + q, p.condition()))
        else:
            result.append(p)

    return result
Exemplo n.º 5
0
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."""
    assert is_iterable_typed(properties, Property)
    assert isinstance(context_module, basestring)
    result = []
    for p in properties:
        if p.value[0] == '@':
            q = qualify_jam_action(p.value[1:], context_module)
            get_manager().engine().register_bjam_action(q)
            result.append(Property(p.feature, '@' + q, p.condition))
        else:
            result.append(p)

    return result
Exemplo n.º 6
0
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)
Exemplo n.º 7
0
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)