From 73b30af2b31b1b3f98e4f9b9e38acd5d598cba00 Mon Sep 17 00:00:00 2001 From: Ivan Grokhotkov Date: Fri, 7 Jun 2019 19:57:47 +0800 Subject: [PATCH] confgen.py: don't output compatibility definitions for options which are not defined For example, if a renamed option CONFIG_NEW is a bool with value "n", kconfiglib will not generate a define for it in the Kconfig file. The define (#define CONFIG_NEW 1) will only be generated if the option is "y" or "m". However the compatibility definition was always generated: #define CONFIG_OLD CONFIG_NEW. This broke the #ifdef checks which depended on the old option names. --- components/bootloader_support/src/bootloader_common.c | 8 ++++++++ tools/kconfig_new/confgen.py | 8 +++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/components/bootloader_support/src/bootloader_common.c b/components/bootloader_support/src/bootloader_common.c index 222d54f50..d0e9a9fc7 100644 --- a/components/bootloader_support/src/bootloader_common.c +++ b/components/bootloader_support/src/bootloader_common.c @@ -17,8 +17,16 @@ #include "sdkconfig.h" #include "esp_err.h" #include "esp_log.h" +#if CONFIG_IDF_TARGET_ESP32 +#include "esp32/rom/spi_flash.h" #include "esp32/rom/crc.h" #include "esp32/rom/gpio.h" +#elif CONFIG_IDF_TARGET_ESP32S2BETA +#include "esp32s2beta/rom/spi_flash.h" +#include "esp32s2beta/rom/crc.h" +#include "esp32s2beta/rom/ets_sys.h" +#include "esp32s2beta/rom/gpio.h" +#endif #include "esp_flash_partitions.h" #include "bootloader_flash.h" #include "bootloader_common.h" diff --git a/tools/kconfig_new/confgen.py b/tools/kconfig_new/confgen.py index 4ea033177..13abea2e5 100755 --- a/tools/kconfig_new/confgen.py +++ b/tools/kconfig_new/confgen.py @@ -162,12 +162,18 @@ class DeprecatedOptions(object): f_o.write('{}\n'.format(self._DEP_OP_END)) def append_header(self, config, path_output): + def _opt_defined(opt): + if not opt.visibility: + return False + return not (opt.orig_type in (kconfiglib.BOOL, kconfiglib.TRISTATE) and opt.str_value == "n") + if len(self.r_dic) > 0: with open(path_output, 'a') as f_o: f_o.write('\n/* List of deprecated options */\n') for dep_opt in sorted(self.r_dic): new_opt = self.r_dic[dep_opt] - f_o.write('#define {}{} {}{}\n'.format(self.config_prefix, dep_opt, self.config_prefix, new_opt)) + if new_opt in config.syms and _opt_defined(config.syms[new_opt]): + f_o.write('#define {}{} {}{}\n'.format(self.config_prefix, dep_opt, self.config_prefix, new_opt)) def main():