From patchwork Sat Sep 2 14:53:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Jo=C3=A3o_Marcos_Costa?= X-Patchwork-Id: 1829105 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20221208 header.b=awPBZmFZ; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=patchwork.ozlabs.org) Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4RdHvy5H4bz1yfm for ; Sun, 3 Sep 2023 00:53:34 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id C66FB867EA; Sat, 2 Sep 2023 16:53:23 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="awPBZmFZ"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 429498679F; Sat, 2 Sep 2023 16:53:23 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-wr1-x431.google.com (mail-wr1-x431.google.com [IPv6:2a00:1450:4864:20::431]) (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 867FE86467 for ; Sat, 2 Sep 2023 16:53:20 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=jmcosta944@gmail.com Received: by mail-wr1-x431.google.com with SMTP id ffacd0b85a97d-31c65820134so2442507f8f.1 for ; Sat, 02 Sep 2023 07:53:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1693666400; x=1694271200; darn=lists.denx.de; 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=cLt/k2jfppd558tZuRkQGTwbhBX5TEWbxVq56iIr2Oo=; b=awPBZmFZvs0ibEW6QOow0blCKO5ggcR+MGVV7wW26eHaTsfnNvUlrXtp1XjWbpoKNA wg9s6HrqL3VURPh0FZyVGOZf3ubrdZto2gWJCJePv7xbLgQkavC9m9hCCAkTB9ah25iZ taPATTreSzuR2Wvfv03uirEGnk8qOidLUBYpQGjilh8+8dnclPrzUlDi+7Gz6WbMQjR+ TCHmjKj1yMd3uuDRPeWdM8KfhyxW0MuyO3q9kSs4Rx+iPwm0wXud8/Y0LCoXjFLKKw36 blIEdZA093053hgdDUc/g63vzZWrjDuC20byw2W7fWy3X5jYGiP5VOtcqeeis7OZ50En dJYA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693666400; x=1694271200; 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=cLt/k2jfppd558tZuRkQGTwbhBX5TEWbxVq56iIr2Oo=; b=h/y3OgRldHGkXOe1iP7ISbJ3Q3OBKUmCmc2Y+iUped22m2mCYU1X8liBKkQM6XotF1 6BR5IsU+hOf3ucWtFCb3v/t0oR4haIwfbUsEi1hHiNgLQ2Gn+CvAMDY6xjr30W6mLcNe vTr5DeawUW5GcM6sCOQzwJRlnrIkIwMWtaTg5lNYfK7ZPAu8OMCIbAbV1CMeh+2UMib7 1SGZbv34/XeKnM9P3nipOlD4a672lB7/dvTRYCuTFpDyDaidpi4UlT8flSpMH1GG9C39 7E2Ea4meIMsktcbGeYBqfes0wNvxw15qJML9dJb+BoKtQvLX2FoXKWEhjPiYxBEDHUpd LRZQ== X-Gm-Message-State: AOJu0Yy7Tx03suR0a8MwMkmQR2aYSyhMlQjrv8jq2vagC7oAQsuRx+d2 YYBSaHA5HNvP+CD262Fbl7sFEpYusu8RF3x2 X-Google-Smtp-Source: AGHT+IHhvFI9vgLlo+4vCaB9u21+EVJCIvA8iQTeRbDqFuZsDRi1Z8DS9v1qaXndz1HxH9uqGBcdgA== X-Received: by 2002:adf:e70e:0:b0:316:f25c:d0c0 with SMTP id c14-20020adfe70e000000b00316f25cd0c0mr3780180wrm.16.1693666399443; Sat, 02 Sep 2023 07:53:19 -0700 (PDT) Received: from fedora.. (cust-west-par-46-193-56-152.cust.wifirst.net. [46.193.56.152]) by smtp.gmail.com with ESMTPSA id cc11-20020a5d5c0b000000b0031f34a395e7sm2385449wrb.45.2023.09.02.07.53.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 02 Sep 2023 07:53:19 -0700 (PDT) From: Joao Marcos Costa To: u-boot@lists.denx.de Cc: trini@konsulko.com, sjg@chromium.org, antoningodard@pm.me, Y.Moog@phytec.de, Joao Marcos Costa Subject: [PATCH v3 1/7] scripts: Port Linux's gen_compile_commands.py to U-Boot Date: Sat, 2 Sep 2023 16:53:04 +0200 Message-ID: <20230902145310.107054-2-jmcosta944@gmail.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230902145310.107054-1-jmcosta944@gmail.com> References: <20230902145310.107054-1-jmcosta944@gmail.com> MIME-Version: 1.0 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 This script generates a database of compiler flags, namely compile_commands.json. It is quite useful for text editors that use clangd LSP (e.g. Vim, Neovim). It was ported from Linux's sources: - tag: v6.4 - revision 6995e2de6891c724bfeb2db33d7b87775f913ad1 Modifications for U-Boot compatibility will be added in a follow-up commit. Signed-off-by: Joao Marcos Costa --- scripts/gen_compile_commands.py | 228 ++++++++++++++++++++++++++++++++ 1 file changed, 228 insertions(+) create mode 100755 scripts/gen_compile_commands.py diff --git a/scripts/gen_compile_commands.py b/scripts/gen_compile_commands.py new file mode 100755 index 0000000000..15ba56527a --- /dev/null +++ b/scripts/gen_compile_commands.py @@ -0,0 +1,228 @@ +#!/usr/bin/env python3 +# SPDX-License-Identifier: GPL-2.0 +# +# Copyright (C) Google LLC, 2018 +# +# Author: Tom Roeder +# +"""A tool for generating compile_commands.json in the Linux kernel.""" + +import argparse +import json +import logging +import os +import re +import subprocess +import sys + +_DEFAULT_OUTPUT = 'compile_commands.json' +_DEFAULT_LOG_LEVEL = 'WARNING' + +_FILENAME_PATTERN = r'^\..*\.cmd$' +_LINE_PATTERN = r'^savedcmd_[^ ]*\.o := (.* )([^ ]*\.c) *(;|$)' +_VALID_LOG_LEVELS = ['DEBUG', 'INFO', 'WARNING', 'ERROR', 'CRITICAL'] +# The tools/ directory adopts a different build system, and produces .cmd +# files in a different format. Do not support it. +_EXCLUDE_DIRS = ['.git', 'Documentation', 'include', 'tools'] + +def parse_arguments(): + """Sets up and parses command-line arguments. + + Returns: + log_level: A logging level to filter log output. + directory: The work directory where the objects were built. + ar: Command used for parsing .a archives. + output: Where to write the compile-commands JSON file. + paths: The list of files/directories to handle to find .cmd files. + """ + usage = 'Creates a compile_commands.json database from kernel .cmd files' + parser = argparse.ArgumentParser(description=usage) + + directory_help = ('specify the output directory used for the kernel build ' + '(defaults to the working directory)') + parser.add_argument('-d', '--directory', type=str, default='.', + help=directory_help) + + output_help = ('path to the output command database (defaults to ' + + _DEFAULT_OUTPUT + ')') + parser.add_argument('-o', '--output', type=str, default=_DEFAULT_OUTPUT, + help=output_help) + + log_level_help = ('the level of log messages to produce (defaults to ' + + _DEFAULT_LOG_LEVEL + ')') + parser.add_argument('--log_level', choices=_VALID_LOG_LEVELS, + default=_DEFAULT_LOG_LEVEL, help=log_level_help) + + ar_help = 'command used for parsing .a archives' + parser.add_argument('-a', '--ar', type=str, default='llvm-ar', help=ar_help) + + paths_help = ('directories to search or files to parse ' + '(files should be *.o, *.a, or modules.order). ' + 'If nothing is specified, the current directory is searched') + parser.add_argument('paths', type=str, nargs='*', help=paths_help) + + args = parser.parse_args() + + return (args.log_level, + os.path.abspath(args.directory), + args.output, + args.ar, + args.paths if len(args.paths) > 0 else [args.directory]) + + +def cmdfiles_in_dir(directory): + """Generate the iterator of .cmd files found under the directory. + + Walk under the given directory, and yield every .cmd file found. + + Args: + directory: The directory to search for .cmd files. + + Yields: + The path to a .cmd file. + """ + + filename_matcher = re.compile(_FILENAME_PATTERN) + exclude_dirs = [ os.path.join(directory, d) for d in _EXCLUDE_DIRS ] + + for dirpath, dirnames, filenames in os.walk(directory, topdown=True): + # Prune unwanted directories. + if dirpath in exclude_dirs: + dirnames[:] = [] + continue + + for filename in filenames: + if filename_matcher.match(filename): + yield os.path.join(dirpath, filename) + + +def to_cmdfile(path): + """Return the path of .cmd file used for the given build artifact + + Args: + Path: file path + + Returns: + The path to .cmd file + """ + dir, base = os.path.split(path) + return os.path.join(dir, '.' + base + '.cmd') + + +def cmdfiles_for_a(archive, ar): + """Generate the iterator of .cmd files associated with the archive. + + Parse the given archive, and yield every .cmd file used to build it. + + Args: + archive: The archive to parse + + Yields: + The path to every .cmd file found + """ + for obj in subprocess.check_output([ar, '-t', archive]).decode().split(): + yield to_cmdfile(obj) + + +def cmdfiles_for_modorder(modorder): + """Generate the iterator of .cmd files associated with the modules.order. + + Parse the given modules.order, and yield every .cmd file used to build the + contained modules. + + Args: + modorder: The modules.order file to parse + + Yields: + The path to every .cmd file found + """ + with open(modorder) as f: + for line in f: + obj = line.rstrip() + base, ext = os.path.splitext(obj) + if ext != '.o': + sys.exit('{}: module path must end with .o'.format(obj)) + mod = base + '.mod' + # Read from *.mod, to get a list of objects that compose the module. + with open(mod) as m: + for mod_line in m: + yield to_cmdfile(mod_line.rstrip()) + + +def process_line(root_directory, command_prefix, file_path): + """Extracts information from a .cmd line and creates an entry from it. + + Args: + root_directory: The directory that was searched for .cmd files. Usually + used directly in the "directory" entry in compile_commands.json. + command_prefix: The extracted command line, up to the last element. + file_path: The .c file from the end of the extracted command. + Usually relative to root_directory, but sometimes absolute. + + Returns: + An entry to append to compile_commands. + + Raises: + ValueError: Could not find the extracted file based on file_path and + root_directory or file_directory. + """ + # The .cmd files are intended to be included directly by Make, so they + # escape the pound sign '#', either as '\#' or '$(pound)' (depending on the + # kernel version). The compile_commands.json file is not interepreted + # by Make, so this code replaces the escaped version with '#'. + prefix = command_prefix.replace('\#', '#').replace('$(pound)', '#') + + # Use os.path.abspath() to normalize the path resolving '.' and '..' . + abs_path = os.path.abspath(os.path.join(root_directory, file_path)) + if not os.path.exists(abs_path): + raise ValueError('File %s not found' % abs_path) + return { + 'directory': root_directory, + 'file': abs_path, + 'command': prefix + file_path, + } + + +def main(): + """Walks through the directory and finds and parses .cmd files.""" + log_level, directory, output, ar, paths = parse_arguments() + + level = getattr(logging, log_level) + logging.basicConfig(format='%(levelname)s: %(message)s', level=level) + + line_matcher = re.compile(_LINE_PATTERN) + + compile_commands = [] + + for path in paths: + # If 'path' is a directory, handle all .cmd files under it. + # Otherwise, handle .cmd files associated with the file. + # built-in objects are linked via vmlinux.a + # Modules are listed in modules.order. + if os.path.isdir(path): + cmdfiles = cmdfiles_in_dir(path) + elif path.endswith('.a'): + cmdfiles = cmdfiles_for_a(path, ar) + elif path.endswith('modules.order'): + cmdfiles = cmdfiles_for_modorder(path) + else: + sys.exit('{}: unknown file type'.format(path)) + + for cmdfile in cmdfiles: + with open(cmdfile, 'rt') as f: + result = line_matcher.match(f.readline()) + if result: + try: + entry = process_line(directory, result.group(1), + result.group(2)) + compile_commands.append(entry) + except ValueError as err: + logging.info('Could not add line from %s: %s', + cmdfile, err) + + with open(output, 'wt') as f: + json.dump(compile_commands, f, indent=2, sort_keys=True) + + +if __name__ == '__main__': + main() From patchwork Sat Sep 2 14:53:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Jo=C3=A3o_Marcos_Costa?= X-Patchwork-Id: 1829106 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20221208 header.b=EpiEEQJr; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=patchwork.ozlabs.org) Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4RdHw80Qfmz1yfm for ; Sun, 3 Sep 2023 00:53:44 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 1287E8679F; Sat, 2 Sep 2023 16:53:26 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="EpiEEQJr"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 51DBF8684C; Sat, 2 Sep 2023 16:53:25 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-wm1-x333.google.com (mail-wm1-x333.google.com [IPv6:2a00:1450:4864:20::333]) (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 C9D9486759 for ; Sat, 2 Sep 2023 16:53:22 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=jmcosta944@gmail.com Received: by mail-wm1-x333.google.com with SMTP id 5b1f17b1804b1-4018af103bcso84765e9.1 for ; Sat, 02 Sep 2023 07:53:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1693666402; x=1694271202; darn=lists.denx.de; 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=e7hb2jrvivQxON1XeovwgMxiW+RYRxZdLPP3zp29do4=; b=EpiEEQJrU9oE6U1sdemFnWeZCcQ5GPpjsId0DUkUMmXccYMqowgVXqWUU/erpZi3+y /XkdFEHzTRIKFAhzdWpvi/f6rzbRZvzM2XwaYQot/Sc+LzcFsR1Cjc247KAUMJtAJGfy 9BdW2dP+jgYoqdrvs5XFAOnWqVD3n3OjeA7TvY9hdZjP11dVgskl9hHa1q3N18RbjUmX CT02fBtZH6g6QaZs24xWyhgrJemsIy9rWDNGGS4lD3MWhXWfQxMqYdl+EyDLsyP0D9el 5iPmck+fBjCnVMbziayB847Z4JF8twYYVolrwSN411dUctdP3osuNtksLU15XoNsn5vR k3kw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693666402; x=1694271202; 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=e7hb2jrvivQxON1XeovwgMxiW+RYRxZdLPP3zp29do4=; b=kU+FTS703Sa14im5ZmolPZgd2lj96qvwZGB2rqoByteiaMymN5eN9SY7eOzgAkdugM ecyBzoL+Qp7A2pzVBcmiW/WEHVvgem00CrqzRHzBB31JuKJcTZHARbORQeJyBopMJred bxdwCyZWh9rL2TeVeBOdklCsyJPFrqyhM+MZTC1CMAxS5vW4ISWTPfs2KFBSJqvleZbg cUge8/7n+0ufdwDazByIL4cNARJnYhSppw5v17fJs5gdT+rwzOiG52AlJAgcWvs3B+jk gVimOLt4IB9zjrwz3Zg1ufHArcYTi3szzlpKDX0HbJHMsHBzw316KJI8pRRFLbXTcfm7 rWqA== X-Gm-Message-State: AOJu0YxYBCVXpY66tYyT2RSOa2hlZ1hSAlIpKCmfp46NaSby0WfYrCCD bFatMtP2lM937v3vEpTKEs0RNKERrU+c1Z1q X-Google-Smtp-Source: AGHT+IFcXSQ8GG1Yw4EjsDCa5kcBctDKQmGXHJ/6+RBfADqZZSht++GqTUIuemJ6xsjQClKX0W0aJQ== X-Received: by 2002:a05:600c:2196:b0:401:4542:5ee1 with SMTP id e22-20020a05600c219600b0040145425ee1mr4579434wme.5.1693666401675; Sat, 02 Sep 2023 07:53:21 -0700 (PDT) Received: from fedora.. (cust-west-par-46-193-56-152.cust.wifirst.net. [46.193.56.152]) by smtp.gmail.com with ESMTPSA id cc11-20020a5d5c0b000000b0031f34a395e7sm2385449wrb.45.2023.09.02.07.53.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 02 Sep 2023 07:53:21 -0700 (PDT) From: Joao Marcos Costa To: u-boot@lists.denx.de Cc: trini@konsulko.com, sjg@chromium.org, antoningodard@pm.me, Y.Moog@phytec.de, Joao Marcos Costa Subject: [PATCH v3 2/7] scripts/gen_compile_commands.py: adapt _LINE_PATTERN Date: Sat, 2 Sep 2023 16:53:05 +0200 Message-ID: <20230902145310.107054-3-jmcosta944@gmail.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230902145310.107054-1-jmcosta944@gmail.com> References: <20230902145310.107054-1-jmcosta944@gmail.com> MIME-Version: 1.0 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 For U-Boot's context, the regular expression defined by _LINE_PATTERN should be adapted. Replace 'savedcmd' by 'cmd'. Signed-off-by: Joao Marcos Costa --- scripts/gen_compile_commands.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/gen_compile_commands.py b/scripts/gen_compile_commands.py index 15ba56527a..0227522959 100755 --- a/scripts/gen_compile_commands.py +++ b/scripts/gen_compile_commands.py @@ -19,7 +19,7 @@ _DEFAULT_OUTPUT = 'compile_commands.json' _DEFAULT_LOG_LEVEL = 'WARNING' _FILENAME_PATTERN = r'^\..*\.cmd$' -_LINE_PATTERN = r'^savedcmd_[^ ]*\.o := (.* )([^ ]*\.c) *(;|$)' +_LINE_PATTERN = r'^cmd_[^ ]*\.o := (.* )([^ ]*\.c) *(;|$)' _VALID_LOG_LEVELS = ['DEBUG', 'INFO', 'WARNING', 'ERROR', 'CRITICAL'] # The tools/ directory adopts a different build system, and produces .cmd # files in a different format. Do not support it. From patchwork Sat Sep 2 14:53:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Jo=C3=A3o_Marcos_Costa?= X-Patchwork-Id: 1829107 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20221208 header.b=OtEV2aqZ; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=patchwork.ozlabs.org) Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4RdHwL278vz1yfm for ; Sun, 3 Sep 2023 00:53:54 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 574B686467; Sat, 2 Sep 2023 16:53:29 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="OtEV2aqZ"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id C5269867C7; Sat, 2 Sep 2023 16:53:27 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-wm1-x32d.google.com (mail-wm1-x32d.google.com [IPv6:2a00:1450:4864:20::32d]) (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 769DB867B6 for ; Sat, 2 Sep 2023 16:53:23 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=jmcosta944@gmail.com Received: by mail-wm1-x32d.google.com with SMTP id 5b1f17b1804b1-401da71b85eso393855e9.1 for ; Sat, 02 Sep 2023 07:53:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1693666403; x=1694271203; darn=lists.denx.de; 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=Msrb6/nmtExFC8B0sHWpf3s96bn/pi+WsRWwEFGprnc=; b=OtEV2aqZ8TV1H2++08itcAnau8FiWoEuqmnMkFutp0NXlqyqUW1eJpFeLLrfynqEft 80Cz61yRJR5TlKhkV2hhfcCoVrS1i5gswmYQCZW+5K0Bw2xDUT/5dN2+s1qbGaEulTLi OWKzZ/U83pM+GJRdJaWFljoxpNWo6XBDExA7BV6tJNLLZNYAystvS8D2dnB8tpqgrig6 bfG8HsqXzAXeWuow1U9lkKIhGBN6feUKTznuYAbS+UMW3hZU00ucOCSqP649ZTI3Sr54 CdJi4mvwnw6bvlZZlHPqkylsYesNgvvqMFCUn6IZMZ113F+nFM8Y7SdYZKmKbl9CQQJ+ j8pg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693666403; x=1694271203; 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=Msrb6/nmtExFC8B0sHWpf3s96bn/pi+WsRWwEFGprnc=; b=gwz/++uGL5G5Qlz2R3zBCdhESRzpg0buI7ssHSEX9lk07jpVzChjcDdDPyP7Q/rKn3 YClYNAyaI+T72LtBFBWw5c/PEwLU1qlX0dx6LIpY0FsoCgzVy+z9xqp4O0IXMbhGt3i+ xN+cLKQecVb4UNaeQ8JQUaSjtTVCs3ZXoulgyvObcStngVGs/tKquEUAfZHg1YStJBFk ocsrzSMmc4BvE25SPaCetZ1+KRCEeCwhdi6ogYexLAHCb9Xrzta9UANQhAW3g0oKmzE3 mDKOHaxRWACu76k6o8UBqy3aHfd5HrMC3v0x/NvLb4gWYX+g3A00R+0ho1mhX2vQZS2A 714g== X-Gm-Message-State: AOJu0YyPA5ljPUnWJJS7mCZRFE/3yRAwj0dalkFQambmanIDQ+yeF3DD 0rXZOACB56cgcIusDSdSB/fQnGsRS17Wl6TE X-Google-Smtp-Source: AGHT+IGu77gCo2GIMAmue9iNSqFb6sODNN5y5i7SpaP7wn1pNFdV5P5vF0n3tOPhPXpDk6eICLDJ8Q== X-Received: by 2002:adf:f24d:0:b0:31d:d5db:5983 with SMTP id b13-20020adff24d000000b0031dd5db5983mr3839325wrp.27.1693666402505; Sat, 02 Sep 2023 07:53:22 -0700 (PDT) Received: from fedora.. (cust-west-par-46-193-56-152.cust.wifirst.net. [46.193.56.152]) by smtp.gmail.com with ESMTPSA id cc11-20020a5d5c0b000000b0031f34a395e7sm2385449wrb.45.2023.09.02.07.53.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 02 Sep 2023 07:53:22 -0700 (PDT) From: Joao Marcos Costa To: u-boot@lists.denx.de Cc: trini@konsulko.com, sjg@chromium.org, antoningodard@pm.me, Y.Moog@phytec.de, Joao Marcos Costa Subject: [PATCH v3 3/7] scripts/gen_compile_commands.py: fix docstring Date: Sat, 2 Sep 2023 16:53:06 +0200 Message-ID: <20230902145310.107054-4-jmcosta944@gmail.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230902145310.107054-1-jmcosta944@gmail.com> References: <20230902145310.107054-1-jmcosta944@gmail.com> MIME-Version: 1.0 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 referred tool is now in U-Boot. Replace "the Linux kernel" by "U-Boot" to make the docstring coherent. Signed-off-by: Joao Marcos Costa --- scripts/gen_compile_commands.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/gen_compile_commands.py b/scripts/gen_compile_commands.py index 0227522959..63d036a773 100755 --- a/scripts/gen_compile_commands.py +++ b/scripts/gen_compile_commands.py @@ -5,7 +5,7 @@ # # Author: Tom Roeder # -"""A tool for generating compile_commands.json in the Linux kernel.""" +"""A tool for generating compile_commands.json in U-Boot.""" import argparse import json From patchwork Sat Sep 2 14:53:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Jo=C3=A3o_Marcos_Costa?= X-Patchwork-Id: 1829109 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20221208 header.b=FaJ4vhMA; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=patchwork.ozlabs.org) Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4RdHwl5lXFz1yfm for ; Sun, 3 Sep 2023 00:54:15 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id E029686828; Sat, 2 Sep 2023 16:53:29 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="FaJ4vhMA"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id D382A867C3; Sat, 2 Sep 2023 16:53:27 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-wm1-x329.google.com (mail-wm1-x329.google.com [IPv6:2a00:1450:4864:20::329]) (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 DAB6386801 for ; Sat, 2 Sep 2023 16:53:23 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=jmcosta944@gmail.com Received: by mail-wm1-x329.google.com with SMTP id 5b1f17b1804b1-400a087b0bfso321825e9.2 for ; Sat, 02 Sep 2023 07:53:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1693666403; x=1694271203; darn=lists.denx.de; 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=nquaMTUkKEj9f0VDmD18sTp9HY+/Vhfo0qP8M2hbUps=; b=FaJ4vhMAV9mLVwZDy01Rm3kAL/M6bB9VYbRfW8amH/XHioZ3Rd8ppQcDL5bXLkWBXn fQV1EROpLqxeeG8TCDuOcEMtHkAvVwC1meB2xZZnaqAQ1merhej0Mmdu1M3jz3Ol3lr+ /3/869YxFskbIMFQSESDIoHojfjsiM6jPo/+p55qPAGaVs9/3x6pgTkbCE0/lg1YW/5k XUq2urfsafnpa2bMlh+zfnLWmuI3wnwf7gMgWdseo3pqjQlzx75MEzwQA8p531LMdFFI zHZqklJCdvNTT9U8wUZ+aF0BvXLmV50nY1k8nAywrzYE9HN0kLVatPp4pkndV8595JDO VhvA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693666403; x=1694271203; 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=nquaMTUkKEj9f0VDmD18sTp9HY+/Vhfo0qP8M2hbUps=; b=LUs3s+AMemp4PqW5kFQrHO+0DPdqJ6vltzlvHTwVPwQ32j6hbsDl5/yujJHTKHfCvW Rnz/m+669Ori+3i5nKLIdHhdHfvorpu4kMDtVYucQWQCzTkV/8gQrGLmmZcH+XP4RbIL V3NhCRoHGH6xRTk3r/N+LOOvipg+Y0RWcb7Jpc5In6oMzFDzNpi/mFmq9dRk4IWblMQP m02Y3etoo2hqVAYbS7XLlxniQzWgYIlBK7lj+CREbCsUW/Y2+Z3yz2doV23Esr807gg/ GGN1Ep0cvjEZvHmXj/rxfJJFKpQDcSoJ9qpNmBUTklvvVEZhuYULulLUVmFmvEGcJWnL dihQ== X-Gm-Message-State: AOJu0YyJOnGuM0s+5fdG1wUq9gCdqx4CN4e0ued/M2o4fJBQ+RxonZXl bdblmaSgPWRNtoIhJlmmf4ZpOvPg9hCGBntY X-Google-Smtp-Source: AGHT+IGdTjMjTn5h3h4D+4QUdMuluoVNsTNniWr+n46OMZSXVvtVnzrGTlcHwJxOGXCgU6ZSyd4TAA== X-Received: by 2002:a5d:638d:0:b0:317:6d9d:1250 with SMTP id p13-20020a5d638d000000b003176d9d1250mr3866514wru.61.1693666403082; Sat, 02 Sep 2023 07:53:23 -0700 (PDT) Received: from fedora.. (cust-west-par-46-193-56-152.cust.wifirst.net. [46.193.56.152]) by smtp.gmail.com with ESMTPSA id cc11-20020a5d5c0b000000b0031f34a395e7sm2385449wrb.45.2023.09.02.07.53.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 02 Sep 2023 07:53:22 -0700 (PDT) From: Joao Marcos Costa To: u-boot@lists.denx.de Cc: trini@konsulko.com, sjg@chromium.org, antoningodard@pm.me, Y.Moog@phytec.de, Joao Marcos Costa Subject: [PATCH v3 4/7] scripts/gen_compile_commands.py: add acknowledgments Date: Sat, 2 Sep 2023 16:53:07 +0200 Message-ID: <20230902145310.107054-5-jmcosta944@gmail.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230902145310.107054-1-jmcosta944@gmail.com> References: <20230902145310.107054-1-jmcosta944@gmail.com> MIME-Version: 1.0 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 Add acknowledgments for porting and modifying the script. Of course, the license, author, and copyright notice remain the same as in the original script. Signed-off-by: Joao Marcos Costa --- scripts/gen_compile_commands.py | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/gen_compile_commands.py b/scripts/gen_compile_commands.py index 63d036a773..1a9c49b34a 100755 --- a/scripts/gen_compile_commands.py +++ b/scripts/gen_compile_commands.py @@ -4,6 +4,7 @@ # Copyright (C) Google LLC, 2018 # # Author: Tom Roeder +# Ported and modified for U-Boot by Joao Marcos Costa # """A tool for generating compile_commands.json in U-Boot.""" From patchwork Sat Sep 2 14:53:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Jo=C3=A3o_Marcos_Costa?= X-Patchwork-Id: 1829108 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20221208 header.b=Z+ZTb5xE; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=patchwork.ozlabs.org) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4RdHwZ3jZxz1yfm for ; Sun, 3 Sep 2023 00:54:06 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 9CEEE867C3; Sat, 2 Sep 2023 16:53:29 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="Z+ZTb5xE"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id CC2FB867B6; Sat, 2 Sep 2023 16:53:27 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-wm1-x333.google.com (mail-wm1-x333.google.com [IPv6:2a00:1450:4864:20::333]) (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 A27AD86824 for ; Sat, 2 Sep 2023 16:53:24 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=jmcosta944@gmail.com Received: by mail-wm1-x333.google.com with SMTP id 5b1f17b1804b1-402be83929eso295915e9.3 for ; Sat, 02 Sep 2023 07:53:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1693666404; x=1694271204; darn=lists.denx.de; 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=7/rN6hpA6RUR8xcynsTbN4wgdal1KH5zv5tVJu4j/8A=; b=Z+ZTb5xExRCEED5GukbDlWtm3WCmZW3biAbsdVBbMQQgnU65yAlyXC9/fVoVeCDUFP UosWg0IV9lDoE0H4E94jXt8AebulhWeQwQCN9sTZ0BkMJSNhqvOJsqb3wMfV6Ee4pDIG pHc1FJoGG6XcunYJyA+bAutknvkQJckGkwsQvQbG0XCSzlqw6g0MMfGwDPezkAp+Y7Y6 L8npO5mRalmjOPNie/sbAbtUn20Mc0Vx8QPWiooppS0FTf/Ny/grxHnGO4Xwfd5DXBdk 3mVr0wimffyGmmb0oculQChU7J7ZzgPOfzDmIewUf3mO9UBWcvqoIiAdp1gGhWlnHSkD axKA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693666404; x=1694271204; 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=7/rN6hpA6RUR8xcynsTbN4wgdal1KH5zv5tVJu4j/8A=; b=b1sybVETQX7fA8XvuFcX3oe5dCNoqUJzGA73zEAIHZ0O8PwX4bt/8t4ULwuSCHgcmh t2y/jXy2K2F/YXExLBhAI9oBlaEQB8kY5POfF6n/takBKIsj09OgTPwvyQwCfOCKQz/3 /ms0GgNf3RZXNfkFE/sqK0549jHhMVIyUn5e9UYOpUaTvDCJ9HRL8otV/ujRGCwNEmgV IqNsf6+4D2szh7oDeJPA8Aeh1dwxB1lvpf8+Pfso8fHIbACjqRWzEalJamnInIY1VXGG Uz0N0Icc9AaTFvFcN5yIMTRPfIefj0xKrC0MYDs2RT3k/eE9vEdlEVXXqiRheVuARMy7 hPjQ== X-Gm-Message-State: AOJu0Yw8z6Ui/OZNAjGpG7Yj9SlfSFuY6q4xlN2u8//Mu6jxDj8ltznu 3Wieqw8am0wlqdgBML1kpbjg6HrWnWdPFzIn X-Google-Smtp-Source: AGHT+IHuPAH+s3vDEUBeNHf+SHGGhgDmWY0xoWoMCdZYK1HUGj2hP/+rdG+D0BhoBBGogGXlA6bHCQ== X-Received: by 2002:a5d:4683:0:b0:31c:3013:9fa5 with SMTP id u3-20020a5d4683000000b0031c30139fa5mr4243832wrq.59.1693666403896; Sat, 02 Sep 2023 07:53:23 -0700 (PDT) Received: from fedora.. (cust-west-par-46-193-56-152.cust.wifirst.net. [46.193.56.152]) by smtp.gmail.com with ESMTPSA id cc11-20020a5d5c0b000000b0031f34a395e7sm2385449wrb.45.2023.09.02.07.53.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 02 Sep 2023 07:53:23 -0700 (PDT) From: Joao Marcos Costa To: u-boot@lists.denx.de Cc: trini@konsulko.com, sjg@chromium.org, antoningodard@pm.me, Y.Moog@phytec.de, Joao Marcos Costa Subject: [PATCH v3 5/7] .gitignore: add compile_commands.json Date: Sat, 2 Sep 2023 16:53:08 +0200 Message-ID: <20230902145310.107054-6-jmcosta944@gmail.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230902145310.107054-1-jmcosta944@gmail.com> References: <20230902145310.107054-1-jmcosta944@gmail.com> MIME-Version: 1.0 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 Add Clang's compilation database file (i.e. compile_commands.json) to .gitignore, at the root of the repository. Signed-off-by: Joao Marcos Costa --- .gitignore | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitignore b/.gitignore index 002f95de4f..261a1d6754 100644 --- a/.gitignore +++ b/.gitignore @@ -109,3 +109,6 @@ __pycache__ # moveconfig database /moveconfig.db + +# Clang's compilation database file +/compile_commands.json From patchwork Sat Sep 2 14:53:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Jo=C3=A3o_Marcos_Costa?= X-Patchwork-Id: 1829111 X-Patchwork-Delegate: xypron.glpk@gmx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20221208 header.b=Aof4JyTB; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=patchwork.ozlabs.org) Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4RdHx94fPYz1yfm for ; Sun, 3 Sep 2023 00:54:37 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 73352867B6; Sat, 2 Sep 2023 16:53:32 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="Aof4JyTB"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id BB6138643B; Sat, 2 Sep 2023 16:53:31 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-wr1-x436.google.com (mail-wr1-x436.google.com [IPv6:2a00:1450:4864:20::436]) (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 BC23D8684C for ; Sat, 2 Sep 2023 16:53:25 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=jmcosta944@gmail.com Received: by mail-wr1-x436.google.com with SMTP id ffacd0b85a97d-31c63cd4ec2so2509158f8f.0 for ; Sat, 02 Sep 2023 07:53:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1693666405; x=1694271205; darn=lists.denx.de; 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=0mg1PguG0pB+8AAHRB68FqnT/TXExVQsRcE5ID7CWLA=; b=Aof4JyTB2/FjMLY9Gt+dyH3ahUQLyMeXIkxZVmUwxCTtzt+yuCDwqtGViUOUT/NgF7 E+3tzfMI2he7pclMwYcZQVZF6zhDyfGLvPrtniLU3GAoCfHaGW46nrwkLmuaUsTLEiXw 35hdRPO844XUfrvXIZPaSm2Sc5D2F4t6E9524WPZMV0Q0WqNBQS5Jrzit1v+FB8sX6YR tiihbnwIkCppW9iHUwHBeZfA5hhQLuI08nLgVxHujshXpx4PRDoTW/Je/hX/F+ZW/rsC ANqkTODnDwiGptYil/S9aOy7Rifnjar7ZXV+CbwsfaxrREqdeeevl/8A1Hf0kk4lpciJ L1Gg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693666405; x=1694271205; 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=0mg1PguG0pB+8AAHRB68FqnT/TXExVQsRcE5ID7CWLA=; b=LJFHBIvWJgcFAcNyX5mZg9lIIddEz+3IBf4lToIF1ESmCM4ivbWnae2PfQhOBvG4YN +DngnDNa/n//j4hQLBKKmpqGqLKzledBJ8Vw+7ZV32FZ8U8aRApCO98sHwkO2eG5bPFg Av0YCVr3wbpM0ldpl+vYWIvNKm8H9lRjJ1hF2YMdbH6tTspj/WMk8s2e8HHWzP5Ks1qX vaxf2EOzGUmSuW/f5ymPzPaQXUgBdB0yEdFiHIiG/c2Cj8e8UGhGsxA1C7r03u7iShOu LI7YPDZIjHnv1yfFpyZRWl11Z9m8CuiO5lts1yKNHqGfGmJPT6FzoXskGB/rxKdMf2lr 5pAQ== X-Gm-Message-State: AOJu0YwTOyCHNZJWDHgfedOwbgm7WAZ5p9sjbcRBwwN2EzNquKtUC4wz W8vLO9z43C63rwXlMhzmktI5VRZ6crZeAyz2 X-Google-Smtp-Source: AGHT+IGSZ0O34uRn+I0ZEuUHUMYVnTUzFWsMThh+N0oAZ0vm2xqQ7BkAPNWu0ccgJm5hbCeVhQQC0A== X-Received: by 2002:a5d:5009:0:b0:317:5168:c21f with SMTP id e9-20020a5d5009000000b003175168c21fmr3974512wrt.31.1693666404972; Sat, 02 Sep 2023 07:53:24 -0700 (PDT) Received: from fedora.. (cust-west-par-46-193-56-152.cust.wifirst.net. [46.193.56.152]) by smtp.gmail.com with ESMTPSA id cc11-20020a5d5c0b000000b0031f34a395e7sm2385449wrb.45.2023.09.02.07.53.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 02 Sep 2023 07:53:24 -0700 (PDT) From: Joao Marcos Costa To: u-boot@lists.denx.de Cc: trini@konsulko.com, sjg@chromium.org, antoningodard@pm.me, Y.Moog@phytec.de, Joao Marcos Costa Subject: [PATCH v3 6/7] doc: add documentation for gen_compile_commands.py Date: Sat, 2 Sep 2023 16:53:09 +0200 Message-ID: <20230902145310.107054-7-jmcosta944@gmail.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230902145310.107054-1-jmcosta944@gmail.com> References: <20230902145310.107054-1-jmcosta944@gmail.com> MIME-Version: 1.0 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 This documentation briefly explains what is a compilation database, and how to use the script to generate one. This is not a portage, as there was no original documentation in the Linux sources. Acknowledge the documentation in the script's header and in doc/build index. Signed-off-by: Joao Marcos Costa --- doc/build/gen_compile_commands.rst | 46 ++++++++++++++++++++++++++++++ doc/build/index.rst | 1 + scripts/gen_compile_commands.py | 1 + 3 files changed, 48 insertions(+) create mode 100644 doc/build/gen_compile_commands.rst diff --git a/doc/build/gen_compile_commands.rst b/doc/build/gen_compile_commands.rst new file mode 100644 index 0000000000..6b32eb678a --- /dev/null +++ b/doc/build/gen_compile_commands.rst @@ -0,0 +1,46 @@ +.. SPDX-License-Identifier: GPL-2.0-only + +==================== +gen_compile_commands +==================== + +gen_compile_commands (scripts/gen_compile_commands.py) is a script used to +generate a compilation database (compile_commands.json). This database consists +of an array of "command objects" describing how each translation unit was +compiled. + +Example:: + + { + "command": "gcc -Wp,-MD,arch/x86/cpu/.lapic.o.d -nostdinc -isystem (...)" + "directory": "/home/jmcosta/u-boot", + "file": "/home/jmcosta/u-boot/arch/x86/cpu/lapic.c" + } + +Such information comes from parsing the respective .cmd file of each translation +unit. In the previous example, that would be `arch/x86/cpu/.lapic.o.cmd`. + +The compilation database is quite useful for text editors (and IDEs) that use +Clangd LSP. It allows jumping to definitions and declarations. Since it relies +on parsing .cmd files, one needs to have a target (e.g. configs/xxx_defconfig) +built before running the script. + +Example:: + + make sandbox_defconfig + make + ./scripts/gen_compile_commands.py + +The database will be in the root of the repository. No further modifications are +needed for it to be usable by the LSP, unless you set a name for the database +other than it's default one (compile_commands.json). + +Options +======= + +For further details on how to use the script and its options, please refer to +its help message, as in the example below. + +Help:: + + ./scripts/gen_compile_commands.py --help diff --git a/doc/build/index.rst b/doc/build/index.rst index 64e66491bd..7a4507b574 100644 --- a/doc/build/index.rst +++ b/doc/build/index.rst @@ -14,3 +14,4 @@ Build U-Boot tools buildman documentation + gen_compile_commands diff --git a/scripts/gen_compile_commands.py b/scripts/gen_compile_commands.py index 1a9c49b34a..aa52e88e18 100755 --- a/scripts/gen_compile_commands.py +++ b/scripts/gen_compile_commands.py @@ -5,6 +5,7 @@ # # Author: Tom Roeder # Ported and modified for U-Boot by Joao Marcos Costa +# Briefly documented at doc/build/gen_compile_commands.rst # """A tool for generating compile_commands.json in U-Boot.""" From patchwork Sat Sep 2 14:53:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Jo=C3=A3o_Marcos_Costa?= X-Patchwork-Id: 1829110 X-Patchwork-Delegate: xypron.glpk@gmx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20221208 header.b=CUnm6fco; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=patchwork.ozlabs.org) Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4RdHwy4Pkgz1yfm for ; Sun, 3 Sep 2023 00:54:26 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 2F97D868BB; Sat, 2 Sep 2023 16:53:31 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="CUnm6fco"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 55426868B1; Sat, 2 Sep 2023 16:53:30 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-wr1-x42f.google.com (mail-wr1-x42f.google.com [IPv6:2a00:1450:4864:20::42f]) (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 8B9AA86898 for ; Sat, 2 Sep 2023 16:53:26 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=jmcosta944@gmail.com Received: by mail-wr1-x42f.google.com with SMTP id ffacd0b85a97d-31c8321c48fso512787f8f.1 for ; Sat, 02 Sep 2023 07:53:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1693666406; x=1694271206; darn=lists.denx.de; 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=qngk3U/RoGV31BGndtOspXrBHoqZK19EQiCz8M+Ehv8=; b=CUnm6fco7ZKaeo9G68gv8wGAJdvqaNJPK5v5n7dm27QOwQgtq3e4qKtVjf1rzW4N9k Rdracu1rXCA2de4+tUVRLa2Of1tugOekLzVBCyjH88W5TbtiA42wQmrv6oGr3XIvgQb9 fKc4/iy3erulSMRXDVGhW4ZwgveY4r7kVaAQ35X14xMD7AL/8i6Mtkj7uYqlx78PS29t VKqViX9RDyUkrO+nC5x0MCbh9TFo95nOBXPbrvwdC74cJbXo9inEZnVpWKc6Q1y/9hGX cAkVt9EkltdeZoyawILp1WdFyNvLUytYSSlugzHAQ4QdnNa1AoMHeY8YlM41uJvg7sI3 IoPw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693666406; x=1694271206; 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=qngk3U/RoGV31BGndtOspXrBHoqZK19EQiCz8M+Ehv8=; b=iIpp1J9NEeoXGGlrt20xalrYSYG/xnuq/A0l1spRR51C2QqhIAom4gNMXhS+bl2406 +H7ffuDZBJBeN18+QHKQaMAPOu4dWa5kDztgF9lEC+QjgLqLmddvShx9QpHvpoxhGNQ5 mFXC47R8DGq/nWdGZmVfcNu+DcNPrZ2UwLRSECIejdJjxi86TaGX+dZ6JjuRHfIwpNwI GlnEM8TLVu4ozqFZ+Jelb8WuBtPdNB0R8PB3/mgr3tGJmDZGJLhJvMKjOZBpJA226aG2 AX5fKcFUxMhiRPmQOhJyhaoWUFoN0WxMHog2WdxZku5xhn2P3Fn2wkiErHFHiCFuHtGU i2iA== X-Gm-Message-State: AOJu0YxABze+ySoJEh9Ay1/e1et4zwOcUruqjqBvAlb3VYa8H48NhejX TWXlE+r6EJVp+RLERIUIYVcKGBvpqNNfICW4 X-Google-Smtp-Source: AGHT+IHggyYQCmhvv1KfuExu6nHy/rLm6g66W6q0lKSlInt8smnrSFjd8m3Xn/yENDONOmJq2hpnPw== X-Received: by 2002:adf:ee90:0:b0:319:6b56:94d9 with SMTP id b16-20020adfee90000000b003196b5694d9mr4887573wro.2.1693666405778; Sat, 02 Sep 2023 07:53:25 -0700 (PDT) Received: from fedora.. (cust-west-par-46-193-56-152.cust.wifirst.net. [46.193.56.152]) by smtp.gmail.com with ESMTPSA id cc11-20020a5d5c0b000000b0031f34a395e7sm2385449wrb.45.2023.09.02.07.53.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 02 Sep 2023 07:53:25 -0700 (PDT) From: Joao Marcos Costa To: u-boot@lists.denx.de Cc: trini@konsulko.com, sjg@chromium.org, antoningodard@pm.me, Y.Moog@phytec.de, Joao Marcos Costa Subject: [PATCH v3 7/7] doc: add new section to build/tools Date: Sat, 2 Sep 2023 16:53:10 +0200 Message-ID: <20230902145310.107054-8-jmcosta944@gmail.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230902145310.107054-1-jmcosta944@gmail.com> References: <20230902145310.107054-1-jmcosta944@gmail.com> MIME-Version: 1.0 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 Add 'Integration with IDEs' section. For now, this section is mostly a reference to the documentation of gen_compile_commands, also in doc/build, but it can be futurely used as a guide for other IDE-friendly features. Signed-off-by: Joao Marcos Costa --- doc/build/gen_compile_commands.rst | 1 + doc/build/tools.rst | 13 +++++++++++++ 2 files changed, 14 insertions(+) diff --git a/doc/build/gen_compile_commands.rst b/doc/build/gen_compile_commands.rst index 6b32eb678a..da812525fe 100644 --- a/doc/build/gen_compile_commands.rst +++ b/doc/build/gen_compile_commands.rst @@ -1,4 +1,5 @@ .. SPDX-License-Identifier: GPL-2.0-only +.. _gen-compile-commands-label: ==================== gen_compile_commands diff --git a/doc/build/tools.rst b/doc/build/tools.rst index ec01722925..5cdbf27d83 100644 --- a/doc/build/tools.rst +++ b/doc/build/tools.rst @@ -45,3 +45,16 @@ Launch the MSYS2 shell of the MSYS2 environment, and do the following:: $ make tools-only_defconfig $ make tools-only + +Integration with IDEs +--------------------- + +IDEs and text editors (e.g., VSCode, Emacs, Vim, Neovim) typically offer +plugins to enhance the development experience, such as Clangd LSP. These +plugins provide features like code navigation (i.e., jumping to definitions +and declarations), code completion, and code formatting. + +U-Boot provides a script (i.e., scripts/gen_compile_commands.py) that +generates a compilation database to be utilized by Clangd LSP for code +navigation. For detailed usage instructions, please refer to the script's +documentation: :ref:`gen-compile-commands-label`.