From patchwork Sat Feb 17 02:05:22 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eugeniu Rosca X-Patchwork-Id: 10225933 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 7D047601D4 for ; Sat, 17 Feb 2018 02:08:15 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6A063289A0 for ; Sat, 17 Feb 2018 02:08:15 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5D6B528A5F; Sat, 17 Feb 2018 02:08:15 +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 CD5FC289B2 for ; Sat, 17 Feb 2018 02:08:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750989AbeBQCIO (ORCPT ); Fri, 16 Feb 2018 21:08:14 -0500 Received: from mail-wm0-f68.google.com ([74.125.82.68]:55344 "EHLO mail-wm0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750948AbeBQCIN (ORCPT ); Fri, 16 Feb 2018 21:08:13 -0500 Received: by mail-wm0-f68.google.com with SMTP id h74so6125610wme.5 for ; Fri, 16 Feb 2018 18:08:13 -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=RM/ncq/dW6wQFrkpfo9VSGULC43t0liZmNHLwHs9wCo=; b=u4oS6GC8+CpgS0cFIfaIDQZRnwcmDNXzSyl+MdvO/dAWi3RYiCM3LFbWWB3evS3OAN WiuLd659eBXyFS+wVhoWKKuUdje5PI90w4HWp1ktceRIpljtq7D2yVuW1FBIQURBDK8h Ajx9vmsxTB9Ma+6KWykzhucl16I7th6wU+jQEReHTQAfBe1HxTwb/YxNlaMtqhHRJpzH aOe+IgmpPIT/DzgmEx0KwDkFX7jplJfXDNe8R5zw0KQK5U6TZedm0QzCYQopNCByE8JB LggqFHBVkVXf5CxNpCeCI9EiBIj2RNG4RUVDLG1PCp9BQkt5sZXySkvJprPeksCjp191 prOw== 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=RM/ncq/dW6wQFrkpfo9VSGULC43t0liZmNHLwHs9wCo=; b=ozO9PkuxgLk2YIEIgmN9JrOOihou6gjV8VBSlztFhJC15yTZan4qAvYCHnYpfNcTIh uuZ4UtxFFXqWJNMNZyVWZvxV5cLQ0XkudInpE4s2NqcsHxKRC3WATf9VDM3Oj/EIE+o2 c+qSfHGIIphmidIULTeKspf7jUxZMWs39NqX1ZscdnjgSulo91IxsHmi2fVafcFiRVbA 6bJSeHSWhTMdzfKNn30x+QLLGPcaSBGoz7fLMKNX+VqtQxc4Nt2NU7kfUF6RdgTmoEtu 7bUWKXlEDUezVwRX9A2x5S6J+dbciHz1XbB/9EJUue9EnN0xY27Npoe0J9IW4YC6eSyi 7H5A== X-Gm-Message-State: APf1xPB/ENAUBV8S9SAxrk6voJ+BmmUVI9fnPShZjnQWiP4N1qMBa5dg 0Rl8f1IPs8eh+ipuKTxbIO4= X-Google-Smtp-Source: AH8x227uQCsDOZDjD1wfrgpjaKkk6M/1YTQVcd3iI0i0FWqStxRzGjm0ImsnvMgB4wA07Dy8dtwZPQ== X-Received: by 10.80.184.134 with SMTP id l6mr5035342ede.250.1518833292618; Fri, 16 Feb 2018 18:08:12 -0800 (PST) Received: from erosca.home (ip1f12fa85.dynamic.kabel-deutschland.de. [31.18.250.133]) by smtp.gmail.com with ESMTPSA id l9sm538791edi.96.2018.02.16.18.08.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 16 Feb 2018 18:08:11 -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 v3 2/3] kconfig: Prepare for printing reverse dependencies in groups Date: Sat, 17 Feb 2018 03:05:22 +0100 Message-Id: <8414488e9b702af60d9f6fd3488e66d18523e68c.1518826148.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 | 38 +++++++++++++++++++++++++++----------- scripts/kconfig/expr.h | 7 ++++++- scripts/kconfig/menu.c | 4 ++-- 3 files changed, 35 insertions(+), 14 deletions(-) diff --git a/scripts/kconfig/expr.c b/scripts/kconfig/expr.c index b89baed7f15c..c610cb14284f 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,16 @@ 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; + default: + break; + } else fn(data, NULL, ""); break; @@ -1247,18 +1258,23 @@ 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; + default: + break; } break; case E_LIST: @@ -1289,7 +1305,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 +1358,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"); }