[Libreoffice-commits] online.git: .gitignore Makefile.am

Henry Castro (via logerrit) logerrit at kemper.freedesktop.org
Fri Apr 17 12:41:50 UTC 2020


 .gitignore  |    1 +
 Makefile.am |   42 ++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 43 insertions(+)

New commits:
commit 5bc712c9176ab5fbaed31c8a9ba1a8cbb17f5cc5
Author:     Henry Castro <hcastro at collabora.com>
AuthorDate: Sat Apr 4 16:19:07 2020 -0400
Commit:     Henry Castro <hcastro at collabora.com>
CommitDate: Fri Apr 17 14:41:32 2020 +0200

    loolwsd: generate compile_commands.js
    
    Very useful with vim plugin YouCompleteMe
    with libclang C-family Semantic Completion
    
    Change-Id: I9dfa9b16c5eb11c410d26e21086283c142a57228
    Reviewed-on: https://gerrit.libreoffice.org/c/online/+/91860
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice at gmail.com>
    Reviewed-by: Henry Castro <hcastro at collabora.com>

diff --git a/.gitignore b/.gitignore
index 77bc70bb5..fdad6cbba 100644
--- a/.gitignore
+++ b/.gitignore
@@ -34,6 +34,7 @@ stamp-h1
 m4
 debian/loolwsd.postinst
 common/support-public-key.hpp
+compile_commands.json
 
 # Test stuff
 systemplate
diff --git a/Makefile.am b/Makefile.am
index bc2aa55ba..ff7ad0b5f 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -106,6 +106,8 @@ if ENABLE_SSL
 shared_sources += net/Ssl.cpp
 endif
 
+shared_json = $(patsubst %.cpp,%.cmd,$(shared_sources))
+
 loolwsd_sources = common/Crypto.cpp \
                   wsd/Admin.cpp \
                   wsd/AdminModel.cpp \
@@ -118,6 +120,8 @@ loolwsd_sources = common/Crypto.cpp \
                   wsd/TileCache.cpp \
                   wsd/ProofKey.cpp
 
+loolwsd_json = $(patsubst %.cpp,%.cmd,$(loolwsd_sources))
+
 loolwsd_SOURCES = $(loolwsd_sources) \
                   $(shared_sources)
 
@@ -153,6 +157,8 @@ loolforkit_sources = kit/ChildSession.cpp \
                      kit/ForKit.cpp \
                      kit/Kit.cpp
 
+loolforkit_json = $(patsubst %.cpp,%.cmd,$(loolforkit_sources))
+
 loolforkit_SOURCES = $(loolforkit_sources) \
                      $(shared_sources)
 
@@ -325,6 +331,7 @@ $(SYSTEM_STAMP) : ${top_srcdir}/loolwsd-systemplate-setup
 clean-local:
 	if test "z at JAILS_PATH@" != "z"; then rm -rf "@JAILS_PATH@"; fi
 	if test "z at SYSTEMPLATE_PATH@" != "z"; then rm -rf "@SYSTEMPLATE_PATH@"; fi
+	rm -f $(abs_srcdir)/compile_commands.json
 
 run: all @JAILS_PATH@
 	@echo "Launching loolwsd"
@@ -457,3 +464,38 @@ endif
 build-nocheck: all-am
 
 endif
+
+define file_target
+$(1): $(2)
+
+endef
+
+define file_targets
+$(foreach file,$(1),$(call file_target,$(file),$(patsubst %.cmd,%.cpp,$(file))))
+endef
+
+CLANGXX_COMPILE_FLAGS=clang++ $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
+	$(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
+
+JSON_COMPILE_FLAGS=$(subst ",\",$(subst \,\\,$(CLANGXX_COMPILE_FLAGS)))
+
+JSON_COMPILE_SRC = $(loolwsd_json) $(loolforkit_json) $(shared_json)
+
+$(eval $(call file_targets,$(JSON_COMPILE_SRC)))
+
+.cpp.cmd:
+	@echo -n "{\"directory\":\"$(abs_builddir)\",\"command\":\"" > $@
+	@echo -n $(JSON_COMPILE_FLAGS) >> $@
+	@echo -n "\",\"file\":\"$<\"}" >> $@
+
+$(abs_srcdir)/compile_commands.json: $(JSON_COMPILE_SRC)
+	@echo -n "[" > $@
+	@for file in $(JSON_COMPILE_SRC) ; \
+	do \
+		cat $$file; \
+		echo ","; \
+		rm -f $$file; \
+	done >> $@
+	@echo -n "]" >> $@
+
+compile_commands: $(abs_srcdir)/compile_commands.json


More information about the Libreoffice-commits mailing list