Beispiel #1
0
    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)
        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))
Beispiel #2
0
    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)
        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))
Beispiel #3
0
    def scan_dependencies(self):
        self.e['deps'] = SpaceList()

        lib_dirs = list_subdirs(self.e.lib_dir) + list_subdirs(self.e.arduino_libraries_dir)
        inc_flags = self.recursive_inc_lib_flags(lib_dirs)

        used_libs = self._scan_dependencies(self.e.src_dir, lib_dirs, inc_flags)
        scanned_libs = set()
        while scanned_libs != used_libs:
            for lib_dir in list(used_libs - scanned_libs):
                used_libs |= self._scan_dependencies(lib_dir, lib_dirs, inc_flags)
                scanned_libs.add(lib_dir)

        self.e['extra_libs'] = list(used_libs)
        self.e['cflags'].extend(self.recursive_inc_lib_flags(used_libs))
Beispiel #4
0
 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=False, exclude=['examples']))
     return flags
Beispiel #5
0
 def inc_lib_flags(self, libdirs, recursive=False):
     flags = SpaceList()
     for d in libdirs:
         flags.append('-I' + d)
         if recursive:
             flags.extend('-I' + subd for subd in list_subdirs(d, recursive=True, exclude=['examples']))
     return flags
Beispiel #6
0
 def recursive_inc_lib_flags(self, libdirs):
     flags = SpaceList()
     for d in libdirs:
         flags.append('-I' + d)
         # recursive=True creates so many include directories that it exceeds avg-gcc's maximum list length.
         flags.extend('-I' + subd for subd in list_subdirs(d, recursive=False, exclude=['examples']))
     return flags
Beispiel #7
0
 def recursive_inc_lib_flags(self, libdirs):
     flags = SpaceList()
     for d in libdirs:
         flags.append('-I' + d)
         # recursive=True creates so many include directories that it exceeds avg-gcc's maximum list length.
         flags.extend('-I' + subd for subd in list_subdirs(
             d, recursive=False, exclude=['examples']))
     return flags
Beispiel #8
0
    def scan_dependencies(self):
        self.e['deps'] = SpaceList()

        # Include local libs, distribution, then src
        lib_dirs = list_subdirs(self.e.lib_dir) +\
                   list_subdirs(self.e.arduino_libraries_dir) +\
                   [self.e.src_dir]
        inc_flags = self.inc_lib_flags(lib_dirs, recursive=True)

        used_libs = self._scan_dependencies(self.e.src_dir, lib_dirs, inc_flags)
        scanned_libs = set()
        while scanned_libs != used_libs:
            for lib_dir in list(used_libs - scanned_libs):
                used_libs |= self._scan_dependencies(lib_dir, lib_dirs, inc_flags)
                scanned_libs.add(lib_dir)

        self.e['extra_libs'] = list(used_libs)
        self.e['cflags'].extend(self.inc_lib_flags(used_libs))
Beispiel #9
0
    def scan_dependencies(self):
        self.e['deps'] = SpaceList()

        lib_dirs = list_subdirs(self.e.lib_dir) + list_subdirs(
            self.e.arduino_libraries_dir)
        inc_flags = self.recursive_inc_lib_flags(lib_dirs)

        used_libs = self._scan_dependencies(self.e.src_dir, lib_dirs,
                                            inc_flags)
        scanned_libs = set()
        while scanned_libs != used_libs:
            for lib_dir in list(used_libs - scanned_libs):
                used_libs |= self._scan_dependencies(lib_dir, lib_dirs,
                                                     inc_flags)
                scanned_libs.add(lib_dir)

        self.e['extra_libs'] = list(used_libs)
        self.e['cflags'].extend(self.recursive_inc_lib_flags(used_libs))
Beispiel #10
0
    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)
Beispiel #11
0
 def recursive_inc_lib_flags(self, dashcmd, libdirs):
     flags = SpaceList()
     for d in libdirs:
         flags.append(dashcmd + d)
         flags.extend(dashcmd + subd for subd in list_subdirs(d, recursive=True, exclude=['examples']))
     return flags
Beispiel #12
0
 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
Beispiel #13
0
 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=False, exclude=["examples"]))
     return flags