mirror of
https://github.com/espressif/esp-idf.git
synced 2024-09-20 00:36:01 -04:00
kconfig: confgen.py now handles many-to-one config renames
All old symbols will now be included in the output when renaming multiple symbols to the same new symbol.
This commit is contained in:
parent
23c55946a6
commit
65a302a6f6
@ -631,6 +631,35 @@ endmenu\n" >> ${IDF_PATH}/Kconfig
|
|||||||
git checkout -- sdkconfig.rename Kconfig
|
git checkout -- sdkconfig.rename Kconfig
|
||||||
popd
|
popd
|
||||||
|
|
||||||
|
echo "Can have multiple deprecated Kconfig options map to a single new option"
|
||||||
|
idf.py clean > /dev/null
|
||||||
|
rm -f sdkconfig.defaults
|
||||||
|
rm -f sdkconfig
|
||||||
|
echo "" > ${IDF_PATH}/sdkconfig.rename
|
||||||
|
idf.py reconfigure > /dev/null
|
||||||
|
echo "CONFIG_TEST_NEW_OPTION=y" >> sdkconfig
|
||||||
|
echo "CONFIG_TEST_OLD_OPTION_1 CONFIG_TEST_NEW_OPTION" >> ${IDF_PATH}/sdkconfig.rename
|
||||||
|
echo "CONFIG_TEST_OLD_OPTION_2 CONFIG_TEST_NEW_OPTION" >> ${IDF_PATH}/sdkconfig.rename
|
||||||
|
echo -e "\n\
|
||||||
|
menu \"test\"\n\
|
||||||
|
config TEST_NEW_OPTION\n\
|
||||||
|
bool \"test\"\n\
|
||||||
|
default \"n\"\n\
|
||||||
|
help\n\
|
||||||
|
TEST_NEW_OPTION description\n\
|
||||||
|
endmenu\n" >> ${IDF_PATH}/Kconfig
|
||||||
|
idf.py reconfigure > /dev/null
|
||||||
|
grep "CONFIG_TEST_OLD_OPTION_1=y" sdkconfig || failure "CONFIG_TEST_OLD_OPTION_1 should be in sdkconfig for backward compatibility"
|
||||||
|
grep "CONFIG_TEST_OLD_OPTION_2=y" sdkconfig || failure "CONFIG_TEST_OLD_OPTION_2 should be in sdkconfig for backward compatibility"
|
||||||
|
grep "#define CONFIG_TEST_OLD_OPTION_1 CONFIG_TEST_NEW_OPTION" build/config/sdkconfig.h || failure "sdkconfig.h should contain the compatibility macro"
|
||||||
|
grep "#define CONFIG_TEST_OLD_OPTION_2 CONFIG_TEST_NEW_OPTION" build/config/sdkconfig.h || failure "sdkconfig.h should contain the compatibility macro"
|
||||||
|
grep "set(CONFIG_TEST_OLD_OPTION_1 \"y\")" build/config/sdkconfig.cmake || failure "CONFIG_TEST_OLD_OPTION_1 should be in auto.conf for backward compatibility"
|
||||||
|
grep "set(CONFIG_TEST_OLD_OPTION_2 \"y\")" build/config/sdkconfig.cmake || failure "CONFIG_TEST_OLD_OPTION_2 should be in auto.conf for backward compatibility"
|
||||||
|
rm -rf sdkconfig sdkconfig.defaults build
|
||||||
|
pushd ${IDF_PATH}
|
||||||
|
git checkout -- sdkconfig.rename Kconfig
|
||||||
|
popd
|
||||||
|
|
||||||
echo "Can have target specific deprecated Kconfig options"
|
echo "Can have target specific deprecated Kconfig options"
|
||||||
idf.py clean
|
idf.py clean
|
||||||
rm -f sdkconfig
|
rm -f sdkconfig
|
||||||
|
@ -18,6 +18,7 @@ import re
|
|||||||
import sys
|
import sys
|
||||||
import tempfile
|
import tempfile
|
||||||
import textwrap
|
import textwrap
|
||||||
|
from collections import defaultdict
|
||||||
|
|
||||||
import gen_kconfig_doc
|
import gen_kconfig_doc
|
||||||
import kconfiglib
|
import kconfiglib
|
||||||
@ -43,7 +44,7 @@ class DeprecatedOptions(object):
|
|||||||
|
|
||||||
def _parse_replacements(self, repl_paths):
|
def _parse_replacements(self, repl_paths):
|
||||||
rep_dic = {}
|
rep_dic = {}
|
||||||
rev_rep_dic = {}
|
rev_rep_dic = defaultdict(list)
|
||||||
|
|
||||||
def remove_config_prefix(string):
|
def remove_config_prefix(string):
|
||||||
if string.startswith(self.config_prefix):
|
if string.startswith(self.config_prefix):
|
||||||
@ -68,11 +69,11 @@ class DeprecatedOptions(object):
|
|||||||
|
|
||||||
(dep_opt, new_opt) = (remove_config_prefix(x) for x in sp_line)
|
(dep_opt, new_opt) = (remove_config_prefix(x) for x in sp_line)
|
||||||
rep_dic[dep_opt] = new_opt
|
rep_dic[dep_opt] = new_opt
|
||||||
rev_rep_dic[new_opt] = dep_opt
|
rev_rep_dic[new_opt].append(dep_opt)
|
||||||
return rep_dic, rev_rep_dic
|
return rep_dic, rev_rep_dic
|
||||||
|
|
||||||
def get_deprecated_option(self, new_option):
|
def get_deprecated_option(self, new_option):
|
||||||
return self.rev_r_dic.get(new_option, None)
|
return self.rev_r_dic.get(new_option, [])
|
||||||
|
|
||||||
def get_new_option(self, deprecated_option):
|
def get_new_option(self, deprecated_option):
|
||||||
return self.r_dic.get(deprecated_option, None)
|
return self.r_dic.get(deprecated_option, None)
|
||||||
@ -128,10 +129,10 @@ class DeprecatedOptions(object):
|
|||||||
for sym in syms:
|
for sym in syms:
|
||||||
if sym.name in self.rev_r_dic:
|
if sym.name in self.rev_r_dic:
|
||||||
# only if the symbol has been renamed
|
# only if the symbol has been renamed
|
||||||
dep_name = self.rev_r_dic[sym.name]
|
dep_names = self.rev_r_dic[sym.name]
|
||||||
|
dep_names = [config.config_prefix + name for name in dep_names]
|
||||||
# config options doesn't have references
|
# config options doesn't have references
|
||||||
f_o.write(' - {}{}\n'.format(config.config_prefix, dep_name))
|
f_o.write(' - {}\n'.format(', '.join(dep_names)))
|
||||||
|
|
||||||
def append_config(self, config, path_output):
|
def append_config(self, config, path_output):
|
||||||
tmp_list = []
|
tmp_list = []
|
||||||
@ -142,8 +143,9 @@ class DeprecatedOptions(object):
|
|||||||
if item.name in self.rev_r_dic:
|
if item.name in self.rev_r_dic:
|
||||||
c_string = item.config_string
|
c_string = item.config_string
|
||||||
if c_string:
|
if c_string:
|
||||||
tmp_list.append(c_string.replace(self.config_prefix + item.name,
|
for dep_name in self.rev_r_dic[item.name]:
|
||||||
self.config_prefix + self.rev_r_dic[item.name]))
|
tmp_list.append(c_string.replace(self.config_prefix + item.name,
|
||||||
|
self.config_prefix + dep_name))
|
||||||
|
|
||||||
for n in config.node_iter():
|
for n in config.node_iter():
|
||||||
append_config_node_process(n)
|
append_config_node_process(n)
|
||||||
@ -392,10 +394,10 @@ def write_cmake(deprecated_options, config, filename):
|
|||||||
write('set({}{} "{}")\n'.format(prefix, sym.name, val))
|
write('set({}{} "{}")\n'.format(prefix, sym.name, val))
|
||||||
|
|
||||||
configs_list.append(prefix + sym.name)
|
configs_list.append(prefix + sym.name)
|
||||||
dep_opt = deprecated_options.get_deprecated_option(sym.name)
|
dep_opts = deprecated_options.get_deprecated_option(sym.name)
|
||||||
if dep_opt:
|
for opt in dep_opts:
|
||||||
tmp_dep_list.append('set({}{} "{}")\n'.format(prefix, dep_opt, val))
|
tmp_dep_list.append('set({}{} "{}")\n'.format(prefix, opt, val))
|
||||||
configs_list.append(prefix + dep_opt)
|
configs_list.append(prefix + opt)
|
||||||
|
|
||||||
for n in config.node_iter():
|
for n in config.node_iter():
|
||||||
write_node(n)
|
write_node(n)
|
||||||
|
Loading…
Reference in New Issue
Block a user