linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] kconfig: fence choices and menuconfigs with comments in .config too
@ 2021-03-19 19:32 Alexander Lobakin
  2021-03-19 19:32 ` [PATCH 1/2] " Alexander Lobakin
  2021-03-19 19:32 ` [PATCH 2/2] kconfig: mention submenu type in comment blocks in .config Alexander Lobakin
  0 siblings, 2 replies; 3+ messages in thread
From: Alexander Lobakin @ 2021-03-19 19:32 UTC (permalink / raw)
  To: Masahiro Yamada; +Cc: Alexander Lobakin, linux-kbuild, linux-kernel

Comment blocks for menus are great for dotconfig readability, but
currently it's the only type (beside plain comments) of submenus
for which these block are generated.
This series expands the code to also generate such blocks for choices
and menuconfigs and additionally expands the comments themselves a
bit to let know if they belong to choice or menu{,config} block.

Alexander Lobakin (2):
  kconfig: fence choices and menuconfigs with comments in .config too
  kconfig: mention submenu type in comment blocks in .config

 scripts/kconfig/confdata.c | 43 +++++++++++++++++++++++++-------------
 1 file changed, 29 insertions(+), 14 deletions(-)

--
2.31.0



^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH 1/2] kconfig: fence choices and menuconfigs with comments in .config too
  2021-03-19 19:32 [PATCH 0/2] kconfig: fence choices and menuconfigs with comments in .config too Alexander Lobakin
@ 2021-03-19 19:32 ` Alexander Lobakin
  2021-03-19 19:32 ` [PATCH 2/2] kconfig: mention submenu type in comment blocks in .config Alexander Lobakin
  1 sibling, 0 replies; 3+ messages in thread
From: Alexander Lobakin @ 2021-03-19 19:32 UTC (permalink / raw)
  To: Masahiro Yamada; +Cc: Alexander Lobakin, linux-kbuild, linux-kernel

Comment blocks are now generated in .config only for menus. Provide
them for choices and menuconfigs too to greatly improve dotconfig
readability.

Choices before:

CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE=y
CONFIG_HAVE_LD_DEAD_CODE_DATA_ELIMINATION=y

Choices after:

CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE=y

CONFIG_HAVE_LD_DEAD_CODE_DATA_ELIMINATION=y

Menuconfigs before:

CONFIG_RESET_CONTROLLER=y

Menuconfigs after:

CONFIG_RESET_CONTROLLER=y

Signed-off-by: Alexander Lobakin <alobakin@pm.me>
---
 scripts/kconfig/confdata.c | 25 ++++++++++++++-----------
 1 file changed, 14 insertions(+), 11 deletions(-)

