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)"
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 = {
'ESP32': 'esp32',
'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):
NAME = BUILD_SYSTEM_CMAKE
@staticmethod
def build(build_item): # type: (BuildItem) -> None
build_path, work_path = BuildSystem.build_prepare(build_item)
@classmethod
def build(cls, build_item): # type: (BuildItem) -> None
build_path, work_path, extra_cmakecache_items = cls.build_prepare(build_item)
# Prepare the build arguments
args = [
# Assume it is the responsibility of the caller to
@ -48,11 +39,12 @@ class CMakeBuildSystem(BuildSystem):
work_path,
"-DIDF_TARGET=" + build_item.target,
]
for key, val in extra_cmakecache_items.items():
args.append("-D{}={}".format(key, val))
if "TEST_EXCLUDE_COMPONENTS" in extra_cmakecache_items \
and "TEST_COMPONENTS" not in extra_cmakecache_items:
args.append("-DTESTS_ALL=1")
if extra_cmakecache_items:
for key, val in extra_cmakecache_items.items():
args.append("-D{}={}".format(key, val))
if "TEST_EXCLUDE_COMPONENTS" in extra_cmakecache_items \
and "TEST_COMPONENTS" not in extra_cmakecache_items:
args.append("-DTESTS_ALL=1")
if build_item.verbose:
args.append("-v")
args.append("build")

View file

@ -17,6 +17,16 @@ NAME_PLACEHOLDER = "@n"
FULL_NAME_PLACEHOLDER = "@f"
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.
# 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.
@ -195,12 +205,11 @@ class BuildSystem(object):
Derived classes implement the methods below.
Objects of these classes aren't instantiated, instead the class (type object) is used.
"""
NAME = "undefined"
SUPPORTED_TARGETS_REGEX = re.compile(r'Supported [Tt]argets((?:[\s|]+(?:ESP[0-9A-Z\-]+))+)')
@staticmethod
def build_prepare(build_item):
@classmethod
def build_prepare(cls, build_item):
app_path = build_item.app_dir
work_path = build_item.work_dir or app_path
if not build_item.build_dir:
@ -244,6 +253,7 @@ class BuildSystem(object):
os.unlink(sdkconfig_file)
logging.debug("Creating sdkconfig file: {}".format(sdkconfig_file))
extra_cmakecache_items = {}
if not build_item.dry_run:
with open(sdkconfig_file, "w") as f_out:
for sdkconfig_name in sdkconfig_defaults_list:
@ -255,13 +265,12 @@ class BuildSystem(object):
for line in f_in:
if not line.endswith("\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))
# Also save the sdkconfig file in the build directory
shutil.copyfile(
os.path.join(work_path, "sdkconfig"),
os.path.join(build_path, "sdkconfig"),
)
else:
for sdkconfig_name in sdkconfig_defaults_list:
sdkconfig_path = os.path.join(app_path, sdkconfig_name)
@ -273,7 +282,10 @@ class BuildSystem(object):
logging.debug("Appending {} to sdkconfig".format(sdkconfig_name))
# The preparation of build is finished. Implement the build part in sub classes.
return build_path, work_path
if cls.NAME == 'cmake':
return build_path, work_path, extra_cmakecache_items
else:
return build_path, work_path
@staticmethod
@abstractmethod

View file

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