From be749395c446627673d2c000d74a890a5e45011c Mon Sep 17 00:00:00 2001 From: Roland Dobai Date: Fri, 8 Nov 2019 14:40:28 +0100 Subject: [PATCH] Menuconfig: Don't ask to save configuration when nothing has changed Closes https://github.com/espressif/esp-idf/issues/4303 --- Kconfig | 2 +- make/project_config.mk | 16 +++++++++------- tools/cmake/kconfig.cmake | 6 ++++-- tools/kconfig/Makefile | 2 +- tools/kconfig/mconf.c | 2 ++ tools/kconfig/zconf.y | 9 +++++++++ tools/kconfig_new/confgen.py | 13 +++++++++---- 7 files changed, 35 insertions(+), 15 deletions(-) diff --git a/Kconfig b/Kconfig index cc66f8dc3..8f1d47e7c 100644 --- a/Kconfig +++ b/Kconfig @@ -20,7 +20,7 @@ mainmenu "Espressif IoT Development Framework Configuration" # the build system is responsible for detecting the mismatch between # CONFIG_IDF_TARGET and $IDF_TARGET. string - default "$(IDF_TARGET)" + default "$IDF_TARGET" config IDF_TARGET_ESP32 bool diff --git a/make/project_config.mk b/make/project_config.mk index b05a4a461..e9563092f 100644 --- a/make/project_config.mk +++ b/make/project_config.mk @@ -34,7 +34,7 @@ SDKCONFIG_DEFAULTS ?= $(PROJECT_PATH)/sdkconfig.defaults $(KCONFIG_TOOL_DIR)/mconf-idf: $(KCONFIG_TOOL_DIR)/conf-idf # reset MAKEFLAGS as the menuconfig makefile uses implicit compile rules -$(KCONFIG_TOOL_DIR)/mconf-idf $(KCONFIG_TOOL_DIR)/conf-idf: $(wildcard $(KCONFIG_TOOL_DIR)/*.c) +$(KCONFIG_TOOL_DIR)/mconf-idf $(KCONFIG_TOOL_DIR)/conf-idf: $(wildcard $(KCONFIG_TOOL_DIR)/*.c) $(wildcard $(KCONFIG_TOOL_DIR)/*.y) ifeq ($(OS),Windows_NT) # mconf-idf is used only in MSYS MAKEFLAGS="" CC=$(HOSTCC) LD=$(HOSTLD) \ @@ -66,7 +66,8 @@ SDKCONFIG_DEFAULTS_FILES := $(foreach f,$(SDKCONFIG_DEFAULTS),$(wildcard $(f))) SDKCONFIG_DEFAULTS_FILES += $(foreach f,$(SDKCONFIG_DEFAULTS_FILES),$(wildcard $(f).$(IDF_TARGET))) ifeq ($(OS),Windows_NT) -SDKCONFIG_DEFAULTS_FILES := $(shell cygpath -m $(SDKCONFIG_DEFAULTS_FILES)) +# -i is for ignore missing arguments in case SDKCONFIG_DEFAULTS_FILES is empty +SDKCONFIG_DEFAULTS_FILES := $(shell cygpath -i -m $(SDKCONFIG_DEFAULTS_FILES)) endif DEFAULTS_ARG := $(foreach f,$(SDKCONFIG_DEFAULTS_FILES),--defaults $(f)) @@ -94,7 +95,8 @@ define RunConfGen $(DEFAULTS_ARG) \ --output config ${SDKCONFIG} \ --output makefile $(SDKCONFIG_MAKEFILE) \ - --output header $(BUILD_DIR_BASE)/include/sdkconfig.h + --output header $(BUILD_DIR_BASE)/include/sdkconfig.h \ + $1 endef ifeq ($(OS),Windows_NT) @@ -135,23 +137,23 @@ ifdef BATCH_BUILD @echo "See esp-idf documentation for more details." @exit 1 else - $(call RunConfGen) + $(call RunConfGen,--dont-write-deprecated) # RunConfGen before menuconfig ensures that deprecated options won't be ignored (they've got renamed) $(call RunMenuConf) # RunConfGen after menuconfig ensures that deprecated options are appended to $(SDKCONFIG) for backward compatibility - $(call RunConfGen) + $(call RunConfGen,) endif # defconfig creates a default config, based on SDKCONFIG_DEFAULTS if present defconfig: | check_python_dependencies prepare_kconfig_files $(summary) DEFCONFIG - $(call RunConfGen) + $(call RunConfGen,) # if neither defconfig or menuconfig are requested, use the GENCONFIG rule to # ensure generated config files are up to date $(SDKCONFIG_MAKEFILE) $(BUILD_DIR_BASE)/include/sdkconfig.h: $(SDKCONFIG) $(COMPONENT_KCONFIGS) $(COMPONENT_KCONFIGS_PROJBUILD) | check_python_dependencies prepare_kconfig_files $(call prereq_if_explicit,defconfig) $(call prereq_if_explicit,menuconfig) $(summary) GENCONFIG - $(call RunConfGen) + $(call RunConfGen,) touch $(SDKCONFIG_MAKEFILE) $(BUILD_DIR_BASE)/include/sdkconfig.h # ensure newer than sdkconfig else # "$(MAKE_RESTARTS)" != "" diff --git a/tools/cmake/kconfig.cmake b/tools/cmake/kconfig.cmake index 3bc476b25..b12e4f309 100644 --- a/tools/cmake/kconfig.cmake +++ b/tools/cmake/kconfig.cmake @@ -263,12 +263,14 @@ function(__kconfig_generate_config sdkconfig sdkconfig_defaults) ${menuconfig_depends} # create any missing config file, with defaults if necessary COMMAND ${prepare_kconfig_files_command} - COMMAND ${confgen_basecommand} --env "IDF_TARGET=${idf_target}" --output config ${sdkconfig} + COMMAND ${confgen_basecommand} + --env "IDF_TARGET=${idf_target}" + --dont-write-deprecated + --output config ${sdkconfig} COMMAND ${CMAKE_COMMAND} -E env "COMPONENT_KCONFIGS_SOURCE_FILE=${kconfigs_path}" "COMPONENT_KCONFIGS_PROJBUILD_SOURCE_FILE=${kconfigs_projbuild_path}" "IDF_CMAKE=y" - "IDF_TARGET=${IDF_TARGET}" "KCONFIG_CONFIG=${sdkconfig}" "IDF_TARGET=${idf_target}" ${MENUCONFIG_CMD} ${root_kconfig} diff --git a/tools/kconfig/Makefile b/tools/kconfig/Makefile index 9fc367b45..b0b1ab565 100644 --- a/tools/kconfig/Makefile +++ b/tools/kconfig/Makefile @@ -311,7 +311,7 @@ ifeq ($(MAKECMDGOALS),gconfig) fi endif -zconf.tab.o: zconf.lex.c zconf.hash.c +zconf.tab.o: zconf.lex.c zconf.hash.c zconf.tab.c qconf.o: qconf.moc diff --git a/tools/kconfig/mconf.c b/tools/kconfig/mconf.c index 75fe11635..02cd0bbf0 100644 --- a/tools/kconfig/mconf.c +++ b/tools/kconfig/mconf.c @@ -1042,6 +1042,8 @@ int main(int ac, char **av) return 1; } + sym_set_change_count(0); + set_config_filename(conf_get_configname()); conf_set_message_callback(conf_message_callback); do { diff --git a/tools/kconfig/zconf.y b/tools/kconfig/zconf.y index 77c713313..1074d9f06 100644 --- a/tools/kconfig/zconf.y +++ b/tools/kconfig/zconf.y @@ -12,6 +12,7 @@ #include #include "lkc.h" +#include "expand_env.h" #define printd(mask, fmt...) if (cdebug & (mask)) printf(fmt) @@ -202,6 +203,14 @@ config_option: T_PROMPT prompt if_expr T_EOL config_option: T_DEFAULT expr if_expr T_EOL { + if ($2 && $2->type == E_SYMBOL) { + char *str = expand_environment($2->left.sym->name, zconf_curname(), zconf_lineno()); + if (strcmp($2->left.sym->name, str) != 0) { + $2->left.sym->name = realloc($2->left.sym->name, strlen(str) + 1); + strncpy($2->left.sym->name, str, strlen(str) + 1); + } + free_expanded(str); + } menu_add_expr(P_DEFAULT, $2, $3); if ($1->stype != S_UNKNOWN) menu_set_type($1->stype); diff --git a/tools/kconfig_new/confgen.py b/tools/kconfig_new/confgen.py index 185aa2903..5d4b5041e 100755 --- a/tools/kconfig_new/confgen.py +++ b/tools/kconfig_new/confgen.py @@ -213,6 +213,10 @@ def main(): help='File with deprecated Kconfig options', required=False) + parser.add_argument('--dont-write-deprecated', + help='Do not write compatibility statements for deprecated values', + action='store_true') + parser.add_argument('--output', nargs=2, action='append', help='Write output file (format and output filename)', metavar=('FORMAT', 'FILENAME'), @@ -253,10 +257,6 @@ def main(): sdkconfig_renames += os.environ.get("COMPONENT_SDKCONFIG_RENAMES", "").split() deprecated_options = DeprecatedOptions(config.config_prefix, path_rename_files=sdkconfig_renames) - sdkconfig_renames = [args.sdkconfig_rename] if args.sdkconfig_rename else [] - sdkconfig_renames += os.environ.get("COMPONENT_SDKCONFIG_RENAMES", "").split() - deprecated_options = DeprecatedOptions(config.config_prefix, path_rename_files=sdkconfig_renames) - if len(args.defaults) > 0: def _replace_empty_assignments(path_in, path_out): with open(path_in, 'r') as f_in, open(path_out, 'w') as f_out: @@ -304,6 +304,11 @@ def main(): except OSError: pass + if args.dont_write_deprecated: + # The deprecated object was useful until now for replacements. Now it will be redefined with no configurations + # and as the consequence, it won't generate output with deprecated statements. + deprecated_options = DeprecatedOptions('', path_rename_files=[]) + # Output the files specified in the arguments for output_type, filename in args.output: with tempfile.NamedTemporaryFile(prefix="confgen_tmp", delete=False) as f: