From patchwork Tue Jan 6 22:03:35 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1320 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=1767737140; bh=+ZrvrIFaP4KnyKeUvlMAhCJrQ52/kv9omunx5tzK90o=; 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=tse7H6kccrBwNMRu3bHFfksVqp04N4+rLXnWiIJ4RbEomFNJFd3EnmL7rG51YKYxd fXQT3XRjmAWps//OZysUXIwz4aL4E2ZwV7KQFu9ATrB3oGrXhggjWAT9rF0rbKxoVq ugcd6Us6snnzgdn9t2bkyoOycYzRwEKXvsLgfMl6qiqvJNM88CJqcu5FXT5Dcfdk+H iQYJ5eN8ASud+lwxN8SqjAcP3bU9oHX0i97XmHO7t2eIm3T8fYzvXkBy78HoM41BTm PAIWLKCXhCjV8w1KQVFzwvcNhue+idlVQycGqlJS0VvNgYpDPF5Sxwq04fktUyFY6U vMRMIaqNrN7jQ== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 8FCD269162 for ; Tue, 6 Jan 2026 15:05:40 -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 TCU57xfNf_17 for ; Tue, 6 Jan 2026 15:05:40 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767737140; bh=+ZrvrIFaP4KnyKeUvlMAhCJrQ52/kv9omunx5tzK90o=; 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=tse7H6kccrBwNMRu3bHFfksVqp04N4+rLXnWiIJ4RbEomFNJFd3EnmL7rG51YKYxd fXQT3XRjmAWps//OZysUXIwz4aL4E2ZwV7KQFu9ATrB3oGrXhggjWAT9rF0rbKxoVq ugcd6Us6snnzgdn9t2bkyoOycYzRwEKXvsLgfMl6qiqvJNM88CJqcu5FXT5Dcfdk+H iQYJ5eN8ASud+lwxN8SqjAcP3bU9oHX0i97XmHO7t2eIm3T8fYzvXkBy78HoM41BTm PAIWLKCXhCjV8w1KQVFzwvcNhue+idlVQycGqlJS0VvNgYpDPF5Sxwq04fktUyFY6U vMRMIaqNrN7jQ== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 7EDCA69146 for ; Tue, 6 Jan 2026 15:05:40 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767737138; bh=d4s5cI7hT71fc7J0cJaDrGz6q9uepPRiKxYtTF4bRmo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fO7M2bopwXc7FiscBAsQDT9CyA3kE2fb8vX00+0X1PYOiHor+dp9aLGChBwmj1fKD /X6JdScjRx7yc1nLT+TPCw+VKVibGk2UcjLKWJydfi2DSf/ERP3c2g3n0cMVNBcMXg MYBDG8lMEqLwPQr0nGBQSGs87g6ZiJDvlEz4Va46QxTZDo0GMNuXlZCZI8/h9ZUtd8 EvLGTHigToAujpjxVXacM4hY0Dl+rnafPk8ZO3HIxjXuyMVoXNraX6+Y+VtED8gDY0 +Iu+28pALjrcSoyyLcpmdDDzIiXNsDK9KWJhLBm4Q7lp4EIbmbRF1QRE4bGBk1Jmqw BOU0JafwQAMwg== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 7BC1869146; Tue, 6 Jan 2026 15:05:38 -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 g_8SSp9FyrtP; Tue, 6 Jan 2026 15:05:38 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767737134; bh=J6Opj+mHnbyrzK/oGPOYIfFSdBtCoW0ntrnbgWsMQn0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=meHmx6PmMyuqeWH9iDm/oTAaIsNj/Cc1PKTWpAhtoRx4DiTjGb10b2d1IkvbSFNWs m+BB003MwL1fmJNsqmrZ73ZLuKCbYb3W+tu2dubIY6MLgRPUZPRSNxRl4NM7ZiSNe9 YUG7Y6+z38fbD6AqKUXq76cw6gFENRfd5z7VuQg+mLMzw6X5doQBc16ddYnuwSdqJk unitIxj03G0x6UNAVsf40nc/pAK0CcphUPZ+szjtQAOaDotWJFrQeKF3sLwu0tqH+V uEs69t/yfr/AwoqSJtDgPbakTZ2rysXtj5EVllrE9Ws2uUKHs1LAMvhazWJu++1b7M tJe54/ulWm9Ew== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id C3388690CB; Tue, 6 Jan 2026 15:05:33 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Tue, 6 Jan 2026 15:03:35 -0700 Message-ID: <20260106220403.2915630-18-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260106220403.2915630-1-sjg@u-boot.org> References: <20260106220403.2915630-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: YXODNEZNL3FNHUNFMYYKWNSNMX6CHGA3 X-Message-ID-Hash: YXODNEZNL3FNHUNFMYYKWNSNMX6CHGA3 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 X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 17/29] buildman: Refactor _calc_size_changes() in builder.py 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 Extract the inner 'for image' loop into _calc_image_size_changes() to improve readability and reduce nesting. Co-developed-by: Claude Signed-off-by: Simon Glass --- tools/buildman/builder.py | 50 ++++++++++++++++++++++++--------------- 1 file changed, 31 insertions(+), 19 deletions(-) diff --git a/tools/buildman/builder.py b/tools/buildman/builder.py index f1fbdc7b888..5c33b737740 100644 --- a/tools/buildman/builder.py +++ b/tools/buildman/builder.py @@ -1241,6 +1241,36 @@ class Builder: outcome.func_sizes[fname]) + @staticmethod + def _calc_image_size_changes(target, sizes, base_sizes): + """Calculate size changes for each image/part + + Args: + target (str): Target board name + sizes (dict): Dict of image sizes, keyed by image name + base_sizes (dict): Dict of base image sizes, keyed by image name + + Returns: + dict: Size changes, e.g.: + {'_target': 'snapper9g45', 'data': 5, 'u-boot-spl:text': -4} + meaning U-Boot data increased by 5 bytes, SPL text decreased + by 4 + """ + err = {'_target' : target} + for image in sizes: + if image in base_sizes: + base_image = base_sizes[image] + # Loop through the text, data, bss parts + for part in sorted(sizes[image]): + diff = sizes[image][part] - base_image[part] + if diff: + if image == 'u-boot': + name = part + else: + name = image + ':' + part + err[name] = diff + return err + def _calc_size_changes(self, board_selected, board_dict): """Calculate changes in size for different image parts @@ -1267,25 +1297,7 @@ class Builder: base_sizes = self._base_board_dict[target].sizes outcome = board_dict[target] sizes = outcome.sizes - - # Loop through the list of images, creating a dict of size - # changes for each image/part. We end up with something like - # {'target' : 'snapper9g45, 'data' : 5, 'u-boot-spl:text' : -4} - # which means that U-Boot data increased by 5 bytes and SPL - # text decreased by 4. - err = {'_target' : target} - for image in sizes: - if image in base_sizes: - base_image = base_sizes[image] - # Loop through the text, data, bss parts - for part in sorted(sizes[image]): - diff = sizes[image][part] - base_image[part] - if diff: - if image == 'u-boot': - name = part - else: - name = image + ':' + part - err[name] = diff + err = self._calc_image_size_changes(target, sizes, base_sizes) arch = board_selected[target].arch if not arch in arch_count: arch_count[arch] = 1