Skip to content

Commit

Permalink
btrfs-progs: build: add target to generate compile_commands.json
Browse files Browse the repository at this point in the history
To support LSP in editors add a convenience command to generate the
commands that eg. clangd uses to generate it's database. This requires
the Bear tool to scan build. Compilation can be done by gcc or clang,
only the .json needs the explicit CC=clang. LSP is sensitive to the
CFLAGS.

Signed-off-by: David Sterba <[email protected]>
  • Loading branch information
kdave committed Jan 7, 2025
1 parent 772e951 commit 084d50d
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -875,6 +875,17 @@ test-build-real:
manpages:
$(Q)$(MAKE) $(MAKEOPTS) -C Documentation

# Generate database for LSP. This depends on Bear and clang, gcc can be used
# for compilation though.
compile_commands.json: FORCE
@if ! type -p bear 2>/dev/null; then echo "ERROR: please install bear (https://github.com/rizsotto/Bear)"; exit 1; fi
@if ! test -f config.status; then echo "ERROR: please configure first and build with CC=clang"; exit 1; fi
@-rm -- $@
@echo "Clean before generating $@"
@$(MAKE) clean
@echo "Capture build commmands and generate $@"

Check failure on line 886 in Makefile

View workflow job for this annotation

GitHub Actions / Check for spelling errors

commmands ==> commands
@bear -- $(MAKE) CC=clang

tags: FORCE
@echo " TAGS $(TAGS_CMD)"
$(Q)$(TAGS_CMD) *.[ch] image/*.[ch] convert/*.[ch] mkfs/*.[ch] \
Expand Down

0 comments on commit 084d50d

Please sign in to comment.