def recursive_inc_lib_flags(self, libdirs): flags = SpaceList() for d in libdirs: flags.append('-I' + d) flags.extend('-I' + subd for subd in list_subdirs( d, recursive=True, exclude=['examples', 'extras'])) return flags
def scan_dependencies(self): self.e['deps'] = SpaceList() lib_dirs = [self.e.arduino_core_dir] + \ list_subdirs(self.e.lib_dir) + \ list_subdirs(self.e.arduino_libraries_dir) + \ list_subdirs(self.e.arduino_core_libraries_dir) + \ list_subdirs(self.e.arduino_user_libraries_dir) inc_flags = self.recursive_inc_lib_flags(lib_dirs) # If lib A depends on lib B it have to appear before B in final # list so that linker could link all together correctly # but order of `_scan_dependencies` is not defined, so... # 1. Get dependencies of sources in arbitrary order used_libs = list( self._scan_dependencies(self.e.src_dir, lib_dirs, inc_flags)) # 2. Get dependencies of dependency libs themselves: existing dependencies # are moved to the end of list maintaining order, new dependencies are appended scanned_libs = set() while scanned_libs != set(used_libs): for lib in set(used_libs) - scanned_libs: dep_libs = self._scan_dependencies(lib, lib_dirs, inc_flags) i = 0 for ulib in used_libs[:]: if ulib in dep_libs: # dependency lib used already, move it to the tail used_libs.append(used_libs.pop(i)) dep_libs.remove(ulib) else: i += 1 # append new dependencies to the tail used_libs.extend(dep_libs) scanned_libs.add(lib) self.e['used_libs'] = used_libs self.e['cppflags'].extend(self.recursive_inc_lib_flags(used_libs))
def scan_dependencies(self): self.e['deps'] = SpaceList() lib_dirs = [self.e.arduino_core_dir] + \ list_subdirs(self.e.lib_dir) + \ list_subdirs(self.e.arduino_libraries_dir) + \ list_subdirs(self.e.arduino_core_libraries_dir) + \ list_subdirs(self.e.arduino_user_libraries_dir) inc_flags = self.recursive_inc_lib_flags(lib_dirs) # If lib A depends on lib B it have to appear before B in final # list so that linker could link all together correctly # but order of `_scan_dependencies` is not defined, so... # 1. Get dependencies of sources in arbitrary order used_libs = list(self._scan_dependencies(self.e.src_dir, lib_dirs, inc_flags)) # 2. Get dependencies of dependency libs themselves: existing dependencies # are moved to the end of list maintaining order, new dependencies are appended scanned_libs = set() while scanned_libs != set(used_libs): for lib in set(used_libs) - scanned_libs: dep_libs = self._scan_dependencies(lib, lib_dirs, inc_flags) i = 0 for ulib in used_libs[:]: if ulib in dep_libs: # dependency lib used already, move it to the tail used_libs.append(used_libs.pop(i)) dep_libs.remove(ulib) else: i += 1 # append new dependencies to the tail used_libs.extend(dep_libs) scanned_libs.add(lib) self.e['used_libs'] = used_libs self.e['cppflags'].extend(self.recursive_inc_lib_flags(used_libs))
def setup_arg_parser(self, parser): super(Init, self).setup_arg_parser(parser) parser.add_argument('-t', '--template', default=self.default_template, help='Project template to use') parser.epilog = "Available project templates:\n\n" template_items = [] for tdir in list_subdirs(self.e.templates_dir): try: description = ConfigObj(os.path.join(tdir, 'manifest.ini'))['description'] except KeyError: description = '' template_items.append((os.path.basename(tdir), description)) parser.epilog += format_available_options(template_items, head_width=12, default=self.default_template)
def setup_arg_parser(self, parser): super(Init, self).setup_arg_parser(parser) parser.add_argument('-t', '--template', default=self.default_template, help='Project template to use') parser.epilog = "Available project templates:\n\n" template_items = [] for tdir in list_subdirs(self.e.templates_dir): try: description = ConfigObj(os.path.join( tdir, 'manifest.ini'))['description'] except KeyError: description = '' template_items.append((os.path.basename(tdir), description)) parser.epilog += format_available_options( template_items, head_width=12, default=self.default_template)
def recursive_inc_lib_flags(self, libdirs): flags = SpaceList() for d in libdirs: flags.append('-I' + d) flags.extend('-I' + subd for subd in list_subdirs(d, recursive=True, exclude=['examples', 'extras'])) return flags