All of lore.kernel.org
 help / color / mirror / Atom feed
From: Hu Weiwen <huww98@outlook.com>
To: Nick Desaulniers <ndesaulniers@google.com>
Cc: llvm@lists.linux.dev, Nathan Chancellor <nathan@kernel.org>,
	Tom Rix <trix@redhat.com>,
	Linux Kbuild mailing list <linux-kbuild@vger.kernel.org>,
	Masahiro Yamada <masahiroy@kernel.org>,
	Hu Weiwen <huww98@outlook.com>
Subject: [PATCH v2] gen_compile_commands: include targets not ending with .o
Date: Thu, 25 May 2023 20:20:03 +0800	[thread overview]
Message-ID: <OSZP286MB20611C35BF36F4EB69FD3DF6C0469@OSZP286MB2061.JPNP286.PROD.OUTLOOK.COM> (raw)
In-Reply-To: <TYCP286MB2066DEF0E1810E8BC36F533EC07B9@TYCP286MB2066.JPNP286.PROD.OUTLOOK.COM>

Currently, we only extract commands for targets ending with '.o'. But we
also have many standalone executables built in-tree.

Remove this restriction. And to avoid some false matching, exclude
targets end with '.c' or '.h' when directly walking the directory.

To really generate compile_commands.json that includes such target, call
this script directly with no arguments.  `make compile_commands.json`
will not include them.

Signed-off-by: Hu Weiwen <huww98@outlook.com>
---
Since V1: Only commit message is updated.

 scripts/clang-tools/gen_compile_commands.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/scripts/clang-tools/gen_compile_commands.py b/scripts/clang-tools/gen_compile_commands.py
index 15ba56527acd..6e88c7e166fc 100755
--- a/scripts/clang-tools/gen_compile_commands.py
+++ b/scripts/clang-tools/gen_compile_commands.py
@@ -18,8 +18,8 @@ import sys
 _DEFAULT_OUTPUT = 'compile_commands.json'
 _DEFAULT_LOG_LEVEL = 'WARNING'
 
-_FILENAME_PATTERN = r'^\..*\.cmd$'
-_LINE_PATTERN = r'^savedcmd_[^ ]*\.o := (.* )([^ ]*\.c) *(;|$)'
+_FILENAME_PATTERN = r'^\..*(?<!\.(c|h))\.cmd$'
+_LINE_PATTERN = r'^savedcmd_[^ ]* := (.* )([^ ]*\.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.
-- 
2.25.1


  parent reply	other threads:[~2023-05-25 12:20 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-14 10:19 [PATCH] gen_compile_commands: include targets not end with .o Hu Weiwen
2023-05-24 19:10 ` Nick Desaulniers
2023-05-25  9:52   ` 胡玮文
2023-05-25 12:20 ` Hu Weiwen [this message]
2023-05-29 10:13   ` [PATCH v2] gen_compile_commands: include targets not ending " Masahiro Yamada
2023-05-30  9:04     ` 胡玮文
2023-06-02  9:38       ` Masahiro Yamada

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=OSZP286MB20611C35BF36F4EB69FD3DF6C0469@OSZP286MB2061.JPNP286.PROD.OUTLOOK.COM \
    --to=huww98@outlook.com \
    --cc=linux-kbuild@vger.kernel.org \
    --cc=llvm@lists.linux.dev \
    --cc=masahiroy@kernel.org \
    --cc=nathan@kernel.org \
    --cc=ndesaulniers@google.com \
    --cc=trix@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.