def _setup_link(self, objects, output_dir, libraries, library_dirs): """Typecheck and fix up some of the arguments supplied to the class of link methods. Specifically: ensure that all arguments are lists, and augment them with their permanent versions (eg. 'self.libraries' augments 'libraries'). Returns a tuple with fixed versions of all arguments. """ if not typecheck.is_sequence(objects): raise TypeError("'objects' must be a list or tuple of strings") objects = list(objects) if output_dir is None: output_dir = self.get_output_dir() elif type (output_dir) is not StringType: raise TypeError("'output_dir' must be a string or None") if libraries is None: libraries = self.libraries elif typecheck.is_sequence(libraries): libraries = list(libraries) + (self.libraries or []) else: raise TypeError("'libraries' (if supplied) must be a list of strings") if library_dirs is None: library_dirs = self.library_dirs elif typecheck.is_sequence(library_dirs): library_dirs = list(library_dirs) + (self.library_dirs or []) else: raise TypeError("'library_dirs' (if supplied) must be a list of strings") return objects, output_dir, libraries, library_dirs
def add_libraries(self, libraries): if libraries and typecheck.is_sequence(libraries): for library in list(libraries): self.add_library(library) libraries = list (libraries) + (self.libraries or []) else: raise TypeError("'libraries' (if supplied) must be a list of strings")
def _setup_compile(self, sources, macros, include_dirs, extra, depends): """Process arguments and decide which source files to compile.""" if macros is None: macros = self.macros elif typecheck.is_list(macros): macros = macros + (self.macros or []) else: raise TypeError("'macros' (if supplied) must be a list of tuples") if include_dirs is None: include_dirs = self._include_dirs elif typecheck.is_sequence(include_dirs): include_dirs = list(include_dirs) + (self._include_dirs or []) else: raise TypeError("'include_dirs' (if supplied) must be a list of strings") if extra is None: extra = [] # List of expected output files objects = self.get_object_filenames(sources) assert len(objects) == len(sources) pp_options = self._gen_preprocess_options(macros, include_dirs) build = {} for i in range(len(sources)): src = sources[i] obj = objects[i] ext = path_utils.splitext(src)[1] path_utils.mkpath(path_utils.dirname(obj), 0777) build[obj] = (src, ext) return macros, objects, extra, pp_options, build
def add_files(self, pathes): """Adds files from the list. :param pathes: A list of strings. """ if not typecheck.is_sequence(pathes): raise TypeError("'files' must be a sequence.") for path in pathes: self.add_file(path)
def add_ports(self, ports): """Adds ports to the system. :param ports: A list of Port instances. """ if not typecheck.is_sequence(ports): raise TypeError("ports must be a sequence.") for port in ports: self.add_port(port)
def set_cores(self, cores): if typecheck.is_sequence(cores) and len(cores): for i in range(len(cores)): self.set_core(cores[i], i) elif typecheck.is_dict(cores) and len(cores): for id, core in cores.items(): self.set_core(core, id) else: raise Exception("Cores is not a sequnce or dictionary.")
def add_processors(self, processors): """Registeres processors. :param processors: A list of :class:`~bb.app.hardware.devices.processors.processor.Processor` instances. """ if not typecheck.is_sequence(processors): raise TypeError('Must be a sequence') for processor in processors: self.add_processor(processor)
def add_property(self, *property_): """Adds a new property for the primitive. Primitive can be described with help of class Property or with tuple:: primitive.add_property("name", "Foo") # or primitive.properties.name = "Foo" or:: primitive.add_properties(("name", "Foo"), ("color", "black")) """ name, value = None, None if len(property_) == 1: if not typecheck.is_sequence(property_): raise TypeError() property_ = property_[0] if len(property_) != 2: raise TypeError() name, value = property_[0], property_[1] self._properties[name] = value
def add_link_objects(self, objects): """See :func:`CCompiler.add_link_object`.""" if typecheck.is_sequence(objects): raise TypeError("'objects' must be a list or tuple of strings") for obj in list(objects): self.add_link_object(obj)
def add_library_dirs(self, dirs): if dirs and typecheck.is_sequence(dirc): for library_dir in list(dirs): self.add_library_dir(library_dir) else: raise TypeError("'dirs' (if supplied) must be a list of strings")
def add_properties(self, properties): if not typecheck.is_sequence(properties): raise TypeError("Has to be a sequence") for property_ in properties: self.add_property(property_)