From patchwork Sat Jan 3 20:32:32 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1253 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=1767472405; bh=BfvLYxFniUJVbYwo8QDyKFGIKi6SSVW7wKvyz7Bm2s4=; 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=RCZfUzUimSPxlkgUXw0TzRoME5lBcgvXX2puV3sQR5jeXKkYevZaZBDDGmMhPBdm5 sOr7/dYLvzVHJiV4i21BgpYyIpg0icQE1SxmY+U+XFHQJks0k7Qp+69DOhLa7omft8 bYl+akP+IO2SWK7AMWId1UFBMQkHOSkPFez/OUglIXWYJfBoKc5dwPZK3paziY+FP0 5V9EQunncs5RYpaxYko4bierIBZLA39fPrv8H0q8N8+KgPH+IsUAjIZXmqkemxGzqp n5Um65vH2bcQpo+0KQM9Otonmp6We4GHYGWRbuVMnT5rrvlhKnKrVi0FONuzjSXZa1 byr0/36eD8aoQ== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 48544690BF for ; Sat, 3 Jan 2026 13:33:25 -0700 (MST) 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 0Bv285-8Qyu7 for ; Sat, 3 Jan 2026 13:33:25 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767472405; bh=BfvLYxFniUJVbYwo8QDyKFGIKi6SSVW7wKvyz7Bm2s4=; 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=RCZfUzUimSPxlkgUXw0TzRoME5lBcgvXX2puV3sQR5jeXKkYevZaZBDDGmMhPBdm5 sOr7/dYLvzVHJiV4i21BgpYyIpg0icQE1SxmY+U+XFHQJks0k7Qp+69DOhLa7omft8 bYl+akP+IO2SWK7AMWId1UFBMQkHOSkPFez/OUglIXWYJfBoKc5dwPZK3paziY+FP0 5V9EQunncs5RYpaxYko4bierIBZLA39fPrv8H0q8N8+KgPH+IsUAjIZXmqkemxGzqp n5Um65vH2bcQpo+0KQM9Otonmp6We4GHYGWRbuVMnT5rrvlhKnKrVi0FONuzjSXZa1 byr0/36eD8aoQ== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 37AA2690BC for ; Sat, 3 Jan 2026 13:33:25 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767472403; bh=uZvOUigdmeY06tVCpb0r+kiMEwaseBPjBlbSsROdiNA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=M3RhSDSXlFVY//TLL+pxrHBBjOPwK9bg+Un4j41RRkbTqIWtHmyuETCiPE4fpJfnl /6BLhuERGhlNry9egctXxmlCVvSWGOoggI+I4K7TmD77nzmb73DQbzdiuqqAh9oHUT ZuAo5KyW48drN1vQUT+43/V8jjIRwvCYZd44sIFLLW5gzOSB3Cal2AVFoS/CEMDf67 CGCapLe063K/eKNqhoyWgD3+ZOAmN/ByvBGbNWz0uyI5ucogInUfKYKqkv8G4PKdWZ jz+oFMy65W2rbR7S1hazpgbQj//zNotwVFBQ/SXkfP04YiIGBQgiOgkz3LySec6rv/ 8+ul3CeB+nOrA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 47E4568F35; Sat, 3 Jan 2026 13:33:23 -0700 (MST) 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 P-zS9sZx4sCB; Sat, 3 Jan 2026 13:33:23 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767472399; bh=jqWz4OtMJ//hvFqPc8yYHXPofjNltgI0VB7SI0o78A4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=T8RYmbAe7bEZyGdq6jQYOahFMEoBT70S6uW/tDUqDAN5qKomr4YmloEC0Nr8NcI8p Q+w2ZUGxXSQDP/KUDQGA770c+mi3ECbys/P4sWq6uPUm4UEhUG88TFHKu77hou3xKa x+vL/J5Dy8lA4+hQtVopIi438EPyH2vnag2oUI/PsFGqDe6ck2aIXtNB+t1ky+Ce0f xm63uhYrtdkeW/3zvQUPyiavZGq5+mJT7WgD75jDv4CrBY9a2/bz5f60oDGZLhWg5u kkgNDbHEMnN1eiPAF1KYaDYZLi4tR9aBwxsBYQ0PNLzvJd56oHyC1k4v/dUgQUDxOr wBoTVnlbHqpjg== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id C637768FC8; Sat, 3 Jan 2026 13:33:18 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Sat, 3 Jan 2026 13:32:32 -0700 Message-ID: <20260103203243.3727493-7-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260103203243.3727493-1-sjg@u-boot.org> References: <20260103203243.3727493-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: PX4ECIA75CUVGWYOLBFUUZX53LPIUDQG X-Message-ID-Hash: PX4ECIA75CUVGWYOLBFUUZX53LPIUDQG 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 , "Claude Opus 4 . 5" X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 06/12] buildman: Extract defconfig loading from scan() into _load_defconfig() 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 Move the logic that handles #include preprocessing and config loading into a separate method to reduce complexity of scan() Co-developed-by: Claude Opus 4.5 Signed-off-by: Simon Glass --- tools/buildman/boards.py | 53 ++++++++++++++++++++++++---------------- 1 file changed, 32 insertions(+), 21 deletions(-) diff --git a/tools/buildman/boards.py b/tools/buildman/boards.py index 1983e4a50d6..e7844f0e5e7 100644 --- a/tools/buildman/boards.py +++ b/tools/buildman/boards.py @@ -222,6 +222,37 @@ class KconfigScanner: if self._tmpfile: try_remove(self._tmpfile) + def _load_defconfig(self, defconfig): + """Load a defconfig file, preprocessing if needed + + If the defconfig contains #include directives, run the C + preprocessor to expand them before loading. + + Args: + defconfig (str): Path to the defconfig file + """ + temp = None + if b'#include' in tools.read_file(defconfig): + cpp = os.getenv('CPP', 'cpp').split() + cmd = cpp + [ + '-nostdinc', '-P', + '-I', self._srctree, + '-undef', + '-x', 'assembler-with-cpp', + defconfig] + stdout = command.output(*cmd, capture_stderr=True) + temp = tempfile.NamedTemporaryFile(prefix='buildman-') + tools.write_file(temp.name, stdout, False) + fname = temp.name + tout.info(f'Processing #include to produce {defconfig}') + else: + fname = defconfig + + self._conf.load_config(fname) + if temp: + del temp + self._tmpfile = None + def scan(self, defconfig, warn_targets): """Load a defconfig file to obtain board parameters. @@ -247,27 +278,7 @@ class KconfigScanner: expect_target, match, rear = leaf.partition('_defconfig') assert match and not rear, f'{leaf} : invalid defconfig' - temp = None - if b'#include' in tools.read_file(defconfig): - cpp = os.getenv('CPP', 'cpp').split() - cmd = cpp + [ - '-nostdinc', '-P', - '-I', self._srctree, - '-undef', - '-x', 'assembler-with-cpp', - defconfig] - stdout = command.output(*cmd, capture_stderr=True) - temp = tempfile.NamedTemporaryFile(prefix='buildman-') - tools.write_file(temp.name, stdout, False) - fname = temp.name - tout.info(f'Processing #include to produce {defconfig}') - else: - fname = defconfig - - self._conf.load_config(fname) - if temp: - del temp - self._tmpfile = None + self._load_defconfig(defconfig) params = {} warnings = []