How to use the b2.util.is_iterable_typed 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 stan-dev / math / lib / boost_1.69.0 / tools / build / src / tools / common.py View on Github external
def get_invocation_command_nodefault(
    toolset, tool, user_provided_command=[], additional_paths=[], path_last=False):
    """
        A helper rule to get the command to invoke some tool. If
        'user-provided-command' is not given, tries to find binary named 'tool' in
        PATH and in the passed 'additional-path'. Otherwise, verifies that the first
        element of 'user-provided-command' is an existing program.

        This rule returns the command to be used when invoking the tool. If we can't
        find the tool, a warning is issued. If 'path-last' is specified, PATH is
        checked after 'additional-paths' when searching for 'tool'.
    """
    assert isinstance(toolset, basestring)
    assert isinstance(tool, basestring)
    assert is_iterable_typed(user_provided_command, basestring)
    assert is_iterable_typed(additional_paths, basestring) or additional_paths is None
    assert isinstance(path_last, (int, bool))

    if not user_provided_command:
        command = find_tool(tool, additional_paths, path_last)
        if not command and __debug_configuration:
            print "warning: toolset", toolset, "initialization: can't find tool, tool"
            #FIXME
            #print "warning: initialized from" [ errors.nearest-user-location ] ;
    else:
        command = check_tool(user_provided_command)
        if not command and __debug_configuration:
            print "warning: toolset", toolset, "initialization:"
            print "warning: can't find user-provided command", user_provided_command
            #FIXME
            #ECHO "warning: initialized from" [ errors.nearest-user-location ]
            command = []
github mzdb / pwiz-mzdb / libraries / boost-build / src / build / targets.py View on Github external
def main_target_default_build (self, specification, project):
        """ Return the default build value to use when declaring a main target,
            which is obtained by using specified value if not empty and parent's
            default build attribute otherwise.
            specification:  Default build explicitly specified for a main target
            project:        Project where the main target is to be declared
        """
        assert is_iterable_typed(specification, basestring)
        assert isinstance(project, ProjectTarget)
        if specification:
            return property_set.create_with_validation(specification)
        else:
            return project.get ('default-build')
