From patchwork Tue May 8 17:59:11 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eugeniu Rosca X-Patchwork-Id: 910546 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=de.adit-jv.com Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 40gbMf2pKxz9s1w for ; Wed, 9 May 2018 09:30:52 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id 30BEAC21E7F; Tue, 8 May 2018 23:30:47 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 736F3C21C38; Tue, 8 May 2018 23:30:44 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 19368C21ECE; Tue, 8 May 2018 17:59:49 +0000 (UTC) Received: from smtp1.de.adit-jv.com (smtp1.de.adit-jv.com [62.225.105.245]) by lists.denx.de (Postfix) with ESMTPS id 85252C21EA2 for ; Tue, 8 May 2018 17:59:48 +0000 (UTC) Received: from localhost (smtp1.de.adit-jv.com [127.0.0.1]) by smtp1.de.adit-jv.com (Postfix) with ESMTP id B5E683C1356; Tue, 8 May 2018 19:59:47 +0200 (CEST) Received: from smtp1.de.adit-jv.com ([127.0.0.1]) by localhost (smtp1.de.adit-jv.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id OUsRD61an-Li; Tue, 8 May 2018 19:59:37 +0200 (CEST) Received: from HI2EXCH01.adit-jv.com (hi2exch01.adit-jv.com [10.72.92.24]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp1.de.adit-jv.com (Postfix) with ESMTPS id AC05E3C0034; Tue, 8 May 2018 19:59:37 +0200 (CEST) Received: from vmlxhi-102.adit-jv.com (10.72.93.184) by HI2EXCH01.adit-jv.com (10.72.92.24) with Microsoft SMTP Server (TLS) id 14.3.389.1; Tue, 8 May 2018 19:59:37 +0200 From: Eugeniu Rosca To: Masahiro Yamada , Ulf Magnusson , Petr Vorel , Tom Rini , Simon Glass Date: Tue, 8 May 2018 19:59:11 +0200 Message-ID: <20180508175911.16259-1-erosca@de.adit-jv.com> X-Mailer: git-send-email 2.17.0 MIME-Version: 1.0 X-Originating-IP: [10.72.93.184] X-Mailman-Approved-At: Tue, 08 May 2018 23:30:43 +0000 Cc: u-boot@lists.denx.de, Eugeniu Rosca Subject: [U-Boot] [PATCH] kconfig: Print reverse dependencies in groups X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" Not sure if partial/limited sync with Linux Kconfig is practiced, but if yes, then pick below three Linux commits, which are focused around improving the readability of reverse dependencies in menuconfig UI. [1] commit 1ccb27143360bd2390a9a970e50709f858b53761 Author: Petr Vorel kconfig: make "Selected by:" and "Implied by:" readable [2] commit 9a47ceec543bfb703fbe2f8d584850b582caf1a6 Masahiro Yamada kconfig: clean-up reverse dependency help implementation [3] commit d9119b5925a03b9a3191fa3e93b4091651d8ad25 Author: Eugeniu Rosca kconfig: Print reverse dependencies in groups Here is an example of re-formatted information about the reverse dependencies of CONFIG_DM (sandbox_defconfig): * W/o the imported commits: Selected by: NIOS2 [=n] && || SANDBOX [=y] && || X86 [=n] && || ARCH_MVEBU [=n] && || TARGET_STV0991 [=n] && || ARCH_BCM283X [=n] && || ARCH_EXYNOS [=n] && || ARCH_S5PC1XX [=n] && ... * With the imported commits: Selected by [y]: - SANDBOX [=y] && - LOG [=y] Selected by [n]: - NIOS2 [=n] && - X86 [=n] && - ARCH_MVEBU [=n] && - TARGET_STV0991 [=n] && - ARCH_BCM283X [=n] && - ARCH_EXYNOS [=n] && - ARCH_S5PC1XX [=n] && - ARCH_INTEGRATOR [=n] && - ARCH_MX8M [=n] && - ARCH_QEMU [=n] && - ARCH_RMOBILE [=n] && - ARCH_SNAPDRAGON [=n] && - ARCH_SOCFPGA [=n] && - ARCH_SUNXI [=n] && - ARCH_ZYNQ [=n] && - ARCH_ZYNQMP [=n] && - TARGET_HIKEY [=n] && ... Signed-off-by: Eugeniu Rosca --- scripts/kconfig/expr.c | 34 +++++++++++++++++++++++++++++++++- scripts/kconfig/expr.h | 2 ++ scripts/kconfig/menu.c | 12 ++++++------ 3 files changed, 41 insertions(+), 7 deletions(-) diff --git a/scripts/kconfig/expr.c b/scripts/kconfig/expr.c index cbf4996dd9c1..40887d17f1e2 100644 --- a/scripts/kconfig/expr.c +++ b/scripts/kconfig/expr.c @@ -1070,7 +1070,9 @@ struct expr *expr_simplify_unmet_dep(struct expr *e1, struct expr *e2) return expr_get_leftmost_symbol(ret); } -void expr_print(struct expr *e, void (*fn)(void *, struct symbol *, const char *), void *data, int prevtoken) +void expr_print(struct expr *e, + void (*fn)(void *, struct symbol *, const char *), + void *data, int prevtoken) { if (!e) { fn(data, NULL, "y"); @@ -1204,3 +1206,33 @@ void expr_gstr_print(struct expr *e, struct gstr *gs) { expr_print(e, expr_print_gstr_helper, gs, E_NONE); } + +/* + * Transform the top level "||" tokens into newlines and prepend each + * line with a minus. This makes expressions much easier to read. + * Suitable for reverse dependency expressions. + */ +static void expr_print_revdep(struct expr *e, + void (*fn)(void *, struct symbol *, const char *), + void *data, tristate pr_type, const char **title) +{ + if (e->type == E_OR) { + expr_print_revdep(e->left.expr, fn, data, pr_type, title); + expr_print_revdep(e->right.expr, fn, data, pr_type, title); + } else if (expr_calc_value(e) == pr_type) { + if (*title) { + fn(data, NULL, *title); + *title = NULL; + } + + fn(data, NULL, " - "); + expr_print(e, fn, data, E_NONE); + fn(data, NULL, "\n"); + } +} + +void expr_gstr_print_revdep(struct expr *e, struct gstr *gs, + tristate pr_type, const char *title) +{ + expr_print_revdep(e, expr_print_gstr_helper, gs, pr_type, &title); +} diff --git a/scripts/kconfig/expr.h b/scripts/kconfig/expr.h index a73f762c48d6..3a3d334ed554 100644 --- a/scripts/kconfig/expr.h +++ b/scripts/kconfig/expr.h @@ -222,6 +222,8 @@ struct expr *expr_simplify_unmet_dep(struct expr *e1, struct expr *e2); void expr_fprint(struct expr *e, FILE *out); struct gstr; /* forward */ void expr_gstr_print(struct expr *e, struct gstr *gs); +void expr_gstr_print_revdep(struct expr *e, struct gstr *gs, + tristate pr_type, const char *title); static inline int expr_is_yes(struct expr *e) { diff --git a/scripts/kconfig/menu.c b/scripts/kconfig/menu.c index e9357931b47d..392c1a0a3963 100644 --- a/scripts/kconfig/menu.c +++ b/scripts/kconfig/menu.c @@ -675,16 +675,16 @@ static void get_symbol_str(struct gstr *r, struct symbol *sym, get_symbol_props_str(r, sym, P_SELECT, _(" Selects: ")); if (sym->rev_dep.expr) { - str_append(r, _(" Selected by: ")); - expr_gstr_print(sym->rev_dep.expr, r); - str_append(r, "\n"); + expr_gstr_print_revdep(sym->rev_dep.expr, r, yes, " Selected by [y]:\n"); + expr_gstr_print_revdep(sym->rev_dep.expr, r, mod, " Selected by [m]:\n"); + expr_gstr_print_revdep(sym->rev_dep.expr, r, no, " Selected by [n]:\n"); } get_symbol_props_str(r, sym, P_IMPLY, _(" Implies: ")); if (sym->implied.expr) { - str_append(r, _(" Implied by: ")); - expr_gstr_print(sym->implied.expr, r); - str_append(r, "\n"); + expr_gstr_print_revdep(sym->implied.expr, r, yes, " Implied by [y]:\n"); + expr_gstr_print_revdep(sym->implied.expr, r, mod, " Implied by [m]:\n"); + expr_gstr_print_revdep(sym->implied.expr, r, no, " Implied by [n]:\n"); } str_append(r, "\n\n");