Merge branch 'bugfix/drop_make_support_when_esp32_not_supported' into 'master'

CI: drop make support when esp32 not supported

See merge request espressif/esp-idf!11510
This commit is contained in:
Ivan Grokhotkov
2020-12-14 15:51:44 +08:00
5 changed files with 62 additions and 57 deletions

View File

@@ -51,12 +51,15 @@ def get_idf_path(path, *paths):
def _get_apps(target, build_system): def _get_apps(target, build_system):
print("- Getting paths of apps") print("- Getting paths of apps")
output = subprocess.check_output( args = [sys.executable,
sys.executable + " " + os.getenv('IDF_PATH') + get_idf_path('tools/find_apps.py'),
"/tools/find_apps.py -p examples --recursive --target %s --build-system %s" '-p',
% (target, build_system), get_idf_path('examples'),
shell=True).decode('utf-8') '--recursive',
o_list = output.split("\n") '--target', target,
'--build-system', build_system]
output = subprocess.check_output(args).decode('utf-8')
o_list = output.split('\n')
json_list = [] json_list = []
for j in o_list: for j in o_list:
if j: if j:

View File

@@ -146,9 +146,9 @@ def find_apps(build_system_class, path, recursive, exclude_list, target):
logging.debug("Looking for {} apps in {}{}".format(build_system_name, path, " recursively" if recursive else "")) logging.debug("Looking for {} apps in {}{}".format(build_system_name, path, " recursively" if recursive else ""))
if not recursive: if not recursive:
if exclude_list: if exclude_list:
logging.warn("--exclude option is ignored when used without --recursive") logging.warning("--exclude option is ignored when used without --recursive")
if not build_system_class.is_app(path): if not build_system_class.is_app(path):
logging.warn("Path {} specified without --recursive flag, but no {} app found there".format( logging.warning("Path {} specified without --recursive flag, but no {} app found there".format(
path, build_system_name)) path, build_system_name))
return [] return []
return [path] return [path]
@@ -168,12 +168,15 @@ def find_apps(build_system_class, path, recursive, exclude_list, target):
del dirs[:] del dirs[:]
supported_targets = build_system_class.supported_targets(root) supported_targets = build_system_class.supported_targets(root)
if supported_targets and target not in supported_targets: if supported_targets and (target in supported_targets):
logging.debug("Skipping, app only supports targets: " + ", ".join(supported_targets)) apps_found.append(root)
else:
if supported_targets:
logging.debug("Skipping, app only supports targets: " + ", ".join(supported_targets))
else:
logging.debug("Skipping, app has no supported targets")
continue continue
apps_found.append(root)
return apps_found return apps_found

View File

@@ -1,6 +1,5 @@
import logging import logging
import os import os
import re
import shutil import shutil
import subprocess import subprocess
import sys 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... # 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)" 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): class CMakeBuildSystem(BuildSystem):
NAME = BUILD_SYSTEM_CMAKE NAME = BUILD_SYSTEM_CMAKE
@@ -95,33 +86,6 @@ class CMakeBuildSystem(BuildSystem):
return False return False
return True return True
@staticmethod @classmethod
def supported_targets(app_path): def supported_targets(cls, app_path):
formal_to_usual = { return cls._supported_targets(app_path)
'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

View File

@@ -282,7 +282,7 @@ class BuildItem(object):
size_info_fs.write(json.dumps(size_info_dict) + '\n') size_info_fs.write(json.dumps(size_info_dict) + '\n')
class BuildSystem(object): class BuildSystem:
""" """
Class representing a build system. Class representing a build system.
Derived classes implement the methods below. Derived classes implement the methods below.
@@ -291,6 +291,12 @@ class BuildSystem(object):
NAME = "undefined" NAME = "undefined"
SUPPORTED_TARGETS_REGEX = re.compile(r'Supported [Tt]argets((?:[\s|]+(?:ESP[0-9A-Z\-]+))+)') 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 @classmethod
def build_prepare(cls, build_item): def build_prepare(cls, build_item):
app_path = build_item.app_dir app_path = build_item.app_dir
@@ -404,9 +410,34 @@ class BuildSystem(object):
with open(readme_path, "r", encoding='utf8') as readme_file: with open(readme_path, "r", encoding='utf8') as readme_file:
return readme_file.read() 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 @abstractmethod
def supported_targets(app_path): def supported_targets(cls, app_path):
pass pass

View File

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