github vslavik / poedit / tools / build / src / build / feature.py View on Github external
then the default value of F1 will be added, not the value in F2. This might
        not be right idea: consider

          feature variant : debug ... ;
               debug : .... on
          feature  : off on ;

          Here, when adding default for an empty property set, we'll get

            debug off

          and that's kind of strange.
    """
    if __debug__:
        from .property import Property
        assert is_iterable_typed(properties, Property)
    # create a copy since properties will be modified
    result = list(properties)

    # We don't add default for conditional properties.  We don't want
    # debug:DEBUG to be takes as specified value for 
    handled_features = set(p.feature for p in properties if not p.condition)

    missing_top = [f for f in __all_top_features if not f in handled_features]
    more = defaults(missing_top)
    result.extend(more)
    handled_features.update(p.feature for p in more)

    # Add defaults for subfeatures of features which are present
    for p in result[:]:
        subfeatures = [s for s in p.feature.subfeatures if not s in handled_features]
        more = defaults(__select_subfeatures(p, subfeatures))
github vslavik / poedit / tools / build / src / build / feature.py View on Github external
def __select_subfeatures (parent_property, features):
    """ Given a property, return the subset of features consisting of all
        ordinary subfeatures of the property's feature, and all specific
        subfeatures of the property's feature which are conditional on the
        property's value.
    """
    if __debug__:
        from .property import Property
        assert isinstance(parent_property, Property)
        assert is_iterable_typed(features, Feature)
    return [f for f in features if is_subfeature_of (parent_property, f)]
github vslavik / poedit / tools / build / src / build / project.py View on Github external
def path_constant(self, name, value):
        """Declare and set a project global constant, whose value is a path. The
        path is adjusted to be relative to the invocation directory. The given
        value path is taken to be either absolute, or relative to this project
        root."""
        assert is_iterable_typed(name, basestring)
        assert is_iterable_typed(value, basestring)
        if len(value) > 1:
            self.registry.manager.errors()("path constant should have one element")
        self.registry.current().add_constant(name[0], value, path=1)
github vslavik / poedit / tools / build / src / build / generators.py View on Github external
def construct_result (self, consumed, project, name, prop_set):
        """ Constructs the dependency graph that will be returned by this
            generator.
                consumed:        Already prepared list of consumable targets
                                 If generator requires several source files will contain
                                 exactly len $(self.source_types_) targets with matching types
                                 Otherwise, might contain several targets with the type of
                                 self.source_types_ [0]
                project:
                name:
                prop_set:        Properties to be used for all actions create here
        """
        if __debug__:
            from .targets import ProjectTarget
            assert is_iterable_typed(consumed, virtual_target.VirtualTarget)
            assert isinstance(project, ProjectTarget)
            assert isinstance(name, basestring) or name is None
            assert isinstance(prop_set, property_set.PropertySet)
        result = []
        # If this is 1->1 transformation, apply it to all consumed targets in order.
        if len (self.source_types_) < 2 and not self.composing_:

            for r in consumed:
                result.extend(self.generated_targets([r], prop_set, project, name))
        elif consumed:
            result.extend(self.generated_targets(consumed, prop_set, project, name))

        return result
github mzdb / pwiz-mzdb / libraries / boost-build / src / build / generators.py View on Github external
def try_one_generator_really (project, name, generator, target_type, properties, sources):
    """ Returns usage requirements + list of created targets.
    """
    if __debug__:
        from .targets import ProjectTarget
        assert isinstance(project, ProjectTarget)
        assert isinstance(name, basestring) or name is None
        assert isinstance(generator, Generator)
        assert isinstance(target_type, basestring)
        assert isinstance(properties, property_set.PropertySet)
        assert is_iterable_typed(sources, virtual_target.VirtualTarget)
    targets = generator.run (project, name, properties, sources)

    usage_requirements = []
    success = False

    dout("returned " + str(targets))

    if targets:
        success = True;

        if isinstance (targets[0], property_set.PropertySet):
            usage_requirements = targets [0]
            targets = targets [1]

        else:
            usage_requirements = property_set.empty ()
github vslavik / poedit / tools / build / src / tools / builtin.py View on Github external
def extra_usage_requirements (self, created_targets, prop_set):
        assert is_iterable_typed(created_targets, virtual_target.VirtualTarget)
        assert isinstance(prop_set, property_set.PropertySet)

        result = property_set.empty ()
        extra = []

        # Add appropriate  usage requirements.
        raw = prop_set.raw ()
        if 'shared' in raw:
            paths = []

            # TODO: is it safe to use the current directory? I think we should use
            # another mechanism to allow this to be run from anywhere.
            pwd = os.getcwd()

            for t in created_targets:
                if type.is_derived(t.type(), 'SHARED_LIB'):
github vslavik / poedit / deps / boost / tools / build / src / build / property_set.py View on Github external
def create_from_user_input(raw_properties, jamfile_module, location):
    """Creates a property-set from the input given by the user, in the
    context of 'jamfile-module' at 'location'"""
    assert is_iterable_typed(raw_properties, basestring)
    assert isinstance(jamfile_module, basestring)
    assert isinstance(location, basestring)
    properties = property.create_from_strings(raw_properties, True)
    properties = property.translate_paths(properties, location)
    properties = property.translate_indirect(properties, jamfile_module)

    project_id = get_manager().projects().attributeDefault(jamfile_module, 'id', None)
    if not project_id:
        project_id = os.path.abspath(location)
    properties = property.translate_dependencies(properties, project_id, location)
    properties = property.expand_subfeatures_in_conditions(properties)
    return create(properties)
github boostorg / build / src / build / project.py View on Github external
def glob(self, wildcards, excludes=None):
        assert is_iterable_typed(wildcards, basestring)
        assert is_iterable_typed(excludes, basestring)or excludes is None
        return self.registry.glob_internal(self.registry.current(),
                                           wildcards, excludes, "glob")