From patchwork Sun Oct 8 17:42:18 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Magnusson X-Patchwork-Id: 9991939 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 7731F60230 for ; Sun, 8 Oct 2017 17:42:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 52D39285A4 for ; Sun, 8 Oct 2017 17:42:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 34BDF2862B; Sun, 8 Oct 2017 17:42:40 +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 C4AAD285A4 for ; Sun, 8 Oct 2017 17:42:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751428AbdJHRmi (ORCPT ); Sun, 8 Oct 2017 13:42:38 -0400 Received: from mail-lf0-f66.google.com ([209.85.215.66]:57319 "EHLO mail-lf0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751228AbdJHRmh (ORCPT ); Sun, 8 Oct 2017 13:42:37 -0400 Received: by mail-lf0-f66.google.com with SMTP id 90so16877889lfs.13; Sun, 08 Oct 2017 10:42:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=jy+5k+EnAlC/NrBwEMm6JFgr4J9aIiQHOBPMcyTtUnI=; b=osuw3eOzujQn91EhQ7PejPL6JQQofbm4S9GC6yDLRr9+E+Ex3R080V2eK3xAtb9Z4a Lxjlzujnj1ZtW1QEXrFx5KQOCpLbZ6F5BoV8FiHEiDSfkVY4/odddxlwfddek+PxrFOx ukzwdgZfo7AvmucjnrI3FNqf7iBEJ+yegWZaJjNlCnUriBcvL3fkwiy/OJOMdlThDEYL WSGxoiZgSAMmxwukFIU/Bi/A1Pfg9Ranl45/uYqpnXUEgdEc6pKXpqDV+C9tzE1xuINw 434X0zwfYLabgM5Ra7tXuV9/MI5j1TSnFEgq3U80e3UVhlXO2flJvZjbQfLKSCiVOdf2 Keqw== 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; bh=jy+5k+EnAlC/NrBwEMm6JFgr4J9aIiQHOBPMcyTtUnI=; b=rFSGzaWHlJ/Jiq/xpoVBFozTZUZG3XTTVkisZ25XbWkRaKkpBAWCqVqGV4hONRRl63 Tu4vpmalGqgwHVgcjmL6EAC2ulRj9Oy97hCU2ceJgi1Mq4LLuScOoKycYVeFwNjwvA/f fmnVeAwHM1PBP6q8ULzwGkN2ITKsmbjW1Rr3WvuW64dz3quh1Da6rSKBDk4dtrtmCRpc S1/r42uAWEwdGeBk6YHT52VQkUiOywjcQmlTmiTH/NSxUx0BENJgKgOq3RR0XwhgrKvW 5LmXO6ubfW7xlpybIh833n8SUoLDH/xn9ncJ5f0F1aT8UTGsqk95+wXnQeLOoSqOmF/A dKHg== X-Gm-Message-State: AMCzsaWRC63t9f0CBGoRowVVnAxEYNTkkF5A3fUSoriBXIvMY1FW+oV8 cceKkvzqnrZzd9Mv71xk+/s= X-Google-Smtp-Source: AOwi7QBUliqNni2PHj6vG4Ewqb3059BYlsWfvtY95Turr/p3NzSimxi5eP/h7vznrGZ6z3AtlOXQig== X-Received: by 10.25.168.78 with SMTP id r75mr1492435lfe.65.1507484555953; Sun, 08 Oct 2017 10:42:35 -0700 (PDT) Received: from huvuddator.lan (ua-213-112-0-22.cust.bredbandsbolaget.se. [213.112.0.22]) by smtp.gmail.com with ESMTPSA id b10sm1495209lje.15.2017.10.08.10.42.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 08 Oct 2017 10:42:35 -0700 (PDT) From: Ulf Magnusson To: yann.morin.1998@free.fr, linux-kbuild@vger.kernel.org Cc: sam@ravnborg.org, zippel@linux-m68k.org, nicolas.pitre@linaro.org, michal.lkml@markovi.net, dirk@gouders.net, yamada.masahiro@socionext.com, lacombar@gmail.com, JBeulich@suse.com, linux-kernel@vger.kernel.org, Ulf Magnusson Subject: [PATCH] kconfig: Document automatic submenu creation code Date: Sun, 8 Oct 2017 19:42:18 +0200 Message-Id: <1507484538-24051-1-git-send-email-ulfalizer@gmail.com> X-Mailer: git-send-email 2.7.4 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 It's tricky to figure out what it does (and how) without staring at the code for a long time. Document it to make it more transparent. No functional changes. Only comments added. Signed-off-by: Ulf Magnusson --- scripts/kconfig/menu.c | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/scripts/kconfig/menu.c b/scripts/kconfig/menu.c index e935793..d5fa572 100644 --- a/scripts/kconfig/menu.c +++ b/scripts/kconfig/menu.c @@ -347,25 +347,63 @@ void menu_finalize(struct menu *parent) for (menu = parent->list; menu; menu = menu->next) menu_finalize(menu); } else if (sym) { + /* + * Automatic submenu creation. If sym, A, B, C, ..., are + * consecutive symbols and A, B, C, ... all depend on sym, the + * following menu structure will be created: + * + * sym + * +-A + * +-B + * +-C + * ... + * + * This also works recursively, giving the following structure + * if B depends on A: + * + * sym + * +-A + * | +-B + * +-C + * ... + */ + basedep = parent->prompt ? parent->prompt->visible.expr : NULL; basedep = expr_trans_compare(basedep, E_UNEQUAL, &symbol_no); basedep = expr_eliminate_dups(expr_transform(basedep)); + + /* Examine consecutive elements after sym */ last_menu = NULL; for (menu = parent->next; menu; menu = menu->next) { dep = menu->prompt ? menu->prompt->visible.expr : menu->dep; if (!expr_contains_symbol(dep, sym)) + /* No dependency, quit */ break; if (expr_depends_symbol(dep, sym)) + /* Absolute dependency, put in submenu */ goto next; + + /* + * Also consider it a dependency on sym if our + * dependencies contain sym and are a "superset" of + * sym's dependencies, e.g. '(sym || Q) && R' when sym + * depends on R. + * + * Note that 'R' might be from an enclosing menu or if, + * making this a more common case than it might seem. + */ + dep = expr_trans_compare(dep, E_UNEQUAL, &symbol_no); dep = expr_eliminate_dups(expr_transform(dep)); dep2 = expr_copy(basedep); expr_eliminate_eq(&dep, &dep2); expr_free(dep); if (!expr_is_yes(dep2)) { + /* Not superset, quit */ expr_free(dep2); break; } + /* Superset, put in submenu */ expr_free(dep2); next: menu_finalize(menu);