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 31219C001DC for ; Wed, 19 Jul 2023 23:52:41 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 77D44867E9; Thu, 20 Jul 2023 01:50:37 +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="CXbKYU4d"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 881A486797; Thu, 20 Jul 2023 01:50:16 +0200 (CEST) Received: from mail-il1-x12e.google.com (mail-il1-x12e.google.com [IPv6:2607:f8b0:4864:20::12e]) (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 6BEFA86785 for ; Thu, 20 Jul 2023 01:50:10 +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-il1-x12e.google.com with SMTP id e9e14a558f8ab-3460815fde5so1628605ab.2 for ; Wed, 19 Jul 2023 16:50:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1689810609; x=1690415409; 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=rd3Ec9fQMQ6n16nKZDHB2UwXaztqK+ypPecuZNlpW0M=; b=CXbKYU4dNYfJuL4JDtoGKzs9yz5uS+pdLgY0XZvSlaBCvJrX+/UZGd2nt5ExXvJxu3 Q5JoZUn13livT08IQXhDR4zKgSIjek7IDvgKO0sBTIx3DT9Vu5ViOlPiVhM5pmhmBSnZ Rsp9q742ypMO5KKyNIgOwpHezzdy7poUri+Ao= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689810609; x=1690415409; 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=rd3Ec9fQMQ6n16nKZDHB2UwXaztqK+ypPecuZNlpW0M=; b=Zh9HRhYvHxndmk+c8JkV3YJfXpdaJltK5qaMneYsJuay/FB8kksL8Nf4vvIXSvF5/1 VkSPCC9h5Usz96QEB60oeiCm4pycghFtzGEYLa9omiTw7bD+ChQy1849qNpnfi9rhjiK 61edTPyTGSuhJCDn6cT25otwX8i7YJNZ1r7sfnFkK7OWs0wZvACe/0Q45WGRA9zaVocK d7glrm2biKQLTTAss2VTnhdFJFs2pw2myxPXWjbhhkP29hci8r0pipeNS/RIHwy/muaS eZJ8K+IbM1aMQuMRCrh8FE/t4Y8QDLdfTl/3w0EmrPitYbKBBKJG6YknggVNpoxNsUmX PZaA== X-Gm-Message-State: ABy/qLaRobrXgj8MCv/MnO/WvH8+1vImzQsC6cjlvvPEfEw7pfU2Ncvq ZMVqnnenB+sSzEORjWHScUm95QZ68oz/3t66Mdo= X-Google-Smtp-Source: APBJJlEnvzgyeBJX404pfW2m5H4GKTiPVw64sjWkYZq/mZQuP7OvQZvfVkIjV31D1zcoAgtIDs7hCQ== X-Received: by 2002:a05:6e02:2199:b0:345:d583:5c64 with SMTP id j25-20020a056e02219900b00345d5835c64mr4490109ila.24.1689810608867; Wed, 19 Jul 2023 16:50:08 -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 ed16-20020a056638291000b0042bb1779c18sm1551779jab.151.2023.07.19.16.50.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Jul 2023 16:50:08 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Mike Frysinger , Simon Glass Subject: [PATCH v4 13/83] buildman: Detect boards with multiple CONFIG_TARGETs defined Date: Wed, 19 Jul 2023 17:48:21 -0600 Message-ID: <20230719234953.796101-14-sjg@chromium.org> X-Mailer: git-send-email 2.41.0.487.g6d72f3e995-goog In-Reply-To: <20230719234953.796101-1-sjg@chromium.org> References: <20230719234953.796101-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 --- (no changes since v3) 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 2d393263003b..56fb6f4de628 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 eb1fa9f0b860..154fa61c08bd 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: orphaned defconfig in boards/board0/MAINTAINERS 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.487.g6d72f3e995-goog