Просмотр исходного кода

bugfix: drop make support for tests have no esp32 support

Fu Hanxi 5 лет назад
Родитель
Сommit
636f136296
3 измененных файлов с 44 добавлено и 45 удалено
  1. 3 39
      tools/find_build_apps/cmake.py
  2. 34 3
      tools/find_build_apps/common.py
  3. 7 3
      tools/find_build_apps/make.py

+ 3 - 39
tools/find_build_apps/cmake.py

@@ -1,6 +1,5 @@
 import logging
 import os
-import re
 import shutil
 import subprocess
 import sys
@@ -14,14 +13,6 @@ IDF_PY = os.path.join(os.environ["IDF_PATH"], "tools", "idf.py")
 # there is no equivalent for the project CMakeLists files. This seems to be the best option...
 CMAKE_PROJECT_LINE = r"include($ENV{IDF_PATH}/tools/cmake/project.cmake)"
 
-SUPPORTED_TARGETS_REGEX = re.compile(r'Supported [Tt]argets((?:[\s|]+(?:ESP[0-9A-Z\-]+))+)')
-
-FORMAL_TO_USUAL = {
-    'ESP32': 'esp32',
-    'ESP32-S2': 'esp32s2',
-    'ESP32-S3': 'esp32s3',
-}
-
 
 class CMakeBuildSystem(BuildSystem):
     NAME = BUILD_SYSTEM_CMAKE
@@ -95,33 +86,6 @@ class CMakeBuildSystem(BuildSystem):
             return False
         return True
 
-    @staticmethod
-    def supported_targets(app_path):
-        formal_to_usual = {
-            'ESP32': 'esp32',
-            'ESP32-S2': 'esp32s2',
-            'ESP32-S3': 'esp32s3',
-        }
-
-        readme_file_content = BuildSystem._read_readme(app_path)
-        if not readme_file_content:
-            return None
-        match = re.findall(BuildSystem.SUPPORTED_TARGETS_REGEX, readme_file_content)
-        if not match:
-            return None
-        if len(match) > 1:
-            raise NotImplementedError("Can't determine the value of SUPPORTED_TARGETS in {}".format(app_path))
-        support_str = match[0].strip()
-
-        targets = []
-        for part in support_str.split('|'):
-            for inner in part.split(' '):
-                inner = inner.strip()
-                if not inner:
-                    continue
-                elif inner in formal_to_usual:
-                    targets.append(formal_to_usual[inner])
-                else:
-                    raise NotImplementedError("Can't recognize value of target {} in {}, now we only support '{}'"
-                                              .format(inner, app_path, ', '.join(formal_to_usual.keys())))
-        return targets
+    @classmethod
+    def supported_targets(cls, app_path):
+        return cls._supported_targets(app_path)

+ 34 - 3
tools/find_build_apps/common.py

@@ -282,7 +282,7 @@ class BuildItem(object):
         size_info_fs.write(json.dumps(size_info_dict) + '\n')
 
 
-class BuildSystem(object):
+class BuildSystem:
     """
     Class representing a build system.
     Derived classes implement the methods below.
@@ -291,6 +291,12 @@ class BuildSystem(object):
     NAME = "undefined"
     SUPPORTED_TARGETS_REGEX = re.compile(r'Supported [Tt]argets((?:[\s|]+(?:ESP[0-9A-Z\-]+))+)')
 
+    FORMAL_TO_USUAL = {
+        'ESP32': 'esp32',
+        'ESP32-S2': 'esp32s2',
+        'ESP32-S3': 'esp32s3',
+    }
+
     @classmethod
     def build_prepare(cls, build_item):
         app_path = build_item.app_dir
@@ -404,9 +410,34 @@ class BuildSystem(object):
         with open(readme_path, "r", encoding='utf8') as readme_file:
             return readme_file.read()
 
-    @staticmethod
+    @classmethod
+    def _supported_targets(cls, app_path):
+        readme_file_content = BuildSystem._read_readme(app_path)
+        if not readme_file_content:
+            return cls.FORMAL_TO_USUAL.values()  # supports all targets if no readme found
+        match = re.findall(BuildSystem.SUPPORTED_TARGETS_REGEX, readme_file_content)
+        if not match:
+            return cls.FORMAL_TO_USUAL.values()  # supports all targets if no such header in readme
+        if len(match) > 1:
+            raise NotImplementedError("Can't determine the value of SUPPORTED_TARGETS in {}".format(app_path))
+        support_str = match[0].strip()
+
+        targets = []
+        for part in support_str.split('|'):
+            for inner in part.split(' '):
+                inner = inner.strip()
+                if not inner:
+                    continue
+                elif inner in cls.FORMAL_TO_USUAL:
+                    targets.append(cls.FORMAL_TO_USUAL[inner])
+                else:
+                    raise NotImplementedError("Can't recognize value of target {} in {}, now we only support '{}'"
+                                              .format(inner, app_path, ', '.join(cls.FORMAL_TO_USUAL.keys())))
+        return targets
+
+    @classmethod
     @abstractmethod
-    def supported_targets(app_path):
+    def supported_targets(cls, app_path):
         pass
 
 

+ 7 - 3
tools/find_build_apps/make.py

@@ -61,6 +61,10 @@ class MakeBuildSystem(BuildSystem):
             return False
         return True
 
-    @staticmethod
-    def supported_targets(app_path):
-        return ['esp32']
+    @classmethod
+    def supported_targets(cls, app_path):
+        readme_supported_targets = cls._supported_targets(app_path)
+        if readme_supported_targets and 'esp32' in readme_supported_targets:
+            return ['esp32']
+        else:
+            return []