Beispiel #1
0
 def is_platforms_compatible(self, platforms):
     platforms_map = {
         "avr": "atmelavr",
         "sam": "atmelsam",
         "samd": "atmelsam",
         "esp8266": "espressif8266",
         "esp32": "espressif32",
         "arc32": "intel_arc32",
         "stm32": "ststm32"
     }
     items = []
     for arch in self._manifest.get("architectures", "").split(","):
         arch = arch.strip()
         if arch == "*":
             items = "*"
             break
         if arch in platforms_map:
             items.append(platforms_map[arch])
     if not items:
         return LibBuilderBase.is_platforms_compatible(self, platforms)
     return util.items_in_list(platforms, items)
Beispiel #2
0
 def is_platforms_compatible(self, platforms):
     platforms_map = {
         "avr": "atmelavr",
         "sam": "atmelsam",
         "samd": "atmelsam",
         "esp8266": "espressif8266",
         "esp32": "espressif32",
         "arc32": "intel_arc32",
         "stm32": "ststm32"
     }
     items = []
     for arch in self._manifest.get("architectures", "").split(","):
         arch = arch.strip()
         if arch == "*":
             items = "*"
             break
         if arch in platforms_map:
             items.append(platforms_map[arch])
     if not items:
         return LibBuilderBase.is_platforms_compatible(self, platforms)
     return util.items_in_list(platforms, items)
Beispiel #3
0
    def _get_lib_id_from_installed(self, filters):
        if filters["name"].startswith("id="):
            return int(filters["name"][3:])
        package_dir = self.get_package_dir(
            filters["name"], filters.get("requirements", filters.get("version"))
        )
        if not package_dir:
            return None
        manifest = self.load_manifest(package_dir)
        if "id" not in manifest:
            return None

        for key in ("frameworks", "platforms"):
            if key not in filters:
                continue
            if key not in manifest:
                return None
            if not util.items_in_list(
                util.items_to_list(filters[key]), util.items_to_list(manifest[key])
            ):
                return None

        if "authors" in filters:
            if "authors" not in manifest:
                return None
            manifest_authors = manifest["authors"]
            if not isinstance(manifest_authors, list):
                manifest_authors = [manifest_authors]
            manifest_authors = [
                a["name"]
                for a in manifest_authors
                if isinstance(a, dict) and "name" in a
            ]
            filter_authors = filters["authors"]
            if not isinstance(filter_authors, list):
                filter_authors = [filter_authors]
            if not set(filter_authors) <= set(manifest_authors):
                return None

        return int(manifest["id"])
Beispiel #4
0
    def _get_lib_id_from_installed(self, filters):
        if filters['name'].startswith("id="):
            return int(filters['name'][3:])
        package_dir = self.get_package_dir(
            filters['name'], filters.get("requirements",
                                         filters.get("version")))
        if not package_dir:
            return None
        manifest = self.load_manifest(package_dir)
        if "id" not in manifest:
            return None

        for key in ("frameworks", "platforms"):
            if key not in filters:
                continue
            if key not in manifest:
                return None
            if not util.items_in_list(
                    util.items_to_list(filters[key]),
                    util.items_to_list(manifest[key])):
                return None

        if "authors" in filters:
            if "authors" not in manifest:
                return None
            manifest_authors = manifest['authors']
            if not isinstance(manifest_authors, list):
                manifest_authors = [manifest_authors]
            manifest_authors = [
                a['name'] for a in manifest_authors
                if isinstance(a, dict) and "name" in a
            ]
            filter_authors = filters['authors']
            if not isinstance(filter_authors, list):
                filter_authors = [filter_authors]
            if not set(filter_authors) <= set(manifest_authors):
                return None

        return int(manifest['id'])
    def process_dependencies(self):
        if not self.dependencies:
            return
        for item in self.dependencies:
            skip = False
            for key in ("platforms", "frameworks"):
                env_key = "PIO" + key.upper()[:-1]
                if env_key not in self.env:
                    continue
                if (key in item and
                        not util.items_in_list(self.env[env_key], item[key])):
                    if self.verbose:
                        sys.stderr.write(
                            "Skip %s incompatible dependency %s\n" %
                            (key[:-1], item))
                    skip = True
            if skip:
                continue

            found = False
            for lb in self.env.GetLibBuilders():
                if item['name'] != lb.name:
                    continue
                elif "frameworks" in item and \
                     not lb.is_frameworks_compatible(item["frameworks"]):
                    continue
                elif "platforms" in item and \
                     not lb.is_platforms_compatible(item["platforms"]):
                    continue
                found = True
                self.depend_recursive(lb)
                break

            if not found:
                sys.stderr.write(
                    "Error: Could not find `%s` dependency for `%s` "
                    "library\n" % (item['name'], self.name))
                self.env.Exit(1)
