fix after rebase

This commit is contained in:
Fu Hanxi 2020-05-06 10:40:23 +08:00
parent c35b010a3f
commit da9ca49093
3 changed files with 34 additions and 30 deletions

View file

@ -15,28 +15,19 @@ IDF_PY = "idf.py"
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\-]+))+)') SUPPORTED_TARGETS_REGEX = re.compile(r'Supported [Tt]argets((?:[\s|]+(?:ESP[0-9A-Z\-]+))+)')
SDKCONFIG_LINE_REGEX = re.compile(r"^([^=]+)=\"?([^\"\n]*)\"?\n*$")
FORMAL_TO_USUAL = { FORMAL_TO_USUAL = {
'ESP32': 'esp32', 'ESP32': 'esp32',
'ESP32-S2': 'esp32s2', 'ESP32-S2': 'esp32s2',
} }
# If these keys are present in sdkconfig.defaults, they will be extracted and passed to CMake
SDKCONFIG_TEST_OPTS = [
"EXCLUDE_COMPONENTS",
"TEST_EXCLUDE_COMPONENTS",
"TEST_COMPONENTS",
"TEST_GROUPS"
]
class CMakeBuildSystem(BuildSystem): class CMakeBuildSystem(BuildSystem):
NAME = BUILD_SYSTEM_CMAKE NAME = BUILD_SYSTEM_CMAKE
@staticmethod @classmethod
def build(build_item): # type: (BuildItem) -> None def build(cls, build_item): # type: (BuildItem) -> None
build_path, work_path = BuildSystem.build_prepare(build_item) build_path, work_path, extra_cmakecache_items = cls.build_prepare(build_item)
# Prepare the build arguments # Prepare the build arguments
args = [ args = [
# Assume it is the responsibility of the caller to # Assume it is the responsibility of the caller to
@ -48,6 +39,7 @@ class CMakeBuildSystem(BuildSystem):
work_path, work_path,
"-DIDF_TARGET=" + build_item.target, "-DIDF_TARGET=" + build_item.target,
] ]
if extra_cmakecache_items:
for key, val in extra_cmakecache_items.items(): for key, val in extra_cmakecache_items.items():
args.append("-D{}={}".format(key, val)) args.append("-D{}={}".format(key, val))
if "TEST_EXCLUDE_COMPONENTS" in extra_cmakecache_items \ if "TEST_EXCLUDE_COMPONENTS" in extra_cmakecache_items \

View file

@ -17,6 +17,16 @@ NAME_PLACEHOLDER = "@n"
FULL_NAME_PLACEHOLDER = "@f" FULL_NAME_PLACEHOLDER = "@f"
INDEX_PLACEHOLDER = "@i" INDEX_PLACEHOLDER = "@i"
SDKCONFIG_LINE_REGEX = re.compile(r"^([^=]+)=\"?([^\"\n]*)\"?\n*$")
# If these keys are present in sdkconfig.defaults, they will be extracted and passed to CMake
SDKCONFIG_TEST_OPTS = [
"EXCLUDE_COMPONENTS",
"TEST_EXCLUDE_COMPONENTS",
"TEST_COMPONENTS",
"TEST_GROUPS"
]
# ConfigRule represents one --config argument of find_apps.py. # ConfigRule represents one --config argument of find_apps.py.
# file_name is the name of the sdkconfig file fragment, optionally with a single wildcard ('*' character). # file_name is the name of the sdkconfig file fragment, optionally with a single wildcard ('*' character).
# file_name can also be empty to indicate that the default configuration of the app should be used. # file_name can also be empty to indicate that the default configuration of the app should be used.
@ -195,12 +205,11 @@ class BuildSystem(object):
Derived classes implement the methods below. Derived classes implement the methods below.
Objects of these classes aren't instantiated, instead the class (type object) is used. Objects of these classes aren't instantiated, instead the class (type object) is used.
""" """
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\-]+))+)')
@staticmethod @classmethod
def build_prepare(build_item): def build_prepare(cls, build_item):
app_path = build_item.app_dir app_path = build_item.app_dir
work_path = build_item.work_dir or app_path work_path = build_item.work_dir or app_path
if not build_item.build_dir: if not build_item.build_dir:
@ -244,6 +253,7 @@ class BuildSystem(object):
os.unlink(sdkconfig_file) os.unlink(sdkconfig_file)
logging.debug("Creating sdkconfig file: {}".format(sdkconfig_file)) logging.debug("Creating sdkconfig file: {}".format(sdkconfig_file))
extra_cmakecache_items = {}
if not build_item.dry_run: if not build_item.dry_run:
with open(sdkconfig_file, "w") as f_out: with open(sdkconfig_file, "w") as f_out:
for sdkconfig_name in sdkconfig_defaults_list: for sdkconfig_name in sdkconfig_defaults_list:
@ -255,13 +265,12 @@ class BuildSystem(object):
for line in f_in: for line in f_in:
if not line.endswith("\n"): if not line.endswith("\n"):
line += "\n" line += "\n"
if cls.NAME == 'cmake':
m = SDKCONFIG_LINE_REGEX.match(line)
if m and m.group(1) in SDKCONFIG_TEST_OPTS:
extra_cmakecache_items[m.group(1)] = m.group(2)
continue
f_out.write(os.path.expandvars(line)) f_out.write(os.path.expandvars(line))
# Also save the sdkconfig file in the build directory
shutil.copyfile(
os.path.join(work_path, "sdkconfig"),
os.path.join(build_path, "sdkconfig"),
)
else: else:
for sdkconfig_name in sdkconfig_defaults_list: for sdkconfig_name in sdkconfig_defaults_list:
sdkconfig_path = os.path.join(app_path, sdkconfig_name) sdkconfig_path = os.path.join(app_path, sdkconfig_name)
@ -273,6 +282,9 @@ class BuildSystem(object):
logging.debug("Appending {} to sdkconfig".format(sdkconfig_name)) logging.debug("Appending {} to sdkconfig".format(sdkconfig_name))
# The preparation of build is finished. Implement the build part in sub classes. # The preparation of build is finished. Implement the build part in sub classes.
if cls.NAME == 'cmake':
return build_path, work_path, extra_cmakecache_items
else:
return build_path, work_path return build_path, work_path
@staticmethod @staticmethod

View file

@ -20,9 +20,9 @@ except NameError:
class MakeBuildSystem(BuildSystem): class MakeBuildSystem(BuildSystem):
NAME = BUILD_SYSTEM_MAKE NAME = BUILD_SYSTEM_MAKE
@staticmethod @classmethod
def build(build_item): def build(cls, build_item):
build_path, work_path = BuildSystem.build_prepare(build_item) build_path, work_path = cls.build_prepare(build_item)
commands = [ commands = [
'make clean', 'make clean',
'make defconfig', 'make defconfig',