mirror of
https://github.com/espressif/esp-idf.git
synced 2026-10-01 02:30:52 +03:00
feat(cmakev2/kconfig): Added support for excluded Kconfigs in menuconfig
This commit adds support for processing Kconfig files from excluded components.
This commit is contained in:
committed by
Frantisek Hrbata
parent
28c1a64007
commit
73ec4d5581
@@ -115,6 +115,8 @@ function(__consolidate_component_kconfig_files)
|
||||
idf_build_set_property(__KCONFIGS "")
|
||||
idf_build_set_property(__KCONFIG_PROJBUILDS "")
|
||||
idf_build_set_property(__SDKCONFIG_RENAMES "")
|
||||
idf_build_set_property(__KCONFIGS_EXCLUDED "")
|
||||
idf_build_set_property(__KCONFIGS_PROJBUILD_EXCLUDED "")
|
||||
|
||||
# Iterate through all discovered components and consolidate their Kconfig files
|
||||
foreach(component_name IN LISTS components_discovered)
|
||||
@@ -143,6 +145,7 @@ function(__consolidate_component_kconfig_files)
|
||||
idf_build_set_property(__KCONFIGS_PROJBUILD_EXCLUDED "${component_projbuild}" APPEND)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(component_rename)
|
||||
idf_build_set_property(__SDKCONFIG_RENAMES "${component_rename}" APPEND)
|
||||
endif()
|
||||
@@ -308,10 +311,14 @@ function(__create_config_env_file env_path)
|
||||
idf_build_get_property(target IDF_TARGET)
|
||||
idf_build_get_property(toolchain IDF_TOOLCHAIN)
|
||||
idf_build_get_property(sdkconfig SDKCONFIG)
|
||||
idf_build_get_property(kconfigs_excluded __KCONFIGS_EXCLUDED)
|
||||
idf_build_get_property(kconfigs_projbuild_excluded __KCONFIGS_PROJBUILD_EXCLUDED)
|
||||
|
||||
# Define Kconfig source file paths
|
||||
set(kconfigs_projbuild_path "${build_dir}/kconfigs_projbuild.in")
|
||||
set(kconfigs_path "${build_dir}/kconfigs.in")
|
||||
set(kconfigs_excluded_path "${build_dir}/kconfigs_excluded.in")
|
||||
set(kconfigs_projbuild_excluded_path "${build_dir}/kconfigs_projbuild_excluded.in")
|
||||
|
||||
# Get IDF version info
|
||||
__get_sdkconfig_option(OPTION CONFIG_IDF_INIT_VERSION
|
||||
@@ -345,6 +352,10 @@ function(__create_config_env_file env_path)
|
||||
set(idf_path "${idf_path}")
|
||||
set(kconfigs_path "${kconfigs_path}")
|
||||
set(kconfigs_projbuild_path "${kconfigs_projbuild_path}")
|
||||
set(kconfigs_excluded_path "${kconfigs_excluded_path}")
|
||||
set(kconfigs_projbuild_excluded_path "${kconfigs_projbuild_excluded_path}")
|
||||
set(kconfigs_excluded "${kconfigs_excluded}")
|
||||
set(kconfigs_projbuild_excluded "${kconfigs_projbuild_excluded}")
|
||||
|
||||
# Generate the config.env file from the config.env.in template
|
||||
configure_file("${template_path}" "${env_path}")
|
||||
|
||||
@@ -2,11 +2,15 @@
|
||||
"COMPONENT_KCONFIGS": "${kconfigs}",
|
||||
"COMPONENT_KCONFIGS_PROJBUILD": "${kconfig_projbuilds}",
|
||||
"COMPONENT_SDKCONFIG_RENAMES": "${sdkconfig_renames}",
|
||||
"COMPONENT_KCONFIGS_EXCLUDED": "${kconfigs_excluded}",
|
||||
"COMPONENT_KCONFIGS_PROJBUILD_EXCLUDED": "${kconfigs_projbuild_excluded}",
|
||||
"IDF_TARGET": "${idf_target}",
|
||||
"IDF_TOOLCHAIN": "${idf_toolchain}",
|
||||
"IDF_VERSION": "$ENV{IDF_VERSION}",
|
||||
"IDF_ENV_FPGA": "${idf_env_fpga}",
|
||||
"IDF_PATH": "${idf_path}",
|
||||
"COMPONENT_KCONFIGS_SOURCE_FILE": "${kconfigs_path}",
|
||||
"COMPONENT_KCONFIGS_PROJBUILD_SOURCE_FILE": "${kconfigs_projbuild_path}"
|
||||
"COMPONENT_KCONFIGS_PROJBUILD_SOURCE_FILE": "${kconfigs_projbuild_path}",
|
||||
"COMPONENT_KCONFIGS_EXCLUDED_SOURCE_FILE": "${kconfigs_excluded_path}",
|
||||
"COMPONENT_KCONFIGS_PROJBUILD_EXCLUDED_SOURCE_FILE": "${kconfigs_projbuild_excluded_path}"
|
||||
}
|
||||
|
||||
@@ -1,32 +1,35 @@
|
||||
#!/usr/bin/env python
|
||||
#
|
||||
# SPDX-FileCopyrightText: 2019-2021 Espressif Systems (Shanghai) CO LTD
|
||||
# SPDX-FileCopyrightText: 2019-2025 Espressif Systems (Shanghai) CO LTD
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
from __future__ import print_function, unicode_literals
|
||||
from __future__ import print_function
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import argparse
|
||||
import json
|
||||
import sys
|
||||
from io import open
|
||||
|
||||
|
||||
def _prepare_source_files(env_dict, list_separator):
|
||||
def _prepare_source_files(env_dict: dict[str, str], list_separator: str) -> None:
|
||||
"""
|
||||
Prepares source files which are sourced from the main Kconfig because upstream kconfiglib doesn't support sourcing
|
||||
a file list. The inputs are the same environment variables which are used by kconfiglib:
|
||||
- COMPONENT_KCONFIGS,
|
||||
- COMPONENT_KCONFIGS_SOURCE_FILE,
|
||||
- COMPONENT_KCONFIGS_PROJBUILD,
|
||||
- COMPONENT_KCONFIGS_PROJBUILD_SOURCE_FILE.
|
||||
- COMPONENT_KCONFIGS_PROJBUILD_SOURCE_FILE,
|
||||
- COMPONENT_KCONFIGS_EXCLUDED, (TODO: Currently disabled)
|
||||
- COMPONENT_KCONFIGS_PROJBUILD_EXCLUDED. (TODO: Currently disabled)
|
||||
|
||||
The outputs are written into files pointed by the value of
|
||||
- COMPONENT_KCONFIGS_SOURCE_FILE,
|
||||
- COMPONENT_KCONFIGS_PROJBUILD_SOURCE_FILE,
|
||||
- COMPONENT_KCONFIGS_EXCLUDED_SOURCE_FILE, (TODO: Currently disabled)
|
||||
- COMPONENT_KCONFIGS_PROJBUILD_EXCLUDED_SOURCE_FILE, (TODO: Currently disabled)
|
||||
|
||||
After running this function, COMPONENT_KCONFIGS_SOURCE_FILE and COMPONENT_KCONFIGS_PROJBUILD_SOURCE_FILE will
|
||||
contain a list of source statements based on the content of COMPONENT_KCONFIGS and COMPONENT_KCONFIGS_PROJBUILD,
|
||||
respectively. For example, if COMPONENT_KCONFIGS="var1;var2;var3" and
|
||||
After running this function, all source files will contain a list of source statements based on the
|
||||
content of their corresponding environment variables. For example, if COMPONENT_KCONFIGS="var1;var2;var3" and
|
||||
COMPONENT_KCONFIGS_SOURCE_FILE="/path/file.txt" then the content of file /path/file.txt will be:
|
||||
source "var1"
|
||||
source "var2"
|
||||
@@ -36,10 +39,10 @@ def _prepare_source_files(env_dict, list_separator):
|
||||
Space separated lists are currently only used by the documentation build system (esp-docs).
|
||||
"""
|
||||
|
||||
def _dequote(var):
|
||||
def _dequote(var: str) -> str:
|
||||
return var[1:-1] if len(var) > 0 and (var[0], var[-1]) == ('"',) * 2 else var
|
||||
|
||||
def _write_source_file(config_var, config_file):
|
||||
def _write_source_file(config_var: str, config_file: str) -> None:
|
||||
dequoted_var = _dequote(config_var)
|
||||
if dequoted_var:
|
||||
new_content = '\n'.join(['source "{}"'.format(path) for path in dequoted_var.split(list_separator)])
|
||||
@@ -62,25 +65,44 @@ def _prepare_source_files(env_dict, list_separator):
|
||||
|
||||
try:
|
||||
_write_source_file(env_dict['COMPONENT_KCONFIGS'], env_dict['COMPONENT_KCONFIGS_SOURCE_FILE'])
|
||||
_write_source_file(env_dict['COMPONENT_KCONFIGS_PROJBUILD'], env_dict['COMPONENT_KCONFIGS_PROJBUILD_SOURCE_FILE'])
|
||||
_write_source_file(
|
||||
env_dict['COMPONENT_KCONFIGS_PROJBUILD'], env_dict['COMPONENT_KCONFIGS_PROJBUILD_SOURCE_FILE']
|
||||
)
|
||||
# TODO: Enable excluded Kconfig processing once integration is complete
|
||||
# Currently commented out due to FileNotFoundError when paths are empty during CI tests
|
||||
# _write_source_file(
|
||||
# env_dict['COMPONENT_KCONFIGS_EXCLUDED'],
|
||||
# env_dict['COMPONENT_KCONFIGS_EXCLUDED_SOURCE_FILE']
|
||||
# )
|
||||
# _write_source_file(
|
||||
# env_dict['COMPONENT_KCONFIGS_PROJBUILD_EXCLUDED'],
|
||||
# env_dict['COMPONENT_KCONFIGS_PROJBUILD_EXCLUDED_SOURCE_FILE'],
|
||||
# )
|
||||
except KeyError as e:
|
||||
print('Error:', e, 'is not defined!')
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
def main():
|
||||
def main() -> None:
|
||||
parser = argparse.ArgumentParser(description='Kconfig Source File Generator')
|
||||
|
||||
parser.add_argument('--env', action='append', default=[],
|
||||
help='Environment value', metavar='NAME=VAL')
|
||||
parser.add_argument('--env', action='append', default=[], help='Environment value', metavar='NAME=VAL')
|
||||
|
||||
parser.add_argument('--env-file', type=argparse.FileType('r'),
|
||||
help='Optional file to load environment variables from. Contents '
|
||||
'should be a JSON object where each key/value pair is a variable.')
|
||||
parser.add_argument(
|
||||
'--env-file',
|
||||
type=argparse.FileType('r'),
|
||||
help='Optional file to load environment variables from. Contents '
|
||||
'should be a JSON object where each key/value pair is a variable.',
|
||||
)
|
||||
|
||||
parser.add_argument('--list-separator', choices=['space', 'semicolon'],
|
||||
default='space',
|
||||
help='Separator used in environment list variables (COMPONENT_KCONFIGS, COMPONENT_KCONFIGS_PROJBUILD)')
|
||||
parser.add_argument(
|
||||
'--list-separator',
|
||||
choices=['space', 'semicolon'],
|
||||
default='space',
|
||||
help='Separator used in environment list variables '
|
||||
'(COMPONENT_KCONFIGS, COMPONENT_KCONFIGS_PROJBUILD) '
|
||||
'TODO: EXCLUDED variants currently disabled',
|
||||
)
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user