Re: [PATCH v2] gen_compile_commands: include targets not ending with .o

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, May 29, 2023 at 07:13:46PM +0900, Masahiro Yamada wrote:
> On Thu, May 25, 2023 at 9:21 PM Hu Weiwen <huww98@xxxxxxxxxxx> wrote:
> >
> > 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.
> 
> 
> Can you give me some examples of false matching?

Examples:
- drivers/scsi/scsi_devinfo_tbl.c: generated by
  sed -n 's/.*define *BLIST_\\([A-Z0-9_]*\\) *.*/BLIST_FLAG_NAME(\\1),/p' include/scsi/scsi_devinfo.h > drivers/scsi/scsi_devinfo_tbl.c

- arch/x86/entry/vdso/vdso-image-32.c: generated by
  arch/x86/entry/vdso/vdso2c arch/x86/entry/vdso/vdso32.so.dbg arch/x86/entry/vdso/vdso32.so arch/x86/entry/vdso/vdso-image-32.c

I think only .c file targets would have false matching, because the cmd
must ends with '.c' to be matched.

> 
> Also, this patch would pick up *.i, *.s, *.lst, etc.
> 
> Does it make sense to parse cmd files for those?
> I guess the answer is no.

We are already parsing cmd files for those before this patch. I use more
strict `_FILENAME_PATTERN'. But it may be hard to exclude all of these
by filename.

Should we use a more strict `_LINE_PATTERN'? e.g., require the cmd to
begin with a compiler, not `sed' or something else. But we don't know
the compiler name, adding a parameter for compiler name may break the
existing usage.

> >
> > 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@xxxxxxxxxxx>
> > ---
> > 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
> >
> 
> 
> -- 
> Best Regards
> Masahiro Yamada



[Index of Archives]     [Linux&nblp;USB Development]     [Linux Media]     [Video for Linux]     [Linux Audio Users]     [Yosemite Secrets]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux