Re: [PATCH v1] clang_tools:gen_compile_commands: Change the default source directory

From: Masahiro Yamada
Date: Sat Feb 13 2021 - 07:49:54 EST


On Fri, Feb 12, 2021 at 8:20 PM Stephen Zhang <stephenzhangzsd@xxxxxxxxx> wrote:
>
> Masahiro Yamada <masahiroy@xxxxxxxxxx> 于2021年2月11日周四 下午10:16写道:
> > Please stop.
> >
> >
> > Commit 6ca4c6d25949117dc5b4845612e290b6d89e70a8
> > removed the tools/ support.
> >
> >
> > There exist two build systems in the Linux source tree.
> > Kbuild covers the entire tree except tools/.
> > The tools/ directory adopts a different build system.
> >
> > It is a pity that the tools/ directory
> > went in a wrong direction, and people
> > try to fix problems in a wrong layer.
> >
> >
> > You are not the first person to send to
> > tweak obj/source trees of this script.
> >
> > You can not do this correctly
> > without terribly messing up the code.
> >
> > Please do not try to support tools/.
> >
> >
> >
> > --
> > Best Regards
> > Masahiro Yamada
>
> Thanks for the suggestion.But what we try to support is scripts/
> instead of tools/. 'tools/' here is to help explaining the problem.
> Or am I just misunderstanding your words?



You took 'tools/perf' as an example,
so I just thought you were trying to fix the tools/.



I can get scripts/ entries without any problem.

If you do O= build, you can pass that directory
to the -d option of gen_compile_commands.py

-d DIRECTORY, --directory DIRECTORY
specify the output directory used for the
kernel build (defaults to the working
directory)


This is the steps I tested.


masahiro@oscar:~/ref/linux$ make O=build defconfig all -j24
[ snip ]
masahiro@oscar:~/ref/linux$
./scripts/clang-tools/gen_compile_commands.py -d build
masahiro@oscar:~/ref/linux$ grep '"file":' compile_commands.json |
grep scripts/ | head -n5
"file": "/home/masahiro/ref/linux/scripts/mod/empty.c"
"file": "/home/masahiro/ref/linux/scripts/mod/sumversion.c"
"file": "/home/masahiro/ref/linux/scripts/mod/file2alias.c"
"file": "/home/masahiro/ref/linux/scripts/mod/modpost.c"
"file": "/home/masahiro/ref/linux/build/scripts/kconfig/parser.tab.c"








--
Best Regards
Masahiro Yamada