mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
build system: pass semicolon-separated directory lists to kconfig
New —-list-separator argument of confgen.py and prepare_kconfig_files.py is used to select which character is used as list separator. For compatibility with esp-docs, we still keep support for space separator. Otherwise esp-docs would have to choose the separator depending on the IDF version.
This commit is contained in:
parent
636ce4750f
commit
8da98b864d
@ -3208,7 +3208,6 @@ tools/idf_py_actions/tools.py
|
|||||||
tools/idf_py_actions/uf2_ext.py
|
tools/idf_py_actions/uf2_ext.py
|
||||||
tools/kconfig_new/confserver.py
|
tools/kconfig_new/confserver.py
|
||||||
tools/kconfig_new/gen_kconfig_doc.py
|
tools/kconfig_new/gen_kconfig_doc.py
|
||||||
tools/kconfig_new/prepare_kconfig_files.py
|
|
||||||
tools/kconfig_new/test/confgen/test_confgen.py
|
tools/kconfig_new/test/confgen/test_confgen.py
|
||||||
tools/kconfig_new/test/confserver/test_confserver.py
|
tools/kconfig_new/test/confserver/test_confserver.py
|
||||||
tools/kconfig_new/test/gen_kconfig_doc/test_kconfig_out.py
|
tools/kconfig_new/test/gen_kconfig_doc/test_kconfig_out.py
|
||||||
|
@ -94,10 +94,6 @@ function(__kconfig_generate_config sdkconfig sdkconfig_defaults)
|
|||||||
idf_build_get_property(idf_path IDF_PATH)
|
idf_build_get_property(idf_path IDF_PATH)
|
||||||
idf_build_get_property(idf_env_fpga __IDF_ENV_FPGA)
|
idf_build_get_property(idf_env_fpga __IDF_ENV_FPGA)
|
||||||
|
|
||||||
string(REPLACE ";" " " kconfigs "${kconfigs}")
|
|
||||||
string(REPLACE ";" " " kconfig_projbuilds "${kconfig_projbuilds}")
|
|
||||||
string(REPLACE ";" " " sdkconfig_renames "${sdkconfig_renames}")
|
|
||||||
|
|
||||||
# These are the paths for files which will contain the generated "source" lines for COMPONENT_KCONFIGS and
|
# These are the paths for files which will contain the generated "source" lines for COMPONENT_KCONFIGS and
|
||||||
# COMPONENT_KCONFIGS_PROJBUILD
|
# COMPONENT_KCONFIGS_PROJBUILD
|
||||||
set(kconfigs_projbuild_path "${CMAKE_CURRENT_BINARY_DIR}/kconfigs_projbuild.in")
|
set(kconfigs_projbuild_path "${CMAKE_CURRENT_BINARY_DIR}/kconfigs_projbuild.in")
|
||||||
@ -130,10 +126,12 @@ function(__kconfig_generate_config sdkconfig sdkconfig_defaults)
|
|||||||
|
|
||||||
set(prepare_kconfig_files_command
|
set(prepare_kconfig_files_command
|
||||||
${python} ${idf_path}/tools/kconfig_new/prepare_kconfig_files.py
|
${python} ${idf_path}/tools/kconfig_new/prepare_kconfig_files.py
|
||||||
|
--list-separator=semicolon
|
||||||
--env-file ${config_env_path})
|
--env-file ${config_env_path})
|
||||||
|
|
||||||
set(confgen_basecommand
|
set(confgen_basecommand
|
||||||
${python} ${idf_path}/tools/kconfig_new/confgen.py
|
${python} ${idf_path}/tools/kconfig_new/confgen.py
|
||||||
|
--list-separator=semicolon
|
||||||
--kconfig ${root_kconfig}
|
--kconfig ${root_kconfig}
|
||||||
--sdkconfig-rename ${root_sdkconfig_rename}
|
--sdkconfig-rename ${root_sdkconfig_rename}
|
||||||
--config ${sdkconfig}
|
--config ${sdkconfig}
|
||||||
|
@ -223,6 +223,10 @@ def main():
|
|||||||
help='Optional file to load environment variables from. Contents '
|
help='Optional file to load environment variables from. Contents '
|
||||||
'should be a JSON object where each key/value pair is a variable.')
|
'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_SDKCONFIG_RENAMES)')
|
||||||
|
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
for fmt, filename in args.output:
|
for fmt, filename in args.output:
|
||||||
@ -247,8 +251,12 @@ def main():
|
|||||||
config.warn_assign_redun = False
|
config.warn_assign_redun = False
|
||||||
config.warn_assign_override = False
|
config.warn_assign_override = False
|
||||||
|
|
||||||
|
sdkconfig_renames_sep = ';' if args.list_separator == 'semicolon' else ' '
|
||||||
|
|
||||||
sdkconfig_renames = [args.sdkconfig_rename] if args.sdkconfig_rename else []
|
sdkconfig_renames = [args.sdkconfig_rename] if args.sdkconfig_rename else []
|
||||||
sdkconfig_renames += os.environ.get('COMPONENT_SDKCONFIG_RENAMES', '').split()
|
sdkconfig_renames_from_env = os.environ.get('COMPONENT_SDKCONFIG_RENAMES')
|
||||||
|
if sdkconfig_renames_from_env:
|
||||||
|
sdkconfig_renames += sdkconfig_renames_from_env.split(sdkconfig_renames_sep)
|
||||||
deprecated_options = DeprecatedOptions(config.config_prefix, path_rename_files=sdkconfig_renames)
|
deprecated_options = DeprecatedOptions(config.config_prefix, path_rename_files=sdkconfig_renames)
|
||||||
|
|
||||||
if len(args.defaults) > 0:
|
if len(args.defaults) > 0:
|
||||||
|
@ -74,7 +74,9 @@ def main():
|
|||||||
def run_server(kconfig, sdkconfig, sdkconfig_rename, default_version=MAX_PROTOCOL_VERSION):
|
def run_server(kconfig, sdkconfig, sdkconfig_rename, default_version=MAX_PROTOCOL_VERSION):
|
||||||
config = kconfiglib.Kconfig(kconfig)
|
config = kconfiglib.Kconfig(kconfig)
|
||||||
sdkconfig_renames = [sdkconfig_rename] if sdkconfig_rename else []
|
sdkconfig_renames = [sdkconfig_rename] if sdkconfig_rename else []
|
||||||
sdkconfig_renames += os.environ.get('COMPONENT_SDKCONFIG_RENAMES', '').split()
|
sdkconfig_renames_from_env = os.environ.get('COMPONENT_SDKCONFIG_RENAMES')
|
||||||
|
if sdkconfig_renames_from_env:
|
||||||
|
sdkconfig_renames += sdkconfig_renames_from_env.split(';')
|
||||||
deprecated_options = confgen.DeprecatedOptions(config.config_prefix, path_rename_files=sdkconfig_renames)
|
deprecated_options = confgen.DeprecatedOptions(config.config_prefix, path_rename_files=sdkconfig_renames)
|
||||||
f_o = tempfile.NamedTemporaryFile(mode='w+b', delete=False)
|
f_o = tempfile.NamedTemporaryFile(mode='w+b', delete=False)
|
||||||
try:
|
try:
|
||||||
@ -157,8 +159,8 @@ def run_server(kconfig, sdkconfig, sdkconfig_rename, default_version=MAX_PROTOCO
|
|||||||
# V2+ response, separate visibility values
|
# V2+ response, separate visibility values
|
||||||
response = {'version': req['version'], 'values': values_diff, 'ranges': ranges_diff, 'visible': visible_diff}
|
response = {'version': req['version'], 'values': values_diff, 'ranges': ranges_diff, 'visible': visible_diff}
|
||||||
if error:
|
if error:
|
||||||
for e in error:
|
for err in error:
|
||||||
print('Error: %s' % e, file=sys.stderr)
|
print('Error: %s' % err, file=sys.stderr)
|
||||||
response['error'] = error
|
response['error'] = error
|
||||||
json.dump(response, sys.stdout)
|
json.dump(response, sys.stdout)
|
||||||
print('\n')
|
print('\n')
|
||||||
|
@ -1,18 +1,7 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
#
|
#
|
||||||
# Copyright 2019 Espressif Systems (Shanghai) PTE LTD
|
# SPDX-FileCopyrightText: 2019-2021 Espressif Systems (Shanghai) CO LTD
|
||||||
#
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
# you may not use this file except in compliance with the License.
|
|
||||||
# You may obtain a copy of the License at
|
|
||||||
#
|
|
||||||
# http:#www.apache.org/licenses/LICENSE-2.0
|
|
||||||
#
|
|
||||||
# Unless required by applicable law or agreed to in writing, software
|
|
||||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
# See the License for the specific language governing permissions and
|
|
||||||
# limitations under the License.
|
|
||||||
|
|
||||||
from __future__ import print_function, unicode_literals
|
from __future__ import print_function, unicode_literals
|
||||||
|
|
||||||
@ -22,7 +11,7 @@ import sys
|
|||||||
from io import open
|
from io import open
|
||||||
|
|
||||||
|
|
||||||
def _prepare_source_files(env_dict):
|
def _prepare_source_files(env_dict, list_separator):
|
||||||
"""
|
"""
|
||||||
Prepares source files which are sourced from the main Kconfig because upstream kconfiglib doesn't support sourcing
|
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:
|
a file list. The inputs are the same environment variables which are used by kconfiglib:
|
||||||
@ -37,18 +26,27 @@ def _prepare_source_files(env_dict):
|
|||||||
|
|
||||||
After running this function, COMPONENT_KCONFIGS_SOURCE_FILE and COMPONENT_KCONFIGS_PROJBUILD_SOURCE_FILE will
|
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,
|
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
|
respectively. 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:
|
COMPONENT_KCONFIGS_SOURCE_FILE="/path/file.txt" then the content of file /path/file.txt will be:
|
||||||
source "var1"
|
source "var1"
|
||||||
source "var2"
|
source "var2"
|
||||||
source "var3"
|
source "var3"
|
||||||
|
|
||||||
|
The character used to delimit paths in COMPONENT_KCONFIGS* variables is determined based on
|
||||||
|
presence of 'IDF_CMAKE' variable in the env_dict.
|
||||||
|
GNU Make build system uses a space, CMake build system uses a semicolon.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def _dequote(var):
|
def _dequote(var):
|
||||||
return var[1:-1] if len(var) > 0 and (var[0], var[-1]) == ('"',) * 2 else var
|
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, config_file):
|
||||||
new_content = '\n'.join(['source "{}"'.format(path) for path in _dequote(config_var).split()])
|
dequoted_var = _dequote(config_var)
|
||||||
|
if dequoted_var:
|
||||||
|
new_content = '\n'.join(['source "{}"'.format(path) for path in dequoted_var.split(list_separator)])
|
||||||
|
else:
|
||||||
|
new_content = ''
|
||||||
|
|
||||||
try:
|
try:
|
||||||
with open(config_file, 'r', encoding='utf-8') as f:
|
with open(config_file, 'r', encoding='utf-8') as f:
|
||||||
old_content = f.read()
|
old_content = f.read()
|
||||||
@ -71,8 +69,7 @@ def _prepare_source_files(env_dict):
|
|||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
def main():
|
||||||
|
|
||||||
parser = argparse.ArgumentParser(description='Kconfig Source File Generator')
|
parser = argparse.ArgumentParser(description='Kconfig Source File Generator')
|
||||||
|
|
||||||
parser.add_argument('--env', action='append', default=[],
|
parser.add_argument('--env', action='append', default=[],
|
||||||
@ -82,6 +79,10 @@ if __name__ == '__main__':
|
|||||||
help='Optional file to load environment variables from. Contents '
|
help='Optional file to load environment variables from. Contents '
|
||||||
'should be a JSON object where each key/value pair is a variable.')
|
'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)')
|
||||||
|
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
try:
|
try:
|
||||||
@ -93,4 +94,10 @@ if __name__ == '__main__':
|
|||||||
if args.env_file is not None:
|
if args.env_file is not None:
|
||||||
env.update(json.load(args.env_file))
|
env.update(json.load(args.env_file))
|
||||||
|
|
||||||
_prepare_source_files(env)
|
list_separator = ';' if args.list_separator == 'semicolon' else ' '
|
||||||
|
|
||||||
|
_prepare_source_files(env, list_separator)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
main()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user