Merge branch 'bugfix/regenerate_sdkconfig_fails_v3.2' into 'release/v3.2'
Fix issues with regenerating sdkconfig on modification (backport v3.2) See merge request idf/esp-idf!4169
This commit is contained in:
commit
671be20cc5
6 changed files with 110 additions and 34 deletions
|
@ -74,7 +74,6 @@ confgen_args = [sys.executable,
|
||||||
"../../tools/kconfig_new/confgen.py",
|
"../../tools/kconfig_new/confgen.py",
|
||||||
"--kconfig", "../../Kconfig",
|
"--kconfig", "../../Kconfig",
|
||||||
"--config", temp_sdkconfig_path,
|
"--config", temp_sdkconfig_path,
|
||||||
"--create-config-if-missing",
|
|
||||||
"--env", "COMPONENT_KCONFIGS={}".format(kconfigs),
|
"--env", "COMPONENT_KCONFIGS={}".format(kconfigs),
|
||||||
"--env", "COMPONENT_KCONFIGS_PROJBUILD={}".format(kconfig_projbuilds),
|
"--env", "COMPONENT_KCONFIGS_PROJBUILD={}".format(kconfig_projbuilds),
|
||||||
"--env", "IDF_PATH={}".format(idf_path),
|
"--env", "IDF_PATH={}".format(idf_path),
|
||||||
|
|
|
@ -238,6 +238,16 @@ function run_tests()
|
||||||
( make 2>&1 | grep "does not fit in configured flash size 1MB" ) || failure "Build didn't fail with expected flash size failure message"
|
( make 2>&1 | grep "does not fit in configured flash size 1MB" ) || failure "Build didn't fail with expected flash size failure message"
|
||||||
mv sdkconfig.bak sdkconfig
|
mv sdkconfig.bak sdkconfig
|
||||||
|
|
||||||
|
print_status "sdkconfig should have contents both files: sdkconfig and sdkconfig.defaults"
|
||||||
|
make clean > /dev/null;
|
||||||
|
rm -f sdkconfig.defaults;
|
||||||
|
rm -f sdkconfig;
|
||||||
|
echo "CONFIG_PARTITION_TABLE_OFFSET=0x10000" >> sdkconfig.defaults;
|
||||||
|
echo "CONFIG_PARTITION_TABLE_TWO_OTA=y" >> sdkconfig;
|
||||||
|
make defconfig > /dev/null;
|
||||||
|
grep "CONFIG_PARTITION_TABLE_OFFSET=0x10000" sdkconfig || failure "The define from sdkconfig.defaults should be into sdkconfig"
|
||||||
|
grep "CONFIG_PARTITION_TABLE_TWO_OTA=y" sdkconfig || failure "The define from sdkconfig should be into sdkconfig"
|
||||||
|
|
||||||
print_status "All tests completed"
|
print_status "All tests completed"
|
||||||
if [ -n "${FAILURES}" ]; then
|
if [ -n "${FAILURES}" ]; then
|
||||||
echo "Some failures were detected:"
|
echo "Some failures were detected:"
|
||||||
|
|
|
@ -212,6 +212,17 @@ function run_tests()
|
||||||
mv CMakeLists.bak CMakeLists.txt
|
mv CMakeLists.bak CMakeLists.txt
|
||||||
assert_built ${APP_BINS} ${BOOTLOADER_BINS} ${PARTITION_BIN}
|
assert_built ${APP_BINS} ${BOOTLOADER_BINS} ${PARTITION_BIN}
|
||||||
|
|
||||||
|
print_status "sdkconfig should have contents both files: sdkconfig and sdkconfig.defaults"
|
||||||
|
idf.py clean > /dev/null;
|
||||||
|
idf.py fullclean > /dev/null;
|
||||||
|
rm -f sdkconfig.defaults;
|
||||||
|
rm -f sdkconfig;
|
||||||
|
echo "CONFIG_PARTITION_TABLE_OFFSET=0x10000" >> sdkconfig.defaults;
|
||||||
|
echo "CONFIG_PARTITION_TABLE_TWO_OTA=y" >> sdkconfig;
|
||||||
|
idf.py reconfigure > /dev/null;
|
||||||
|
grep "CONFIG_PARTITION_TABLE_OFFSET=0x10000" sdkconfig || failure "The define from sdkconfig.defaults should be into sdkconfig"
|
||||||
|
grep "CONFIG_PARTITION_TABLE_TWO_OTA=y" sdkconfig || failure "The define from sdkconfig should be into sdkconfig"
|
||||||
|
|
||||||
print_status "All tests completed"
|
print_status "All tests completed"
|
||||||
if [ -n "${FAILURES}" ]; then
|
if [ -n "${FAILURES}" ]; then
|
||||||
echo "Some failures were detected:"
|
echo "Some failures were detected:"
|
||||||
|
|
|
@ -109,7 +109,6 @@ function(kconfig_process_config)
|
||||||
--kconfig ${ROOT_KCONFIG}
|
--kconfig ${ROOT_KCONFIG}
|
||||||
--config ${SDKCONFIG}
|
--config ${SDKCONFIG}
|
||||||
${defaults_arg}
|
${defaults_arg}
|
||||||
--create-config-if-missing
|
|
||||||
--env "COMPONENT_KCONFIGS=${kconfigs}"
|
--env "COMPONENT_KCONFIGS=${kconfigs}"
|
||||||
--env "COMPONENT_KCONFIGS_PROJBUILD=${kconfigs_projbuild}"
|
--env "COMPONENT_KCONFIGS_PROJBUILD=${kconfigs_projbuild}"
|
||||||
--env "IDF_CMAKE=y")
|
--env "IDF_CMAKE=y")
|
||||||
|
@ -141,12 +140,24 @@ function(kconfig_process_config)
|
||||||
# makes sdkconfig.h and skdconfig.cmake
|
# makes sdkconfig.h and skdconfig.cmake
|
||||||
#
|
#
|
||||||
# This happens during the cmake run not during the build
|
# This happens during the cmake run not during the build
|
||||||
execute_process(COMMAND ${confgen_basecommand}
|
if(NOT BOOTLOADER_BUILD)
|
||||||
|
execute_process(
|
||||||
|
COMMAND ${confgen_basecommand}
|
||||||
|
--output header ${SDKCONFIG_HEADER}
|
||||||
|
--output cmake ${SDKCONFIG_CMAKE}
|
||||||
|
--output json ${SDKCONFIG_JSON}
|
||||||
|
--output json_menus ${KCONFIG_JSON_MENUS}
|
||||||
|
--output config ${SDKCONFIG} # only generate config at the top-level project
|
||||||
|
RESULT_VARIABLE config_result)
|
||||||
|
else()
|
||||||
|
execute_process(
|
||||||
|
COMMAND ${confgen_basecommand}
|
||||||
--output header ${SDKCONFIG_HEADER}
|
--output header ${SDKCONFIG_HEADER}
|
||||||
--output cmake ${SDKCONFIG_CMAKE}
|
--output cmake ${SDKCONFIG_CMAKE}
|
||||||
--output json ${SDKCONFIG_JSON}
|
--output json ${SDKCONFIG_JSON}
|
||||||
--output json_menus ${KCONFIG_JSON_MENUS}
|
--output json_menus ${KCONFIG_JSON_MENUS}
|
||||||
RESULT_VARIABLE config_result)
|
RESULT_VARIABLE config_result)
|
||||||
|
endif()
|
||||||
if(config_result)
|
if(config_result)
|
||||||
message(FATAL_ERROR "Failed to run confgen.py (${confgen_basecommand}). Error ${config_result}")
|
message(FATAL_ERROR "Failed to run confgen.py (${confgen_basecommand}). Error ${config_result}")
|
||||||
endif()
|
endif()
|
||||||
|
|
|
@ -50,10 +50,6 @@ def main():
|
||||||
nargs='?',
|
nargs='?',
|
||||||
default=None)
|
default=None)
|
||||||
|
|
||||||
parser.add_argument('--create-config-if-missing',
|
|
||||||
help='If set, a new config file will be saved if the old one is not found',
|
|
||||||
action='store_true')
|
|
||||||
|
|
||||||
parser.add_argument('--kconfig',
|
parser.add_argument('--kconfig',
|
||||||
help='KConfig file with config item definitions',
|
help='KConfig file with config item definitions',
|
||||||
required=True)
|
required=True)
|
||||||
|
@ -83,6 +79,8 @@ def main():
|
||||||
os.environ[name] = value
|
os.environ[name] = value
|
||||||
|
|
||||||
config = kconfiglib.Kconfig(args.kconfig)
|
config = kconfiglib.Kconfig(args.kconfig)
|
||||||
|
config.disable_redun_warnings()
|
||||||
|
config.disable_override_warnings()
|
||||||
|
|
||||||
if args.defaults is not None:
|
if args.defaults is not None:
|
||||||
# always load defaults first, so any items which are not defined in that config
|
# always load defaults first, so any items which are not defined in that config
|
||||||
|
@ -91,15 +89,11 @@ def main():
|
||||||
raise RuntimeError("Defaults file not found: %s" % args.defaults)
|
raise RuntimeError("Defaults file not found: %s" % args.defaults)
|
||||||
config.load_config(args.defaults)
|
config.load_config(args.defaults)
|
||||||
|
|
||||||
if args.config is not None:
|
# If config file previously exists, load it
|
||||||
if os.path.exists(args.config):
|
if args.config and os.path.exists(args.config):
|
||||||
config.load_config(args.config)
|
config.load_config(args.config, replace=False)
|
||||||
elif args.create_config_if_missing:
|
|
||||||
print("Creating config file %s..." % args.config)
|
|
||||||
config.write_config(args.config)
|
|
||||||
elif args.default is None:
|
|
||||||
raise RuntimeError("Config file not found: %s" % args.config)
|
|
||||||
|
|
||||||
|
# Output the files specified in the arguments
|
||||||
for output_type, filename in args.output:
|
for output_type, filename in args.output:
|
||||||
temp_file = tempfile.mktemp(prefix="confgen_tmp")
|
temp_file = tempfile.mktemp(prefix="confgen_tmp")
|
||||||
try:
|
try:
|
||||||
|
@ -263,6 +257,7 @@ def write_json_menus(config, filename):
|
||||||
def update_if_changed(source, destination):
|
def update_if_changed(source, destination):
|
||||||
with open(source, "r") as f:
|
with open(source, "r") as f:
|
||||||
source_contents = f.read()
|
source_contents = f.read()
|
||||||
|
|
||||||
if os.path.exists(destination):
|
if os.path.exists(destination):
|
||||||
with open(destination, "r") as f:
|
with open(destination, "r") as f:
|
||||||
dest_contents = f.read()
|
dest_contents = f.read()
|
||||||
|
|
|
@ -500,6 +500,8 @@ class Kconfig(object):
|
||||||
__slots__ = (
|
__slots__ = (
|
||||||
"_choices",
|
"_choices",
|
||||||
"_print_undef_assign",
|
"_print_undef_assign",
|
||||||
|
"_print_override",
|
||||||
|
"_print_redun_assign",
|
||||||
"_print_warnings",
|
"_print_warnings",
|
||||||
"_set_re_match",
|
"_set_re_match",
|
||||||
"_unset_re_match",
|
"_unset_re_match",
|
||||||
|
@ -575,6 +577,7 @@ class Kconfig(object):
|
||||||
|
|
||||||
self._print_warnings = warn
|
self._print_warnings = warn
|
||||||
self._print_undef_assign = False
|
self._print_undef_assign = False
|
||||||
|
self._print_redun_assign = self._print_override = True
|
||||||
|
|
||||||
self.syms = {}
|
self.syms = {}
|
||||||
self.const_syms = {}
|
self.const_syms = {}
|
||||||
|
@ -826,10 +829,12 @@ class Kconfig(object):
|
||||||
display_val = val
|
display_val = val
|
||||||
display_user_val = sym.user_value
|
display_user_val = sym.user_value
|
||||||
|
|
||||||
self._warn('{} set more than once. Old value: "{}", new '
|
msg = '{} set more than once. Old value: "{}", new value: "{}".'.format(name, display_user_val, display_val)
|
||||||
'value: "{}".'
|
|
||||||
.format(name, display_user_val, display_val),
|
if display_user_val == display_val:
|
||||||
filename, linenr)
|
self._warn_redun_assign(msg, filename, linenr)
|
||||||
|
else:
|
||||||
|
self._warn_override(msg, filename, linenr)
|
||||||
|
|
||||||
sym.set_value(val)
|
sym.set_value(val)
|
||||||
|
|
||||||
|
@ -1057,6 +1062,36 @@ class Kconfig(object):
|
||||||
"""
|
"""
|
||||||
self._print_undef_assign = False
|
self._print_undef_assign = False
|
||||||
|
|
||||||
|
def enable_redun_warnings(self):
|
||||||
|
"""
|
||||||
|
Enables warnings for redundant assignments to symbols. Printed to
|
||||||
|
stderr. Enabled by default.
|
||||||
|
"""
|
||||||
|
self._print_redun_assign = True
|
||||||
|
|
||||||
|
def disable_redun_warnings(self):
|
||||||
|
"""
|
||||||
|
See enable_redun_warnings().
|
||||||
|
"""
|
||||||
|
self._print_redun_assign = False
|
||||||
|
|
||||||
|
def enable_override_warnings(self):
|
||||||
|
"""
|
||||||
|
Enables warnings for duplicated assignments in .config files that set
|
||||||
|
different values (e.g. CONFIG_FOO=m followed by CONFIG_FOO=y, where
|
||||||
|
the last value set is used).
|
||||||
|
|
||||||
|
These warnings are enabled by default. Disabling them might be helpful
|
||||||
|
in certain cases when merging configurations.
|
||||||
|
"""
|
||||||
|
self._print_override = True
|
||||||
|
|
||||||
|
def disable_override_warnings(self):
|
||||||
|
"""
|
||||||
|
See enable_override_warnings().
|
||||||
|
"""
|
||||||
|
self._print_override = False
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
"""
|
"""
|
||||||
Returns a string with information about the Kconfig object when it is
|
Returns a string with information about the Kconfig object when it is
|
||||||
|
@ -1071,6 +1106,8 @@ class Kconfig(object):
|
||||||
"warnings " + ("enabled" if self._print_warnings else "disabled"),
|
"warnings " + ("enabled" if self._print_warnings else "disabled"),
|
||||||
"undef. symbol assignment warnings " +
|
"undef. symbol assignment warnings " +
|
||||||
("enabled" if self._print_undef_assign else "disabled"),
|
("enabled" if self._print_undef_assign else "disabled"),
|
||||||
|
"redundant symbol assignment warnings " +
|
||||||
|
("enabled" if self._print_redun_assign else "disabled")
|
||||||
)))
|
)))
|
||||||
|
|
||||||
#
|
#
|
||||||
|
@ -2150,6 +2187,19 @@ class Kconfig(object):
|
||||||
'attempt to assign the value "{}" to the undefined symbol {}' \
|
'attempt to assign the value "{}" to the undefined symbol {}' \
|
||||||
.format(val, name), filename, linenr)
|
.format(val, name), filename, linenr)
|
||||||
|
|
||||||
|
def _warn_redun_assign(self, msg, filename=None, linenr=None):
|
||||||
|
"""
|
||||||
|
See the class documentation.
|
||||||
|
"""
|
||||||
|
if self._print_redun_assign:
|
||||||
|
_stderr_msg("warning: " + msg, filename, linenr)
|
||||||
|
|
||||||
|
def _warn_override(self, msg, filename=None, linenr=None):
|
||||||
|
"""
|
||||||
|
See the class documentation.
|
||||||
|
"""
|
||||||
|
if self._print_override:
|
||||||
|
_stderr_msg("warning: " + msg, filename, linenr)
|
||||||
|
|
||||||
class Symbol(object):
|
class Symbol(object):
|
||||||
"""
|
"""
|
||||||
|
|
Loading…
Reference in a new issue