diff --git a/scripts/kconfig/confdata.c b/scripts/kconfig/confdata.c
index 2568dbe16ed6..e4f0a21fd469 100644
--- a/scripts/kconfig/confdata.c
+++ b/scripts/kconfig/confdata.c
@@ -869,17 +869,20 @@ int conf_write(const char *name)
 	menu = rootmenu.list;
 	while (menu) {
 		sym = menu->sym;
-		if (!sym) {
-			if (!menu_is_visible(menu))
-				goto next;
+
+		if ((!sym || (sym->flags & SYMBOL_CHOICE) ||
+		     (menu->prompt && menu->prompt->type == P_MENU)) &&
+		    menu_is_visible(menu)) {
 			str = menu_get_prompt(menu);
 			fprintf(out, "\n"
 				     "#\n"
 				     "# %s\n"
 				     "#\n", str);
 			need_newline = false;
-		} else if (!(sym->flags & SYMBOL_CHOICE) &&
-			   !(sym->flags & SYMBOL_WRITTEN)) {
+		}
+
+		if (sym && !(sym->flags & SYMBOL_CHOICE) &&
+		    !(sym->flags & SYMBOL_WRITTEN)) {
 			sym_calc_value(sym);
 			if (!(sym->flags & SYMBOL_WRITE))
 				goto next;
@@ -896,11 +899,11 @@ int conf_write(const char *name)
 			menu = menu->list;
 			continue;
 		}
-		if (menu->next)
-			menu = menu->next;
-		else while ((menu = menu->parent)) {
-			if (!menu->sym && menu_is_visible(menu) &&
-			    menu != &rootmenu) {
+
+		do {
+			if (((menu->sym && menu->sym->flags & SYMBOL_CHOICE) ||
+			     (menu->prompt && menu->prompt->type == P_MENU)) &&
+			    menu_is_visible(menu) && menu != &rootmenu) {
 				str = menu_get_prompt(menu);
 				fprintf(out, "# end of %s\n", str);
 				need_newline = true;
@@ -909,7 +912,7 @@ int conf_write(const char *name)
 				menu = menu->next;
 				break;
 			}
-		}
+		} while ((menu = menu->parent));
 	}
 	fclose(out);

--
2.31.0



^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH 2/2] kconfig: mention submenu type in comment blocks in .config
  2021-03-19 19:32 [PATCH 0/2] kconfig: fence choices and menuconfigs with comments in .config too Alexander Lobakin
  2021-03-19 19:32 ` [PATCH 1/2] " Alexander Lobakin
@ 2021-03-19 19:32 ` Alexander Lobakin
  1 sibling, 0 replies; 3+ messages in thread
From: Alexander Lobakin @ 2021-03-19 19:32 UTC (permalink / raw)
  To: Masahiro Yamada; +Cc: Alexander Lobakin, linux-kbuild, linux-kernel

To have a better understanding of the dotconfig blocks, mention if
a particular block-commented section is a choice or a menu{,config}.

Before:

CONFIG_TICK_ONESHOT=y
CONFIG_NO_HZ_COMMON=y

CONFIG_NO_HZ_IDLE=y

CONFIG_HIGH_RES_TIMERS=y

After:

CONFIG_TICK_ONESHOT=y
CONFIG_NO_HZ_COMMON=y

CONFIG_NO_HZ_IDLE=y

CONFIG_HIGH_RES_TIMERS=y

Signed-off-by: Alexander Lobakin <alobakin@pm.me>
---
 scripts/kconfig/confdata.c | 18 +++++++++++++++---
 1 file changed, 15 insertions(+), 3 deletions(-)

diff --git a/scripts/kconfig/confdata.c b/scripts/kconfig/confdata.c
index e4f0a21fd469..3f50d8b82a54 100644
--- a/scripts/kconfig/confdata.c
+++ b/scripts/kconfig/confdata.c
@@ -822,6 +822,17 @@ int conf_write_defconfig(const char *filename)
 	return 0;
 }

+static const char *menu_type_string(const struct menu *menu)
+{
+	if (menu->sym && (menu->sym->flags & SYMBOL_CHOICE))
+		return " choice";
+
+	if (menu->prompt && menu->prompt->type == P_MENU)
+		return " menu";
+
+	return "";
+}
+
 int conf_write(const char *name)
 {
 	FILE *out;
@@ -876,8 +887,8 @@ int conf_write(const char *name)
 			str = menu_get_prompt(menu);
 			fprintf(out, "\n"
 				     "#\n"
-				     "# %s\n"
-				     "#\n", str);
+				     "# %s%s\n"
+				     "#\n", str, menu_type_string(menu));
 			need_newline = false;
 		}

@@ -905,7 +916,8 @@ int conf_write(const char *name)
 			     (menu->prompt && menu->prompt->type == P_MENU)) &&
 			    menu_is_visible(menu) && menu != &rootmenu) {
 				str = menu_get_prompt(menu);
-				fprintf(out, "# end of %s\n", str);
+				fprintf(out, "# end of %s%s\n", str,
+					menu_type_string(menu));
 				need_newline = true;
 			}
 			if (menu->next) {
--
2.31.0



^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-03-19 19:33 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-19 19:32 [PATCH 0/2] kconfig: fence choices and menuconfigs with comments in .config too Alexander Lobakin
2021-03-19 19:32 ` [PATCH 1/2] " Alexander Lobakin
2021-03-19 19:32 ` [PATCH 2/2] kconfig: mention submenu type in comment blocks in .config Alexander Lobakin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).