From patchwork Sun Feb 18 20:47:14 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eugeniu Rosca X-Patchwork-Id: 10226953 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id EF38C602CB for ; Sun, 18 Feb 2018 20:48:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DEC3528893 for ; Sun, 18 Feb 2018 20:48:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D39D228898; Sun, 18 Feb 2018 20:48:19 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4FEE628893 for ; Sun, 18 Feb 2018 20:48:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751769AbeBRUsT (ORCPT ); Sun, 18 Feb 2018 15:48:19 -0500 Received: from mail-wm0-f66.google.com ([74.125.82.66]:55493 "EHLO mail-wm0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751741AbeBRUsS (ORCPT ); Sun, 18 Feb 2018 15:48:18 -0500 Received: by mail-wm0-f66.google.com with SMTP id q83so2314467wme.5 for ; Sun, 18 Feb 2018 12:48:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=5poQIrTgAQZVX2pdOnDUeQMNWIu6Qq68I67od24jvts=; b=LnITR1Dv7TqjCW3rrGGSP9+9U1YfYQPrZidjcTz16gIOmpGDsB6h0ZXKgU+6NpUwNz V/JBollQyXJFOOmhHU1+F2AER3iLq56fzW/dOfrGBHkrV2m4zto5eCAKyL5gzkhIdiX1 HY3MUjlPaM2yfGFaVwzUvTuIIcvEnsKFfDRvfsG4qT/R9jg9v7h2uR/wLfii6EMp14bQ WlVzfqUCQh09b4RH9Z/taHg6W2p61K80h64WUdlOZ27If8ndJ+NyOmAOGy1JBFej5Z/i NtI9T6CAWCKwPjZGBiwVqliXkT7zLxM0DQwLVk27Q4HtcvUG8Xh00n4gmKawENTFfpzS 9lxg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=5poQIrTgAQZVX2pdOnDUeQMNWIu6Qq68I67od24jvts=; b=eMVxwcNTFAvyPv2ijoIOChMAmh5KQsNb4M7lpDdv5yAKnInJtSPHwibxgpHGVCn8od mf86qdTe/Db+Iu+PoyVRalhKqfB+Rfwizv7AOsJhw1mGZCZrkHn8SdFo9oA5yOIvyhbx LhiJK17Svlr6e5qmz2EweFfQ2OyfH8Ra9dZs1/kx8c81Y/D6MBoqVR7ZQHszOVfsMuWf vM19m8/bKnooYZebnqBIjAtGdfiLe+A6SEi4jGsTIFuU72KSjIHGorP9dU2yY5JrpMbp HqfgYkSWcXPvtBSn73i/ZTdIKjnvksSJThhLjv00M3tRlOoFdT61/32VU6gWsR2Ica3D iArQ== X-Gm-Message-State: APf1xPDe1YK8fmtzQJKA+DXV9QWCLWIBYsSF04ZSPjiR2gHHrbGw3POd j64dTk2RICJCe/H7KkzTsyw= X-Google-Smtp-Source: AH8x224eliqhwx+VIaZ1HTgPRWyJrLkzTnfyFIBSZW2LggpmHxrxbRIUbAkXrZca+KP5f88JBNk/rQ== X-Received: by 10.80.162.229 with SMTP id 92mr7757854edm.26.1518986897137; Sun, 18 Feb 2018 12:48:17 -0800 (PST) Received: from erosca.home ([2a02:8108:91c0:4bcc:98e2:b49f:4e58:283e]) by smtp.gmail.com with ESMTPSA id l9sm3786381edi.96.2018.02.18.12.48.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 18 Feb 2018 12:48:16 -0800 (PST) From: Eugeniu Rosca X-Google-Original-From: Eugeniu Rosca To: Masahiro Yamada , Ulf Magnusson , Petr Vorel , Nicolas Pitre , Randy Dunlap , Paul Bolle Cc: Eugeniu Rosca , Eugeniu Rosca , linux-kbuild@vger.kernel.org Subject: [PATCH v4 2/3] kconfig: Prepare for printing reverse dependencies in groups Date: Sun, 18 Feb 2018 21:47:14 +0100 Message-Id: <7b2504452d3c7abb2090df45147fd43c825c14cc.1518985888.git.erosca@de.adit-jv.com> X-Mailer: git-send-email 2.16.1 In-Reply-To: References: In-Reply-To: References: Sender: linux-kbuild-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Eugeniu Rosca Currently, reverse dependencies are printed like [1]. Prepare the ground for printing them like [2]. No functional change is intended in this patch. [1] Current pattern for printing reverse dependencies: Selected by: - EXPR_A_Y /* evaluates to =y */ - EXPR_B_N /* evaluates to =n */ - EXPR_C_Y /* evaluates to =y */ - EXPR_D_M /* evaluates to =m */ - EXPR_E_N /* evaluates to =n */ [2] Upcoming pattern for printing reverse dependencies: Selected by [y]: - EXPR_A_Y - EXPR_C_Y Selected by [m]: - EXPR_D_M Selected by [n]: - EXPR_B_N - EXPR_E_N Suggested-by: Ulf Magnusson Signed-off-by: Eugeniu Rosca Reviewed-by: Ulf Magnusson --- scripts/kconfig/expr.c | 34 +++++++++++++++++++++++----------- scripts/kconfig/expr.h | 7 ++++++- scripts/kconfig/menu.c | 4 ++-- 3 files changed, 31 insertions(+), 14 deletions(-) diff --git a/scripts/kconfig/expr.c b/scripts/kconfig/expr.c index b89baed7f15c..66b435bca80c 100644 --- a/scripts/kconfig/expr.c +++ b/scripts/kconfig/expr.c @@ -1189,7 +1189,12 @@ expr_print_newline(struct expr *e, expr_print(e, fn, data, prevtoken); } -static void __expr_print(struct expr *e, void (*fn)(void *, struct symbol *, const char *), void *data, int prevtoken, bool revdep) +static void +__expr_print(struct expr *e, + void (*fn)(void *, struct symbol *, const char *), + void *data, + int prevtoken, + enum print_type type) { if (!e) { fn(data, NULL, "y"); @@ -1201,10 +1206,14 @@ static void __expr_print(struct expr *e, void (*fn)(void *, struct symbol *, con switch (e->type) { case E_SYMBOL: if (e->left.sym->name) - if (!revdep) + switch (type) { + case PRINT_NORMAL: fn(data, e->left.sym, e->left.sym->name); - else + break; + case PRINT_REVDEP_ALL: expr_print_newline(e, fn, data, E_OR); + break; + } else fn(data, NULL, ""); break; @@ -1247,18 +1256,21 @@ static void __expr_print(struct expr *e, void (*fn)(void *, struct symbol *, con fn(data, e->right.sym, e->right.sym->name); break; case E_OR: - __expr_print(e->left.expr, fn, data, E_OR, revdep); - if (!revdep) + __expr_print(e->left.expr, fn, data, E_OR, type); + if (type == PRINT_NORMAL) fn(data, NULL, " || "); - __expr_print(e->right.expr, fn, data, E_OR, revdep); + __expr_print(e->right.expr, fn, data, E_OR, type); break; case E_AND: - if (!revdep) { + switch (type) { + case PRINT_NORMAL: expr_print(e->left.expr, fn, data, E_AND); fn(data, NULL, " && "); expr_print(e->right.expr, fn, data, E_AND); - } else { + break; + case PRINT_REVDEP_ALL: expr_print_newline(e, fn, data, E_OR); + break; } break; case E_LIST: @@ -1289,7 +1301,7 @@ static void __expr_print(struct expr *e, void (*fn)(void *, struct symbol *, con void expr_print(struct expr *e, void (*fn)(void *, struct symbol *, const char *), void *data, int prevtoken) { - __expr_print(e, fn, data, prevtoken, false); + __expr_print(e, fn, data, prevtoken, PRINT_NORMAL); } static void expr_print_file_helper(void *data, struct symbol *sym, const char *str) @@ -1342,7 +1354,7 @@ void expr_gstr_print(struct expr *e, struct gstr *gs) * line with a minus. This makes expressions much easier to read. * Suitable for reverse dependency expressions. */ -void expr_gstr_print_revdep(struct expr *e, struct gstr *gs) +void expr_gstr_print_revdep(struct expr *e, struct gstr *gs, enum print_type t) { - __expr_print(e, expr_print_gstr_helper, gs, E_NONE, true); + __expr_print(e, expr_print_gstr_helper, gs, E_NONE, t); } diff --git a/scripts/kconfig/expr.h b/scripts/kconfig/expr.h index c16e82e302a2..21cb67c15091 100644 --- a/scripts/kconfig/expr.h +++ b/scripts/kconfig/expr.h @@ -34,6 +34,11 @@ enum expr_type { E_LIST, E_SYMBOL, E_RANGE }; +enum print_type { + PRINT_NORMAL, + PRINT_REVDEP_ALL, +}; + union expr_data { struct expr *expr; struct symbol *sym; @@ -310,7 +315,7 @@ 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); +void expr_gstr_print_revdep(struct expr *e, struct gstr *gs, enum print_type t); static inline int expr_is_yes(struct expr *e) { diff --git a/scripts/kconfig/menu.c b/scripts/kconfig/menu.c index 99222855544c..5b8edba105f2 100644 --- a/scripts/kconfig/menu.c +++ b/scripts/kconfig/menu.c @@ -828,14 +828,14 @@ 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_revdep(sym->rev_dep.expr, r); + expr_gstr_print_revdep(sym->rev_dep.expr, r, PRINT_REVDEP_ALL); str_append(r, "\n"); } get_symbol_props_str(r, sym, P_IMPLY, _(" Implies: ")); if (sym->implied.expr) { str_append(r, _(" Implied by: ")); - expr_gstr_print_revdep(sym->implied.expr, r); + expr_gstr_print_revdep(sym->implied.expr, r, PRINT_REVDEP_ALL); str_append(r, "\n"); }