From: Simon Glass <sjg@chromium.org>
Date: Wed, 19 Jul 2023 23:48:20 +0000 (-0600)
Subject: buildman: Refactor target handling in Boards.scan()
X-Git-Tag: v2025.01-rc5-pxa1908~924^2~71
X-Git-Url: http://git.dujemihanovic.xyz/%22http:/kyber.dk/phpMyBuilder/static/%7B%7B?a=commitdiff_plain;h=f99f34b14b7c48360452a0bcca395e0fc7a01b2b;p=u-boot.git

buildman: Refactor target handling in Boards.scan()

Move the assert to the top of the function and provide an explicit
variables for the target name and base name.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

diff --git a/tools/buildman/boards.py b/tools/buildman/boards.py
index 122fe7090b..2d39326300 100644
--- a/tools/buildman/boards.py
+++ b/tools/buildman/boards.py
@@ -231,6 +231,10 @@ class KconfigScanner:
                 'config': <config_header_name>,
             }
         """
+        leaf = os.path.basename(defconfig)
+        expect_target, match, rear = leaf.partition('_defconfig')
+        assert match and not rear, f'{leaf} : invalid defconfig'
+
         self._conf.load_config(defconfig)
         self._tmpfile = None
 
@@ -245,9 +249,7 @@ class KconfigScanner:
             else:
                 params[key] = '-'
 
-        defconfig = os.path.basename(defconfig)
-        params['target'], match, rear = defconfig.partition('_defconfig')
-        assert match and not rear, f'{defconfig} : invalid defconfig'
+        params['target'] = expect_target
 
         # fix-up for aarch64
         if params['arch'] == 'arm' and params['cpu'] == 'armv8':