From patchwork Sun Mar 29 11:10:27 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 2065 Return-Path: X-Original-To: u-boot-concept@u-boot.org Delivered-To: u-boot-concept@u-boot.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1774782702; bh=iNLWLqKRD/EsCREXDCnA+umKKqH6pmajH8mbi3sXePI=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=llEnAsh6Hg1IKIEoiXg81kFdVYEU/8m7tppeJ7kgbNZviNh0C8CEM/BMs4ZzKtTjJ TbeiFnFcCpoxw7i32ABN3DePP5tRVDMYtQt/So1ZsBHh1TzpaU6psOwPZMO/Q0s58i dB+MWC9OBBlyigxFP2zMZLWJ3kzKzGWokJfbK2QmOBJODYGwSeN/pEUeytjpWX2xU8 etjELJtCCvUvXj8QgK37MemuOxi6h05NbPpU36r45sReVO73bQOFQI4J7MfRjI3bim t48j+HJehOn3KwanWBnKZyKDpDP7ggMESLyHbXChjzfcJ2UZJk91ldhnYqlpbjSoBN 5SSe+2j3IeP0g== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id D5E2C6A2BE for ; Sun, 29 Mar 2026 05:11:42 -0600 (MDT) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10024) with ESMTP id EnKwTIMKl_Iq for ; Sun, 29 Mar 2026 05:11:42 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1774782702; bh=iNLWLqKRD/EsCREXDCnA+umKKqH6pmajH8mbi3sXePI=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=llEnAsh6Hg1IKIEoiXg81kFdVYEU/8m7tppeJ7kgbNZviNh0C8CEM/BMs4ZzKtTjJ TbeiFnFcCpoxw7i32ABN3DePP5tRVDMYtQt/So1ZsBHh1TzpaU6psOwPZMO/Q0s58i dB+MWC9OBBlyigxFP2zMZLWJ3kzKzGWokJfbK2QmOBJODYGwSeN/pEUeytjpWX2xU8 etjELJtCCvUvXj8QgK37MemuOxi6h05NbPpU36r45sReVO73bQOFQI4J7MfRjI3bim t48j+HJehOn3KwanWBnKZyKDpDP7ggMESLyHbXChjzfcJ2UZJk91ldhnYqlpbjSoBN 5SSe+2j3IeP0g== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id C43116A2BF for ; Sun, 29 Mar 2026 05:11:42 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1774782700; bh=CKSPjZMX+KEVUje9nzFcSFP2ZCQr9U3Dqvl49OawdhU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HpjsOsGTRoykmWViFgRkZOBTUk+4aGxNbNSI1YvCJW1m6EUZONKvQ4oYNkKn/wDZk n4jCivyNlCL44LX1pAkMcdRJdJKDO1EPrcbemHyA/hKuWrVGbGk1tiRNUDNmmyKcCJ NHxAwUFHbRLWqhTM/1apPKE4gl8CHaSEpsjt/JgZd/sA2bQ2hrURLo5Ss9qlPMNtOf PRx8cTVU+okrIyEQmGta023s0pAuS+E/kewEigSFVicorgqe6CPXPzvGGRcQO1MqsH 7qu/uJowjVsWnvy9c8fJftyEg3dMd9XpSZulmFN65VBbgmNuWJMIm4L8whiVXbeujX EvAEcjFZY5FtQ== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id ACAD76A2BE; Sun, 29 Mar 2026 05:11:40 -0600 (MDT) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10026) with ESMTP id YQKdytCOlW_H; Sun, 29 Mar 2026 05:11:40 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1774782694; bh=xHIJVjaZIN7Uv03Xdv4Xi6Xo2VWNysJbXl7NLRY4GDQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=iDeombw0t1gyaqbOquPZxe1/qJ8klqzeUfvCyKNfAiJBwBuG3KRMopoGcH+hl0d+Z wCZGXyt6FFznKQmSWn6pqBzhbufE8M9XGbowfXWrrj2/LgQEBSVal0wxVZm6LvrrhW mviHx8PFmpHiDtyq95mf5nN0FcPS++/tUhtYb6G4VPoX8Ka2EqfMlv+HfsWm0G7GCs epRe/1CJ9KkU/R7HaHk8lmZDqBzhQETeA3B6cgtLdOsdBJxMIJvxrzBVxGF3E92z3K EG9ExWTDmQoWILO3ppknJ6VLK4dV+Ehi+NUmjkkwza4itpNFyT6ZRqYVL7s9MQq1GB xrB47s4u9QfDw== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 5B8D26A2BC; Sun, 29 Mar 2026 05:11:34 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Sun, 29 Mar 2026 05:10:27 -0600 Message-ID: <20260329111037.1352652-3-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260329111037.1352652-1-sjg@u-boot.org> References: <20260329111037.1352652-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: CVR5YH3HNXHGMKTWYGNWWF7A32CS3RNR X-Message-ID-Hash: CVR5YH3HNXHGMKTWYGNWWF7A32CS3RNR X-MailFrom: sjg@u-boot.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Simon Glass X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 2/7] qconfig: Auto-rebuild stale database for -f queries List-Id: Discussion and patches related to U-Boot Concept Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Simon Glass The -f (find) option calls read_database() directly, which crashes if the database does not exist and silently returns stale data if Kconfig or defconfig files have changed since the last build. Add a db_is_current() check that compares the database timestamp against all Kconfig and defconfig files, similar to output_is_new() in buildman/boards.py. Use this in ensure_database() so that both -f and buildman's callers get automatic rebuilds when the database is stale. Wire do_find_config() through ensure_database() instead of read_database() so that -f benefits from this. Signed-off-by: Simon Glass --- tools/qconfig.py | 45 +++++++++++++++++++++++++++++++++++++-------- 1 file changed, 37 insertions(+), 8 deletions(-) diff --git a/tools/qconfig.py b/tools/qconfig.py index 4e06bfec88b..1e1f74a0c85 100755 --- a/tools/qconfig.py +++ b/tools/qconfig.py @@ -1289,9 +1289,11 @@ def find_config(dbase, config_list): return result -def do_find_config(config_list, list_format): +def do_find_config(config_list, list_format, jobs): """Find boards with a given combination of CONFIGs + Rebuilds the database automatically if it is missing or stale. + Args: config_list (list of str): List of CONFIG options to check (each a regex consisting of a config option, with or without a CONFIG_ prefix. If @@ -1299,11 +1301,12 @@ def do_find_config(config_list, list_format): otherwise it must be true) list_format (bool): True to write in 'list' format, one board name per line + jobs (int): Number of threads to use if the database needs rebuilding Returns: int: exit code (0 for success) """ - dbase = read_database() + dbase = ensure_database(jobs) out = find_config(dbase, config_list) if not list_format: print(f'{len(out)} matches') @@ -1840,11 +1843,37 @@ def do_tests(): return 0 +def db_is_current(): + """Check if the CONFIG database is up to date + + Returns: + bool: True if the database exists and is newer than all Kconfig and + defconfig files + """ + if not os.path.exists(CONFIG_DATABASE): + return False + + db_time = os.path.getctime(CONFIG_DATABASE) + + for dirpath, _, filenames in os.walk('configs'): + for fname in fnmatch.filter(filenames, '*_defconfig'): + if db_time < os.path.getctime(os.path.join(dirpath, fname)): + return False + + for dirpath, _, filenames in os.walk('.'): + for fname in filenames: + if fname.startswith('Kconfig'): + if db_time < os.path.getctime(os.path.join(dirpath, fname)): + return False + + return True + + def ensure_database(threads): - """Return a qconfig database so that Kconfig options can be queried + """Return a qconfig database, rebuilding it if stale or missing - If a database exists, it is assumed to be up-to-date. If not, one is built, - which can take a few minutes. + Checks whether the database is newer than all Kconfig and defconfig files. + If not, it is rebuilt automatically. Args: threads (int): Number of threads to use when processing @@ -1862,8 +1891,8 @@ def ensure_database(threads): key: CONFIG option value: set of boards using that option """ - if not os.path.exists(CONFIG_DATABASE): - print('Building qconfig.db database') + if not db_is_current(): + print('Building qconfig.db database...') args = Namespace(build_db=True, verbose=False, force_sync=False, dry_run=False, exit_on_error=False, jobs=threads, git_ref=None, defconfigs=None, defconfiglist=None, @@ -1893,7 +1922,7 @@ def main(): sys.exit(1) return 0 if args.find: - return do_find_config(args.configs, args.list) + return do_find_config(args.configs, args.list, args.jobs) if args.build_db: config_db, progress = do_build_db(args)