[dm-devel] [PATCH 3/3] multipath-tools: support generating compile_commands.json

mwilck at suse.com mwilck at suse.com
Fri Nov 12 21:05:51 UTC 2021


From: Martin Wilck <mwilck at suse.com>

This file is necessary to run clangd as helper for an IDE, e.g.
with emacs lsp-mode.

Signed-off-by: Martin Wilck <mwilck at suse.com>
---
 .gitignore | 1 +
 Makefile   | 6 ++++++
 2 files changed, 7 insertions(+)

diff --git a/.gitignore b/.gitignore
index 5dbac39..8e09f95 100644
--- a/.gitignore
+++ b/.gitignore
@@ -17,6 +17,7 @@ mpathpersist/mpathpersist
 abi.tar.gz
 abi
 abi-test
+compile_commands.json
 .nfs*
 *.swp
 *.patch
diff --git a/Makefile b/Makefile
index 1cec777..82e0ea3 100644
--- a/Makefile
+++ b/Makefile
@@ -66,6 +66,12 @@ abi-test:	abi reference-abi $(wildcard abi/*.abi)
 	fi; \
 	[ $$err -eq 0 ]
 
+# Create compile_commands.json, useful for using clangd with an IDE
+# Requires bear (https://github.com/rizsotto/Bear)
+compile_commands.json: Makefile Makefile.inc $(BUILDDIRS:=/Makefile)
+	$(MAKE) clean
+	bear -- $(MAKE)
+
 libmultipath libdmmp: libmpathcmd
 libmpathpersist libmpathvalid multipath multipathd: libmultipath
 libmultipath/prioritizers libmultipath/checkers libmultipath/foreign: libmultipath
-- 
2.33.1





More information about the dm-devel mailing list