Skip to content

Commit 3460d0b

Browse files
tchebbmasahir0y
authored andcommitted
kconfig: distinguish between dependencies and visibility in help text
Kconfig makes a distinction between dependencies (defined by "depends on" expressions and enclosing "if" blocks) and visibility (which includes all dependencies, but also includes inline "if" expressions of individual properties as well as, for prompts, "visible if" expressions of enclosing menus). Before commit bcdedcc ("menuconfig: print more info for symbol without prompts"), the "Depends on" lines of a symbol's help text indicated the visibility of the prompt property they appeared under. After bcdedcc, there was always only a single "Depends on" line, which indicated the visibility of the first P_SYMBOL property of the symbol. Since P_SYMBOLs never have inline if expressions, this was in effect the same as the dependencies of the menu item that the P_SYMBOL was attached to. Neither of these situations accurately conveyed the dependencies of a symbol--the first because it was actually the visibility, and the second because it only showed the dependencies from a single definition. With this series, we are back to printing separate dependencies for each definition, but we print the actual dependencies (rather than the visibility) in the "Depends on" line. However, it can still be useful to know the visibility of a prompt, so this patch adds a "Visible if" line that shows the visibility only if the visibility is different from the dependencies (which it isn't for most prompts in Linux). Before: Symbol: THUMB2_KERNEL [=n] Type : bool Defined at arch/arm/Kconfig:1417 Prompt: Compile the kernel in Thumb-2 mode Depends on: (CPU_V7 [=y] || CPU_V7M [=n]) && !CPU_V6 [=n] && !CPU_V6K [=n] Location: -> Kernel Features Selects: ARM_UNWIND [=n] After: Symbol: THUMB2_KERNEL [=n] Type : bool Defined at arch/arm/Kconfig:1417 Prompt: Compile the kernel in Thumb-2 mode Depends on: (CPU_V7 [=y] || CPU_V7M [=n]) && !CPU_V6 [=n] && !CPU_V6K [=n] Visible if: (CPU_V7 [=y] || CPU_V7M [=n]) && !CPU_V6 [=n] && !CPU_V6K [=n] && !CPU_THUMBONLY [=n] Location: -> Kernel Features Selects: ARM_UNWIND [=n] Signed-off-by: Thomas Hebb <[email protected]> Signed-off-by: Masahiro Yamada <[email protected]>
1 parent edda15f commit 3460d0b

File tree

3 files changed

+13
-2
lines changed

3 files changed

+13
-2
lines changed

scripts/kconfig/expr.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313

1414
#define DEBUG_EXPR 0
1515

16-
static int expr_eq(struct expr *e1, struct expr *e2);
1716
static struct expr *expr_eliminate_yn(struct expr *e);
1817

1918
struct expr *expr_alloc_symbol(struct symbol *sym)
@@ -250,7 +249,7 @@ void expr_eliminate_eq(struct expr **ep1, struct expr **ep2)
250249
* equals some operand in the other (operands do not need to appear in the same
251250
* order), recursively.
252251
*/
253-
static int expr_eq(struct expr *e1, struct expr *e2)
252+
int expr_eq(struct expr *e1, struct expr *e2)
254253
{
255254
int res, old_count;
256255

scripts/kconfig/expr.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,7 @@ struct expr *expr_alloc_or(struct expr *e1, struct expr *e2);
300300
struct expr *expr_copy(const struct expr *org);
301301
void expr_free(struct expr *e);
302302
void expr_eliminate_eq(struct expr **ep1, struct expr **ep2);
303+
int expr_eq(struct expr *e1, struct expr *e2);
303304
tristate expr_calc_value(struct expr *e);
304305
struct expr *expr_trans_bool(struct expr *e);
305306
struct expr *expr_eliminate_dups(struct expr *e);

scripts/kconfig/menu.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -736,6 +736,17 @@ static void get_prompt_str(struct gstr *r, struct property *prop,
736736
str_printf(r, " Prompt: %s\n", prop->text);
737737

738738
get_dep_str(r, prop->menu->dep, " Depends on: ");
739+
/*
740+
* Most prompts in Linux have visibility that exactly matches their
741+
* dependencies. For these, we print only the dependencies to improve
742+
* readability. However, prompts with inline "if" expressions and
743+
* prompts with a parent that has a "visible if" expression have
744+
* differing dependencies and visibility. In these rare cases, we
745+
* print both.
746+
*/
747+
if (!expr_eq(prop->menu->dep, prop->visible.expr))
748+
get_dep_str(r, prop->visible.expr, " Visible if: ");
749+
739750
menu = prop->menu->parent;
740751
for (i = 0; menu != &rootmenu && i < 8; menu = menu->parent) {
741752
bool accessible = menu_is_visible(menu);

0 commit comments

Comments
 (0)