build: add compile_commands.json target

Add a convenience target generating the compilation database 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.  For an in-tree build,
clangd and other consumers discover it there automatically when
opening files; for an out-of-tree build, symlink it into the source
tree root (consumers search the ancestors of the file being edited).

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 <gwd@xenproject.org>
Reviewed-by: Anthony PERARD <anthony.perard@vates.tech>
This commit is contained in:
George Dunlap authored and Anthony PERARD committed 2026-08-11 11:07:16 +02:00
1 parent 79ea30888d
commit ad82632486
2 files changed
+4

No files matched your search

+1
View File
@@ -192,6 +192,7 @@ xen/arch/*/include/generated
xen/build-dir-cppcheck/ xen/build-dir-cppcheck/
xen/common/config_data.S xen/common/config_data.S
xen/common/config.gz xen/common/config.gz
xen/compile_commands.json
xen/cppcheck-htmlreport/ xen/cppcheck-htmlreport/
xen/cppcheck-report/ xen/cppcheck-report/
xen/cppcheck-misra.* xen/cppcheck-misra.*
+3
View File
@@ -685,6 +685,9 @@ cloc:
done; \ done; \
done | cloc --list-file=- done | cloc --list-file=-
compile_commands.json: FORCE
$(PYTHON) $(srctree)/scripts/gen_compile_commands.py -d $(objtree)
# Target used by xen-analysis.sh script to retrieve Xen build system variables # Target used by xen-analysis.sh script to retrieve Xen build system variables
export-variable-%: export-variable-%:
$(info $*=$($*)) $(info $*=$($*))
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.