From patchwork Mon Dec 13 10:00:42 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ariel Marcovitch X-Patchwork-Id: 12673635 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B2BDEC433FE for ; Mon, 13 Dec 2021 10:28:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239764AbhLMK2V (ORCPT ); Mon, 13 Dec 2021 05:28:21 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37816 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240745AbhLMK0p (ORCPT ); Mon, 13 Dec 2021 05:26:45 -0500 Received: from mail-wr1-x42a.google.com (mail-wr1-x42a.google.com [IPv6:2a00:1450:4864:20::42a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 07E65C08EB3F; Mon, 13 Dec 2021 02:01:00 -0800 (PST) Received: by mail-wr1-x42a.google.com with SMTP id q3so26022621wru.5; Mon, 13 Dec 2021 02:00:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=x9PqIToAjBgk14clYxLRRS2A0PQ+nML9zqgIg86sYx8=; b=ZdiqsrugQIz6eFUGLe60DhEwEcR21/aME5FdWdH8X3uROPwcLRY+W3M8Khs3NTbcQm kwqL0yv7ZViGmGs6QbrM+arTQGCXXP0d70vgp24o9ie0rStun9jE6SO2ZqUirdYMzUp0 iK6m69Lw0D3ErWFfN0EvNP18vvLLBldpc4+YoprDomch+/M/c4RD2tCQnYRYsSQQRnom 4AMpSQejMhFrpjiZcJYo8etF5354unywlBArpZBEmqp9NXZYmlqIDpy1dXeqLVUMGn5a CfS6L6G0KG1nLxsqRUGEHE3VvXGHtdlt8/w6mB9oQO8wDW8yarSP2JjAyi8S0/u6ZXJH rr+A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=x9PqIToAjBgk14clYxLRRS2A0PQ+nML9zqgIg86sYx8=; b=5xGI4Gh3tPzbtJZsCGXJvlQ0fmGSttTWQrgLK57rFl/Q43E+YviAfKeTv1uRV6Mqft rc2gq6t3Xvhiw1WNtUPJuTHQAJ5NWTWcZxZ6/AQlMOSLgQgxTuQDzJolm7uHt989+r9h 7UczLqr0d9+Wac2VL5Fo2RYiRhYlWl4Sh/2Udr0/gL3FulFNhIjw9vMROscpjXXPxAlr uK5gYEn67b8ZZwXdQeKPLkhAJ1Bs9aHqg7iwXVZChoXbx3WsicNNa1poBnJLitrAB2GR VCJHQJGGgtpseh1mQnCUEuCimuhR3ssAHNLpaXcuKt3elKLFp8o7CaOsOAmKGGCdUpH7 XFZw== X-Gm-Message-State: AOAM53267KsNKOiucuLeQgLfqXXl4Oi3jKEvZ2GaYloUA15HwhsuGdtj cqf6qrc6m2MW/Fof3TUL+Zo= X-Google-Smtp-Source: ABdhPJzBACNC9hXGBSdzgJSVqIFLyDoE8W+NZyYoA4+Tj6Y3PdjAmufpXBqXeXF4QUffNgMqb7fCJg== X-Received: by 2002:a05:6000:1085:: with SMTP id y5mr15991168wrw.653.1639389658590; Mon, 13 Dec 2021 02:00:58 -0800 (PST) Received: from localhost.localdomain ([2a00:a040:197:458f:acc5:ce9c:f048:f197]) by smtp.googlemail.com with ESMTPSA id s8sm11826590wra.9.2021.12.13.02.00.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Dec 2021 02:00:58 -0800 (PST) From: Ariel Marcovitch To: masahiroy@kernel.org Cc: linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org, Ariel Marcovitch Subject: [PATCH 1/2] kconfig: Show menuconfigs as menus in the .config file Date: Mon, 13 Dec 2021 12:00:42 +0200 Message-Id: <20211213100043.45645-2-arielmarcovitch@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211213100043.45645-1-arielmarcovitch@gmail.com> References: <20211213100043.45645-1-arielmarcovitch@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org Until now, menuconfigs were considered configs because they had non-zero sym attribute. This meant that instead of having the nice menu comment block in the .config output file, they were merely shown as single configs. For example: ```Kconfig menu "Foo" endmenu menuconfig BAR bool "Bar" config OTHER bool "Other" depends on BAR ``` Will be shown as: ```.config # # Foo # # end of Foo CONFIG_BAR=y CONFIG_OTHER=y ``` Instead of using the sym attribute to decide whether or not to print the menu block comment, check menu->prompt->type explicitly (after checking that menu_is_visible(menu) which means menu->prompt is not none). The only prompt types we actually show as menus are P_MENU and P_COMMENT. At the end of the menu we need to show the end of block only for P_MENU (although P_COMMENT prompts will not get to this flow because they don't have children). Signed-off-by: Ariel Marcovitch --- scripts/kconfig/confdata.c | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/scripts/kconfig/confdata.c b/scripts/kconfig/confdata.c index 42bc56ee238c..9f2c22f46ee0 100644 --- a/scripts/kconfig/confdata.c +++ b/scripts/kconfig/confdata.c @@ -874,16 +874,21 @@ int conf_write(const char *name) menu = rootmenu.list; while (menu) { sym = menu->sym; - if (!sym) { - if (!menu_is_visible(menu)) - goto next; - str = menu_get_prompt(menu); - fprintf(out, "\n" - "#\n" - "# %s\n" - "#\n", str); - need_newline = false; - } else if (!(sym->flags & SYMBOL_CHOICE) && + + if (menu_is_visible(menu)) { + enum prop_type type = menu->prompt->type; + + if (type == P_MENU || type == P_COMMENT) { + str = menu_get_prompt(menu); + fprintf(out, "\n" + "#\n" + "# %s\n" + "#\n", str); + need_newline = false; + } + } + + if (sym && !(sym->flags & SYMBOL_CHOICE) && !(sym->flags & SYMBOL_WRITTEN)) { sym_calc_value(sym); if (!(sym->flags & SYMBOL_WRITE)) @@ -904,7 +909,8 @@ int conf_write(const char *name) if (menu->next) menu = menu->next; else while ((menu = menu->parent)) { - if (!menu->sym && menu_is_visible(menu) && + if (menu_is_visible(menu) && + menu->prompt->type == P_MENU && menu != &rootmenu) { str = menu_get_prompt(menu); fprintf(out, "# end of %s\n", str); From patchwork Mon Dec 13 10:00:43 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ariel Marcovitch X-Patchwork-Id: 12673637 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3213EC4332F for ; Mon, 13 Dec 2021 10:28:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238291AbhLMK2m (ORCPT ); Mon, 13 Dec 2021 05:28:42 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38800 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241590AbhLMK0w (ORCPT ); Mon, 13 Dec 2021 05:26:52 -0500 Received: from mail-wr1-x42a.google.com (mail-wr1-x42a.google.com [IPv6:2a00:1450:4864:20::42a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1924BC08EB4F; Mon, 13 Dec 2021 02:01:07 -0800 (PST) Received: by mail-wr1-x42a.google.com with SMTP id t18so25978727wrg.11; Mon, 13 Dec 2021 02:01:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=WPZA9gRkqDLMYp6+mF0W8zeDD7JXBBR/yD8P8ozoEHs=; b=lTRohng/ek5bUhGyzs9yhqj0AFjXhJZNV2mTG4xQ8QBSnaPGdwxJtRWcsLxu+5bVvK JZy7J9AELWjaRkKNRXbK7sojEG+6eR9KEBC2TWDFPLg/LeOilJKz8jtxJ74sXXZ5EDzZ elPvbe+rHC5cOmE/889pCOjE1Y0vGXPa8PO3AzfZDjryHaZdxaItXtW8bIzxdBC6AIMD Tyi6EHEPUJW1jOebzybSyATejI4EADM9qP4EouQeWxvWg8XcvbbGk736WwfX7cafyLwt JFTBDHNw0rTuVdrPVmYZDxUJGfB3w1sPQete4oBqu4LpmKEvqHgxFlFzf0eRUkBGtvG1 yrNQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=WPZA9gRkqDLMYp6+mF0W8zeDD7JXBBR/yD8P8ozoEHs=; b=eoC2HC3Arr0sPMfOP0tpXy/7NEcxWPwWJ4MGrZDLGdAOFMpflTDgXhisSykolxTpO2 n9LmZKnefby2AQklgJYRrdQtvFoK+U2HFK6fxI34f2AvBFcZXj/BE2Arh6CbdADxxG1N A6WEIAURzJxz9N8lSFHuRCI0svOfX70i/2TieyHnI8uRAFVHo2Ptoejc/gWZ0f/zhrmp XBEnyxbP/xddo0Rx2BGVQ17G62I97pq2nQfxz/Yr7OTNNqDU33e40dSSyhGkbdkUrmGc Opu8CgESxAQnTQCxblkNGbIMXx5TUaauTKx082sfCZYhOzA3DnzxyncKGHZSSfrztWAA 0JVQ== X-Gm-Message-State: AOAM531fc0z/X8i0FXKA3w/GpyeMWnTM3M8SKoJ43/Zvt7UsEf3B18qh XOY5MaxEDxiLthffvZ/UQ2w= X-Google-Smtp-Source: ABdhPJz/4rbWZ7qUzST/4tUrc8MMfWVMlZ0VIrRbqzbkIug1yPPDFy1EZRp/eDGulYe7ee4IYdsJ2g== X-Received: by 2002:adf:bc89:: with SMTP id g9mr30095418wrh.578.1639389665783; Mon, 13 Dec 2021 02:01:05 -0800 (PST) Received: from localhost.localdomain ([2a00:a040:197:458f:acc5:ce9c:f048:f197]) by smtp.googlemail.com with ESMTPSA id s8sm11826590wra.9.2021.12.13.02.01.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Dec 2021 02:01:05 -0800 (PST) From: Ariel Marcovitch To: masahiroy@kernel.org Cc: linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org, Ariel Marcovitch Subject: [PATCH 2/2] kconfig: Make comments look different than menus in .config Date: Mon, 13 Dec 2021 12:00:43 +0200 Message-Id: <20211213100043.45645-3-arielmarcovitch@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211213100043.45645-1-arielmarcovitch@gmail.com> References: <20211213100043.45645-1-arielmarcovitch@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org Currently, the same code that handles menus in the write to .config handles comments as well. That's why comments look exactly like menus in the .config except for the 'end of menu' comments that appear only for menus. This makes sense because sometimes comments are used as sort of submenus. However for the other cases, it looks kinda weird because one might attempt to look for the 'end of menu' for comments as well and be very confused. Make comments look different than menus. For the following: ```kconfig menu "Stuff" config FOO def_bool y comment "Some comment" config BAR def_bool n endmenu ``` The .config will look like this: ``` # # Stuff # CONFIG_FOO=y ### Some comment # CONFIG_BAR is not defined # end of Stuff ``` Signed-off-by: Ariel Marcovitch --- scripts/kconfig/confdata.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/scripts/kconfig/confdata.c b/scripts/kconfig/confdata.c index 9f2c22f46ee0..d3ec1ad67d92 100644 --- a/scripts/kconfig/confdata.c +++ b/scripts/kconfig/confdata.c @@ -880,10 +880,16 @@ int conf_write(const char *name) if (type == P_MENU || type == P_COMMENT) { str = menu_get_prompt(menu); - fprintf(out, "\n" - "#\n" - "# %s\n" - "#\n", str); + + if (type == P_MENU) + fprintf(out, "\n" + "#\n" + "# %s\n" + "#\n", str); + else + fprintf(out, "\n" + "### %s\n", str); + need_newline = false; } }