Re: [PATCH 3/3] build: add compile_commands.json target
Anthony PERARD <[email protected]> Thu, 6 Aug 2026 15:48:08 +0200
| Newsgroups | gmane.comp.emulators.xen.devel |
|---|---|
| Message-ID | <1786024089.8631fc262581453bbf619ec5b2062170.19fd754d83e000e099@vates.tech> |
On Wed, Aug 05, 2026 at 11:52:40AM +1000, George Dunlap wrote: > Add a phony convenience target generating the compilation database "phony convenience target", that a funny way to put it :-) the target isn't phony, it just use the Make keyword "phony" to have it ignore the existing target. > from a built object tree, alongside the other developer conveniences > (tags, cscope, cloc -- the last of which already walks the same .cmd > files): > > make -C xen compile_commands.json > > The output lands in the object tree root, where clangd and other > consumers discover it automatically when opening files from an > in-tree build. What about out-of-tree build? :-) that first part of the sentence almost seems to acknowledge their existence. Anyway, one can create a symlink. > Note the database records the compiler invocations actually used. > With a clang build it is consumable by clangd as-is; for a gcc build, > clang-based tools may need a small .clangd configuration > (CompileFlags: Remove/Add) dropping gcc-only flags. > > Also add the generated file to .gitignore. > > Assisted-by: LLM > Signed-off-by: George Dunlap <[email protected]> > --- > .gitignore | 1 + > xen/Makefile | 4 ++++ > 2 files changed, 5 insertions(+) > > diff --git a/.gitignore b/.gitignore > index bfc7bdf043..0aa9b801de 100644 > --- a/.gitignore > +++ b/.gitignore > @@ -192,6 +192,7 @@ xen/arch/*/include/generated > xen/build-dir-cppcheck/ > xen/common/config_data.S > xen/common/config.gz > +xen/compile_commands.json > xen/cppcheck-htmlreport/ > xen/cppcheck-report/ > xen/cppcheck-misra.* > diff --git a/xen/Makefile b/xen/Makefile > index d39bdfdd53..f87240f33c 100644 > --- a/xen/Makefile > +++ b/xen/Makefile > @@ -685,6 +685,10 @@ cloc: > done; \ > done | cloc --list-file=- > > +.PHONY: compile_commands.json > +compile_commands.json: Could you use FORCE instead .PHONY? That is just: +compile_commands.json: FORCE Thanks, -- Anthony Perard | Vates XCP-ng Developer XCP-ng & Xen Orchestra - Vates solutions web: https://vates.tech