Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id F28FFC0015E for ; Sun, 16 Jul 2023 00:40:02 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 407CA862E2; Sun, 16 Jul 2023 02:38:16 +0200 (CEST) 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="GspxYL1r"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id EB98086371; Sun, 16 Jul 2023 02:37:40 +0200 (CEST) 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 269BB86272 for ; Sun, 16 Jul 2023 02:37:34 +0200 (CEST) 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 ca18e2360f4ac-7837329a00aso153106539f.2 for ; Sat, 15 Jul 2023 17:37:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1689467852; x=1692059852; 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=e64QVRT/anH2oxsz8Z+Qcgtmcxa9BC0S6cPva0SHUjs=; b=GspxYL1rBEdFLW5e9WcOjZ4bWB8WxtuAMWpuySks4fIKrdn0MEYz6V+w6njdNyx8JS tcA0Wb3ztWu/HA0sIrEKiQosGRNbPzr9pFK49rAScqa2CzIWX8oFRrwADOBDz0De9LZb g3dS6yTXu0RPkJue2GAcnU4v3jZGUUz6rJ07o= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689467852; x=1692059852; 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=e64QVRT/anH2oxsz8Z+Qcgtmcxa9BC0S6cPva0SHUjs=; b=HPGungGKHz6fQMr5IT7rmL4qG23j2T91C5V0c5z9Ah2vqlPcbpj+HkLEuy8TVfZ/Xi xQtnAGco9Q1MUR0Sr6vUDVMsi0a26FLEgwb6m2DHrVv19dNEH+OkpBOYVsoH0fHAD1LO 7IFOi3lM5ojyZfmdzCR3Kd15xlxHhu3TBuJGYxgc16CGrLHnTkIQx2uDTLc4HXIyZvEt bTQsT9Npiee598ZnJr2gGVoeHiwf/jKPOXTNHEQH0f9L95fj4qmtSvGADVYUxxvXfnB1 P9djUnHHuxbUvFDRcFfORDYyFUbIo9Ym4AGExdcM4baReSdDdfGPeqoThN0B3KoBUVnN f3nQ== X-Gm-Message-State: ABy/qLY24K7Hk2+Vh4mBx2W7TdYvmNnhxzcZ/keWFPF39dsWshju/LtC Dlrn81yD+nkekt3WfL0TGKWYU/fd7v6zOZD+AUU= X-Google-Smtp-Source: APBJJlEQ1LlnHZ6NOiHv8UBtNGos2+rhbfUCPBN3J4/3cVNgdX8doM3N4VaXpSqLYivlKQg5xAMrqQ== X-Received: by 2002:a5e:a803:0:b0:783:3899:e1d0 with SMTP id c3-20020a5ea803000000b007833899e1d0mr8742284ioa.6.1689467852605; Sat, 15 Jul 2023 17:37:32 -0700 (PDT) Received: from sjg1.lan (c-73-14-173-85.hsd1.co.comcast.net. [73.14.173.85]) by smtp.gmail.com with ESMTPSA id t3-20020a05663801e300b0042b52dc77e3sm3510512jaq.158.2023.07.15.17.37.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 15 Jul 2023 17:37:32 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Mike Frysinger , Simon Glass Subject: [PATCH v3 13/81] buildman: Detect boards with multiple CONFIG_TARGETs defined Date: Sat, 15 Jul 2023 18:35:41 -0600 Message-ID: <20230716003718.231903-14-sjg@chromium.org> X-Mailer: git-send-email 2.41.0.455.g037347b96a-goog In-Reply-To: <20230716003718.231903-1-sjg@chromium.org> References: <20230716003718.231903-1-sjg@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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.8 at phobos.denx.de X-Virus-Status: Clean The TARGET_xxx options are special in that they refer to a single target. Exactly one should be enabled for each target, corresponding to a defconfig file. Detect configs which result in two TARGET_xxx options being set. For example, at present, TARGET_POLEG and TARET_POLEG_EVB are enabled for the same board. Note: This warning is not displayed by default. An option will be added to enable it. Signed-off-by: Simon Glass --- Changes in v3: - Add new patch to detect boards with multiple CONFIG_TARGETs defined tools/buildman/boards.py | 73 +++++++++++++++++++++++++------------ tools/buildman/func_test.py | 20 +++++++++- 2 files changed, 68 insertions(+), 25 deletions(-) diff --git a/tools/buildman/boards.py b/tools/buildman/boards.py index 794e6fcf63bf..31831f383750 100644 --- a/tools/buildman/boards.py +++ b/tools/buildman/boards.py @@ -220,16 +220,17 @@ class KconfigScanner: defconfig (str): path to the defconfig file to be processed Returns: - A dictionary of board parameters. It has a form of: - { - 'arch': , - 'cpu': , - 'soc': , - 'vendor': , - 'board': , - 'target': , - 'config': , - } + tuple: dictionary of board parameters. It has a form of: + { + 'arch': , + 'cpu': , + 'soc': , + 'vendor': , + 'board': , + 'target': , + 'config': , + } + warnings (list of str): list of warnings found """ leaf = os.path.basename(defconfig) expect_target, match, rear = leaf.partition('_defconfig') @@ -239,6 +240,7 @@ class KconfigScanner: self._tmpfile = None params = {} + warnings = [] # Get the value of CONFIG_SYS_ARCH, CONFIG_SYS_CPU, ... etc. # Set '-' if the value is empty. @@ -249,6 +251,17 @@ class KconfigScanner: else: params[key] = '-' + # Check there is exactly one TARGET_xxx set + target = None + for name, sym in self._conf.syms.items(): + if name.startswith('TARGET_') and sym.str_value == 'y': + tname = name[7:].lower() + if target: + warnings.append( + f'WARNING: {leaf}: Duplicate TARGET_xxx: {target} and {tname}') + else: + target = tname + params['target'] = expect_target # fix-up for aarch64 @@ -266,7 +279,7 @@ class KconfigScanner: else: params['arch'] = 'riscv64' - return params + return params, warnings class MaintainersDatabase: @@ -658,11 +671,19 @@ class Boards: queue.put(kconf_scanner.scan(defconfig)) @classmethod - def read_queues(cls, queues, params_list): - """Read the queues and append the data to the paramers list""" + def read_queues(cls, queues, params_list, warnings): + """Read the queues and append the data to the paramers list + + Args: + queues (list of multiprocessing.Queue): Queues to read + params_list (list of dict): List to add params too + warnings (set of str): Set to add warnings to + """ for que in queues: while not que.empty(): - params_list.append(que.get()) + params, warn = que.get() + params_list.append(params) + warnings.update(warn) def scan_defconfigs(self, config_dir, srcdir, jobs=1): """Collect board parameters for all defconfig files. @@ -675,9 +696,12 @@ class Boards: jobs (int): The number of jobs to run simultaneously Returns: - list of dict: List of board parameters, each a dict: - key: 'arch', 'cpu', 'soc', 'vendor', 'board', 'target', 'config' - value: string value of the key + tuple: + list of dict: List of board parameters, each a dict: + key: 'arch', 'cpu', 'soc', 'vendor', 'board', 'target', + 'config' + value: string value of the key + list of str: List of warnings recorded """ all_defconfigs = [] for (dirpath, _, filenames) in os.walk(config_dir): @@ -700,13 +724,14 @@ class Boards: processes.append(proc) queues.append(que) - # The resulting data should be accumulated to this list + # The resulting data should be accumulated to these lists params_list = [] + warnings = set() # Data in the queues should be retrieved preriodically. # Otherwise, the queues would become full and subprocesses would get stuck. while any(p.is_alive() for p in processes): - self.read_queues(queues, params_list) + self.read_queues(queues, params_list, warnings) # sleep for a while until the queues are filled time.sleep(SLEEP_TIME) @@ -716,9 +741,9 @@ class Boards: proc.join() # retrieve leftover data - self.read_queues(queues, params_list) + self.read_queues(queues, params_list, warnings) - return params_list + return params_list, sorted(list(warnings)) @classmethod def insert_maintainers_info(cls, srcdir, params_list): @@ -797,9 +822,9 @@ class Boards: value: string value of the key list of str: Warnings that came up """ - params_list = self.scan_defconfigs(config_dir, srcdir, jobs) - warnings = self.insert_maintainers_info(srcdir, params_list) - return params_list, warnings + params_list, warnings = self.scan_defconfigs(config_dir, srcdir, jobs) + m_warnings = self.insert_maintainers_info(srcdir, params_list) + return params_list, warnings + m_warnings def ensure_board_list(self, output, jobs=1, force=False, quiet=False): """Generate a board database file if needed. diff --git a/tools/buildman/func_test.py b/tools/buildman/func_test.py index 73abe16e1ca5..e7e22da62b15 100644 --- a/tools/buildman/func_test.py +++ b/tools/buildman/func_test.py @@ -794,10 +794,11 @@ CONFIG_LOCALVERSION=y # Scan the test directory which contains a Kconfig and some *_defconfig # files - params = self._boards.scan_defconfigs(src, src) + params, warnings = self._boards.scan_defconfigs(src, src) # We should get two boards self.assertEquals(2, len(params)) + self.assertFalse(warnings) first = 0 if params[0]['target'] == 'board0' else 1 board0 = params[first] board2 = params[1 - first] @@ -882,6 +883,7 @@ Active aarch64 armv8 - armltd total_compute board2 src = self._git_dir main = os.path.join(src, 'boards', 'board0', 'MAINTAINERS') other = os.path.join(src, 'boards', 'board2', 'MAINTAINERS') + kc_file = os.path.join(src, 'Kconfig') config_dir = os.path.join(src, 'configs') params_list, warnings = self._boards.build_board_list(config_dir, src) @@ -946,3 +948,19 @@ Active aarch64 armv8 - armltd total_compute board2 self.assertEquals( ['WARNING: boards/board0/MAINTAINERS: missing defconfig ending at line 16'], warnings) + + # Add another TARGET to the Kconfig + tools.write_file(main, data, binary=False) + extra = (b''' +if TARGET_BOARD2 +config TARGET_OTHER +\tbool "other" +\tdefault y +endif +''') + tools.write_file(kc_file, tools.read_file(kc_file) + extra) + params_list, warnings = self._boards.build_board_list(config_dir, src) + self.assertEquals(2, len(params_list)) + self.assertEquals( + ['WARNING: board2_defconfig: Duplicate TARGET_xxx: board2 and other'], + warnings) -- 2.41.0.455.g037347b96a-goog