Beispiel #6
0
    def process_dependencies(self):
        if not self.dependencies:
            return
        for item in self.dependencies:
            skip = False
            for key in ("platforms", "frameworks"):
                env_key = "PIO" + key.upper()[:-1]
                if env_key not in self.env:
                    continue
                if (key in item and
                        not util.items_in_list(self.env[env_key], item[key])):
                    if self.verbose:
                        sys.stderr.write("Skip %s incompatible dependency %s\n"
                                         % (key[:-1], item))
                    skip = True
            if skip:
                continue

            found = False
            for lb in self.env.GetLibBuilders():
                if item['name'] != lb.name:
                    continue
                elif "frameworks" in item and \
                     not lb.is_frameworks_compatible(item["frameworks"]):
                    continue
                elif "platforms" in item and \
                     not lb.is_platforms_compatible(item["platforms"]):
                    continue
                found = True
                self.depend_recursive(lb)
                break

            if not found:
                sys.stderr.write(
                    "Error: Could not find `%s` dependency for `%s` "
                    "library\n" % (item['name'], self.name))
                self.env.Exit(1)
 def is_frameworks_compatible(self, frameworks):
     return util.items_in_list(frameworks, ["mbed"])
 def is_frameworks_compatible(self, frameworks):
     return util.items_in_list(frameworks, ["arduino", "energia"])
Beispiel #9
0
 def is_system_compatible(value):
     if not value or "*" in value:
         return True
     return util.items_in_list(value, util.get_systype())
Beispiel #10
0
 def is_frameworks_compatible(self, frameworks):
     return util.items_in_list(frameworks,
                               self._manifest.get("frameworks") or ["*"])
Beispiel #11
0
 def is_platforms_compatible(self, platforms):
     items = self._manifest.get("platforms")
     if not items:
         return LibBuilderBase.is_platforms_compatible(self, platforms)
     return util.items_in_list(platforms, items)
Beispiel #12
0
 def is_frameworks_compatible(self, frameworks):
     return util.items_in_list(frameworks, ["mbed"])
Beispiel #13
0
 def is_frameworks_compatible(self, frameworks):
     return util.items_in_list(frameworks, ["arduino", "energia"])
 def is_platforms_compatible(self, platforms):
     items = self._manifest.get("platforms")
     if not items:
         return LibBuilderBase.is_platforms_compatible(self, platforms)
     return util.items_in_list(platforms, items)
Beispiel #15
0
 def is_frameworks_compatible(self, frameworks):
     items = self._manifest.get("frameworks")
     if not items:
         return LibBuilderBase.is_frameworks_compatible(self, frameworks)
     return util.items_in_list(frameworks, items)
 def is_frameworks_compatible(self, frameworks):
     items = self._manifest.get("frameworks")
     if not items:
         return LibBuilderBase.is_frameworks_compatible(self, frameworks)
     return util.items_in_list(frameworks, items)
Beispiel #17
0
 def is_platforms_compatible(self, platforms):
     return util.items_in_list(platforms,
                               self._manifest.get("platforms") or ["*"])