def try_one_generator(project, name, generator, target_type, properties, sources): """ Checks if generator invocation can be pruned, because it's guaranteed to fail. If so, quickly returns empty list. Otherwise, calls try_one_generator_really. """ source_types = [] for s in sources: source_types.append(s.type()) viable_source_types = viable_source_types_for_generator(generator) if source_types and viable_source_types != ['*'] and\ not set.intersection (source_types, viable_source_types): if project.manager().logger().on(): id = generator.id() project.manager().logger().log(__name__, "generator '%s' pruned" % id) project.manager().logger().log(__name__, "source_types" '%s' % source_types) project.manager().logger().log( __name__, "viable_source_types '%s'" % viable_source_types) return [] else: return try_one_generator_really(project, name, generator, target_type, properties, sources)
def try_one_generator (project, name, generator, target_type, properties, sources): """ Checks if generator invocation can be pruned, because it's guaranteed to fail. If so, quickly returns empty list. Otherwise, calls try_one_generator_really. """ 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) source_types = [] for s in sources: source_types.append (s.type ()) viable_source_types = viable_source_types_for_generator (generator) if source_types and viable_source_types != ['*'] and\ not set_.intersection (source_types, viable_source_types): if project.manager ().logger ().on (): id = generator.id () project.manager ().logger ().log (__name__, "generator '%s' pruned" % id) project.manager ().logger ().log (__name__, "source_types" '%s' % source_types) project.manager ().logger ().log (__name__, "viable_source_types '%s'" % viable_source_types) return [] else: return try_one_generator_really (project, name, generator, target_type, properties, sources)
def libraries_to_install(existing_libraries): # Decides which libraries are to be installed by looking at --with-<library> # --without-<library> arguments. Returns the list of directories under "libs" # which must be built and installed. with_parameter = regex.transform(sys.argv, "--with-(.*)") without_parameter = regex.transform(sys.argv, "--without-(.*)") if not with_parameter and not without_parameter: # Nothing is specified on command line. See if maybe # project-config.jam has some choices. project_config_libs = bjam.call("peek", "project-config", "libraries") with_parameter = regex.transform(project_config_libs, "--with-(.*)") without_parameter = regex.transform(project_config_libs, "--without-(.*)") # Do some checks. if with_parameter and without_parameter: get_manager().errors()("both --with-<library> and --without-<library> specified") wrong = set.difference(with_parameter, existing_libraries) if wrong: get_manager().errors()("wrong library name '" + wrong[0] + "' in the --with-<library> option.") wrong = set.difference(without_parameter, existing_libraries) if wrong: get_manager().errors()("wrong library name '" + wrong[0] + "' in the --without-<library> option.") if with_parameter: return set.intersection(existing_libraries, with_parameter) else: return set.difference(existing_libraries, without_parameter)
def libraries_to_install(existing_libraries): # Decides which libraries are to be installed by looking at --with-<library> # --without-<library> arguments. Returns the list of directories under "libs" # which must be built and installed. with_parameter = regex.transform(sys.argv, "--with-(.*)") without_parameter = regex.transform(sys.argv, "--without-(.*)") if not with_parameter and not without_parameter: # Nothing is specified on command line. See if maybe # project-config.jam has some choices. project_config_libs = bjam.call("peek", "project-config", "libraries") with_parameter = regex.transform(project_config_libs, "--with-(.*)") without_parameter = regex.transform(project_config_libs, "--without-(.*)") # Do some checks. if with_parameter and without_parameter: get_manager().errors()( "both --with-<library> and --without-<library> specified") wrong = set.difference(with_parameter, existing_libraries) if wrong: get_manager().errors()("wrong library name '" + wrong[0] + "' in the --with-<library> option.") wrong = set.difference(without_parameter, existing_libraries) if wrong: get_manager().errors()("wrong library name '" + wrong[0] + "' in the --without-<library> option.") if with_parameter: return set.intersection(existing_libraries, with_parameter) else: return set.difference(existing_libraries, without_parameter)
def take(attributes, properties): """Returns a property set which include all properties in 'properties' that have any of 'attributes'.""" result = [] for e in properties: if set.intersection(attributes, feature.attributes(get_grist(e))): result.append(e) return result
def __x_product_aux(property_sets, x_product_seen, x_product_used, feature_space): """ Implementation of __x_product. """ result = [] if property_sets: p = feature.split(property_sets[0]) else: p = [] f = set.difference(get_grist(p), feature.free_features()) seen = [] # No conflict with things used at a higher level? if not set.intersection(f, x_product_used): # don't mix in any conflicting features local_x_product_used = x_product_used + f local_x_product_seen = [] if len(property_sets) > 1: rest = __x_product_aux(property_sets[1:], local_x_product_seen, local_x_product_used, feature_space) result = [property_sets[0] + '/' + x for x in rest] if not result and property_sets: result = [property_sets[0]] # If we didn't encounter a conflicting feature lower down, # don't recurse again. if not set.intersection(f, local_x_product_seen): property_sets = [] seen = local_x_product_seen if len(property_sets) > 1: result.extend( __x_product_aux(property_sets[1:], x_product_seen, x_product_used, feature_space)) x_product_seen += f + seen # Note that we've seen these features so that higher levels will # recurse again without them set. return result
def __x_product_aux (property_sets, x_product_seen, x_product_used, feature_space): """ Implementation of __x_product. """ result = [] if property_sets: p = feature.split (property_sets [0]) else: p = [] f = set.difference (get_grist (p), feature.free_features ()) seen = [] # No conflict with things used at a higher level? if not set.intersection (f, x_product_used): # don't mix in any conflicting features local_x_product_used = x_product_used + f local_x_product_seen = [] if len (property_sets) > 1: rest = __x_product_aux (property_sets [1:], local_x_product_seen, local_x_product_used, feature_space) result = [ property_sets [0] + '/' + x for x in rest] if not result and property_sets: result = [property_sets [0]] # If we didn't encounter a conflicting feature lower down, # don't recurse again. if not set.intersection (f, local_x_product_seen): property_sets = [] seen = local_x_product_seen if len (property_sets) > 1: result.extend (__x_product_aux (property_sets [1:], x_product_seen, x_product_used, feature_space)) x_product_seen += f + seen # Note that we've seen these features so that higher levels will # recurse again without them set. return result
def try_one_generator (project, name, generator, target_type, properties, sources): """ Checks if generator invocation can be pruned, because it's guaranteed to fail. If so, quickly returns empty list. Otherwise, calls try_one_generator_really. """ source_types = [] for s in sources: source_types.append (s.type ()) viable_source_types = viable_source_types_for_generator (generator) if source_types and viable_source_types != ['*'] and\ not set.intersection (source_types, viable_source_types): if project.manager ().logger ().on (): id = generator.id () project.manager ().logger ().log (__name__, "generator '%s' pruned" % id) project.manager ().logger ().log (__name__, "source_types" '%s' % source_types) project.manager ().logger ().log (__name__, "viable_source_types '%s'" % viable_source_types) return [] else: return try_one_generator_really (project, name, generator, target_type, properties, sources)