From patchwork Sun Feb 12 23:15:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1741233 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=ISFunDGL; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4PFNyz392Hz23r9 for ; Mon, 13 Feb 2023 10:31:39 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 32A19859EC; Mon, 13 Feb 2023 00:25:13 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="ISFunDGL"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 9B1C8856CB; Mon, 13 Feb 2023 00:18:40 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-io1-xd2a.google.com (mail-io1-xd2a.google.com [IPv6:2607:f8b0:4864:20::d2a]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id A76F58585F for ; Mon, 13 Feb 2023 00:18:23 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-io1-xd2a.google.com with SMTP id y7so3945784iob.6 for ; Sun, 12 Feb 2023 15:18:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=NYheKbTKcef3/1NsJZFMt+LvTd26VUDiO3s/OPa8HOQ=; b=ISFunDGLjZ7w/lzxwUe+DMmW93kjWChGHQxkuUUVbRRRsIV4YPVVHX4iematU4o1QQ rlu1j0vhG+veiMdjO+2YEVueykdEu9hOWVaNuD+P7ESQC8xNSRm/VGzKzI5v5FK4i9D/ AWxOMDrdtkEHRBllM5OiwnrYVGVM5KcpZxFmY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=NYheKbTKcef3/1NsJZFMt+LvTd26VUDiO3s/OPa8HOQ=; b=a60GOa0E9pRAL1owTwotdgvTRvsDVWJ/YIZv2W0sBzcI16DCsM9+sFwBqKsR4e+j2J yuRkA4z9uVDcOR+RHI0krzWbQ6XH7aV2qntwFwrGRZl13yCmVa9eD5Ty0rA3euBU0xTZ 4p3emGLfxyOKVzRm6NGfVFCz18UV2jjwGSbjCh2NgzUJr+K+9Kz2plpjUC2psUg5HYsz M5H76x8koWefCECV6839gQfO1f4xKv0Eb22qzNYs8qf5KchvoTWUZ6wIZDqr++5l8/Ef MaGRB8r3szPKSpRyQiQdGVkJM3E7Xpwp4uHQNl9Tenxq0g3Azn6JDzhtOI6B7my/38rW AVhg== X-Gm-Message-State: AO0yUKUywJdCnFiL4Lr7DrPOK8m+MSbakuA6UP/CggPOLRYtnjuUGn8S hw6mrexj06bTOXD8WTvHYxjD8fXlIDj+rSOA X-Google-Smtp-Source: AK7set8jhcVDoEhe21giKk1RaatTgWZGvakevWJd8SzMUuJFZTtf6nFAhpOH4sVIXSNEa7RYV13WkA== X-Received: by 2002:a5d:8586:0:b0:71a:4874:3864 with SMTP id f6-20020a5d8586000000b0071a48743864mr18932424ioj.6.1676243862784; Sun, 12 Feb 2023 15:17:42 -0800 (PST) Received: from sjg1.roam.corp.google.com (c-73-14-173-85.hsd1.co.comcast.net. [73.14.173.85]) by smtp.gmail.com with ESMTPSA id n16-20020a6b8b10000000b006dfbd35e995sm3627849iod.21.2023.02.12.15.17.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 12 Feb 2023 15:17:42 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: Tom Rini , Simon Glass Subject: [PATCH v3 36/95] moveconfig: Various minor improvements Date: Sun, 12 Feb 2023 16:15:39 -0700 Message-Id: <20230212231638.1134219-37-sjg@chromium.org> X-Mailer: git-send-email 2.39.1.581.gbfd45094c4-goog In-Reply-To: <20230212231638.1134219-1-sjg@chromium.org> References: <20230212231638.1134219-1-sjg@chromium.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 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" X-Virus-Scanned: clamav-milter 0.103.6 at phobos.denx.de X-Virus-Status: Clean It turns out that the conf_noproper file is not neeed, since if an option does not appear in U-Boot proper we can just omit it from the autoconf for that build. Drop it. Also add more control over what is output from the tool. Add this in here. It should be added to the previous series (splb). Signed-off-by: Simon Glass --- (no changes since v1) tools/moveconfig.py | 91 +++++++++++++++++++++------------------------ 1 file changed, 43 insertions(+), 48 deletions(-) diff --git a/tools/moveconfig.py b/tools/moveconfig.py index b3ac2672737..ec2afa92e46 100755 --- a/tools/moveconfig.py +++ b/tools/moveconfig.py @@ -1833,13 +1833,20 @@ def scan_src_files(fname_dict, all_uses, fname_uses): MODE_NORMAL, MODE_SPL, MODE_PROPER = range(3) -def do_scan_source(path, do_update, show_conflicts, do_commit): +def do_scan_source(path, do_update, do_update_source, show_conflicts, + do_commit): """Scan the source tree for Kconfig inconsistencies Args: path (str): Path to source tree - do_update (bool): True to write to scripts/kconf_... files - show_conflicts (bool): True to show conflicts + do_update (bool): True to write to scripts/conf_nospl file + do_update_source (bool): True to update source to remove invalid use of + CONFIG_IS_ENABLED() + show_conflicts (bool): True to show conflicts between the source code + and the Kconfig (such as missing options, or options which imply an + SPL option that does not exist) + do_commit (bool): Create commits to remove use of SPL_TPL_ and + CONFIG_IS_ENABLED macros when there is no SPL symbol. """ def is_not_proper(name): for prefix in SPL_PREFIXES: @@ -1977,9 +1984,7 @@ def do_scan_source(path, do_update, show_conflicts, do_commit): dirname, leaf = os.path.split(fname) root, ext = os.path.splitext(leaf) - #if dirname != '' or root != 'Makefile': - #continue - if (dirname.startswith('test') or + if (dirname.startswith('test/') or dirname.startswith('lib/efi_selftest')): # Ignore test code since it is mostly only for sandbox pass @@ -2011,38 +2016,25 @@ def do_scan_source(path, do_update, show_conflicts, do_commit): finish_file(last_fname, rest_list) return mk_dict, src_dict - def check_mk_missing(all_uses, spl_not_found, proper_not_found): + def check_missing(all_uses, spl_not_found, proper_not_found, + show_conflicts): # Make sure we know about all the options in Makefiles - print('\nCONFIG options present in Makefiles but not Kconfig:') not_found = check_not_found(all_uses, MODE_NORMAL) - show_uses(not_found) + if show_conflicts: + print('\nCONFIG options present in source but not Kconfig:') + show_uses(not_found) - print('\nCONFIG options present in Makefiles but not Kconfig (SPL):') not_found = check_not_found(all_uses, MODE_SPL) - show_uses(not_found) spl_not_found |= set(is_not_proper(key) or key for key in not_found.keys()) + if show_conflicts: + print('\nCONFIG options present in source but not Kconfig (SPL):') + show_uses(not_found) - print('\nCONFIG options used as Proper in Makefiles but without a non-SPL_ variant:') not_found = check_not_found(all_uses, MODE_PROPER) - show_uses(not_found) - proper_not_found |= set(key for key in not_found.keys()) - - def check_src_missing(all_uses, spl_not_found, proper_not_found): - # Make sure we know about all the options in source files - print('\nCONFIG options present in source but not Kconfig:') - not_found = check_not_found(all_uses, MODE_NORMAL) - show_uses(not_found) - - print('\nCONFIG options present in source but not Kconfig (SPL):') - not_found = check_not_found(all_uses, MODE_SPL) - show_uses(not_found) - spl_not_found |= set(is_not_proper(key) or key - for key in not_found.keys()) - - print('\nCONFIG options used as Proper in source but without a non-SPL_ variant:') - not_found = check_not_found(all_uses, MODE_PROPER) - show_uses(not_found) proper_not_found |= set(key for key in not_found.keys()) + if show_conflicts: + print('\nCONFIG options used as Proper in source but without a non-SPL_ variant:') + show_uses(not_found) def show_summary(spl_not_found, proper_not_found): print('\nCONFIG options used as SPL but without an SPL_ variant:') @@ -2053,19 +2045,24 @@ def do_scan_source(path, do_update, show_conflicts, do_commit): for item in sorted(proper_not_found): print(f' {item}') - def write_update(spl_not_found, proper_not_found): - with open(os.path.join(path, 'scripts', 'conf_nospl'), + def write_update(spl_not_found): + with open(os.path.join(path, 'scripts', 'conf_nospl'), 'w', encoding='utf-8') as out: - print('# These options should not be enabled in SPL builds\n', + print('''# Options which are never enabled in SPL. + +Generally, options which have no SPL_ prefix (e.g. CONFIG_FOO) apply to all +SPL build phases. This allows things like ARCH_ARM to propagate to all builds +without the hassle of generating a separate SPL version fo each phase. But in +some cases this is not wanted. + +This file lists options which don't have an SPL equivalent, but still should not +be enabled in SPL builds. It is necessary since kconfig cannot tell (just by +looking at the Kconfig description) whether it applies to Proper builds only, +or to all builds. +''', file=out) for item in sorted(spl_not_found): print(item, file=out) - with open(os.path.join(path, 'scripts', 'conf_noproper'), 'w', - encoding='utf-8') as out: - print('# These options should not be enabled in Proper builds\n', - file=out) - for item in sorted(proper_not_found): - print(item, file=out) def check_conflict(kconf, all_uses, show): """Check conflicts between uses of CONFIG options in source @@ -2210,7 +2207,7 @@ def do_scan_source(path, do_update, show_conflicts, do_commit): conflicts, cfg_dict = check_conflict(kconf, all_uses, show_conflicts) - if do_update: + if do_update_source: update_source(conflicts) if do_commit: create_commits(cfg_dict) @@ -2218,17 +2215,13 @@ def do_scan_source(path, do_update, show_conflicts, do_commit): # Look for CONFIG options that are not found spl_not_found = set() proper_not_found = set() - check_mk_missing(all_uses, spl_not_found, proper_not_found) - - # Scan the source code - scan_src_files(src_dict, all_uses, fname_uses) - check_src_missing(all_uses, spl_not_found, proper_not_found) + check_missing(all_uses, spl_not_found, proper_not_found, show_conflicts) show_summary(spl_not_found, proper_not_found) # Write out the updated information if do_update: - write_update(spl_not_found, proper_not_found) + write_update(spl_not_found) def main(): try: @@ -2289,6 +2282,8 @@ doc/develop/moveconfig.rst for documentation.''' help="respond 'yes' to any prompts") parser.add_argument('-u', '--update', action='store_true', default=False, help="update scripts/ files (use with --scan-source)") + parser.add_argument('-U', '--update-source', action='store_true', + help="update source code (use with --scan-source)") parser.add_argument('-v', '--verbose', action='store_true', default=False, help='show any build errors as boards are built') parser.add_argument('configs', nargs='*') @@ -2304,8 +2299,8 @@ doc/develop/moveconfig.rst for documentation.''' unittest.main() if args.scan_source: - do_scan_source(os.getcwd(), args.update, args.list_problems, - args.commit) + do_scan_source(os.getcwd(), args.update, args.update_source, + args.list_problems, args.commit) return if not any((len(configs), args.force_sync, args.build_db, args.imply,