[Libreoffice-commits] core.git: 2 commits - bin/gbuild-to-ide Makefile.in

Markus Mohrhard markus.mohrhard at collabora.co.uk
Mon Aug 11 05:40:46 PDT 2014


 Makefile.in       |    2 ++
 bin/gbuild-to-ide |   44 +++++++++++++++++++++++++++++++++++++++++++-
 2 files changed, 45 insertions(+), 1 deletion(-)

New commits:
commit 6d5e69072e7c37f8ff4adb49062218ab17373e7d
Author: Markus Mohrhard <markus.mohrhard at collabora.co.uk>
Date:   Thu Aug 7 23:06:22 2014 +0200

    write directly files understood by YCM
    
    Change-Id: I262050f625a0b3ff04a274c88b446d1c2b2aa19d
    Reviewed-on: https://gerrit.libreoffice.org/10821
    Reviewed-by: Markus Mohrhard <markus.mohrhard at googlemail.com>
    Tested-by: Markus Mohrhard <markus.mohrhard at googlemail.com>

diff --git a/bin/gbuild-to-ide b/bin/gbuild-to-ide
index 0e9ab7c..f005cf2 100755
--- a/bin/gbuild-to-ide
+++ b/bin/gbuild-to-ide
@@ -236,7 +236,7 @@ class VimIntegrationGenerator(IdeIntegrationGenerator):
                 entry = {'directory': lib.location, 'file': filePath, 'command': self.generateCommand(lib, filePath)}
                 entries.append(entry)
             global_list.extend(entries)
-        export_file = open('database.txt','w') 
+        export_file = open('compile_commands.json','w') 
         json.dump(global_list, export_file)
 
     def generateCommand(self, lib, file):
commit 071c09d7d9092a83194ae9d5082cde6ca4ef87ce
Author: Markus Mohrhard <markus.mohrhard at collabora.co.uk>
Date:   Thu Aug 7 22:11:50 2014 +0200

    add a IDE generator for clang json database format
    
    This can be used for YouCompleteMe a vim plugin that allows
    auto-completition based on clang. This is much better than the normal
    static analyzer based auto-completition.
    
    Change-Id: I4872d2cb3b3a404af55eacf5c71d6a2715771ab6
    Reviewed-on: https://gerrit.libreoffice.org/10820
    Reviewed-by: Markus Mohrhard <markus.mohrhard at googlemail.com>
    Tested-by: Markus Mohrhard <markus.mohrhard at googlemail.com>

diff --git a/Makefile.in b/Makefile.in
index 0c9893c..3de0845 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -340,8 +340,10 @@ $(1)-ide-integration:
 endef
 
 $(foreach ide,\
+	debug \
 	kdevelop \
 	vs2012 \
+	vim \
 	xcode, \
 $(eval $(call gb_Top_GbuildToIdeIntegration,$(ide))))
 
diff --git a/bin/gbuild-to-ide b/bin/gbuild-to-ide
index fcc1236..0e9ab7c 100755
--- a/bin/gbuild-to-ide
+++ b/bin/gbuild-to-ide
@@ -15,6 +15,7 @@ import shutil
 import re
 import sys
 import uuid
+import json
 import xml.etree.ElementTree as ET
 
 
@@ -222,6 +223,43 @@ class DebugIntegrationGenerator(IdeIntegrationGenerator):
             print(exe)
 
 
+class VimIntegrationGenerator(IdeIntegrationGenerator):
+    def __init__(self, gbuildparser):
+        IdeIntegrationGenerator.__init__(self, gbuildparser)
+
+    def emit(self):
+        global_list = []
+        for lib in self.gbuildparser.libs:
+            entries = []
+            for file in lib.cxxobjects:
+                filePath = os.path.join(self.gbuildparser.srcdir, file) + ".cxx"
+                entry = {'directory': lib.location, 'file': filePath, 'command': self.generateCommand(lib, filePath)}
+                entries.append(entry)
+            global_list.extend(entries)
+        export_file = open('database.txt','w') 
+        json.dump(global_list, export_file)
+
+    def generateCommand(self, lib, file):
+        command = 'clang++ '
+        for key, value in lib.defs.items():
+            command += ' -D'
+            command += key
+            if value is not None:
+                command += '='
+                command += value
+        for include in lib.include:
+            command += ' -I'
+            command += include
+        for isystem in lib.include_sys:
+            command += ' -isystem '
+            command += isystem
+        for cxxflag in lib.cxxflags:
+            command += ' '
+            command += cxxflag
+        command += ' -c '
+        command += file
+        return command
+
 class KdevelopIntegrationGenerator(IdeIntegrationGenerator):
     def encode_int(self, i):
         temp = '%08x' % i
@@ -838,13 +876,17 @@ if __name__ == '__main__':
         gbuildparser = GbuildParser().parse(open(args.input, 'r'))
     else:
         gbuildparser = GbuildParser().parse(sys.stdin)
-    #DebugIntegrationGenerator(gbuildparser).emit()
+
     if args.ide == 'kdevelop':
         KdevelopIntegrationGenerator(gbuildparser).emit()
     elif args.ide == 'xcode':
         XcodeIntegrationGenerator(gbuildparser).emit()
     elif args.ide == 'vs2012':
         VisualStudioIntegrationGenerator(gbuildparser).emit()
+    elif args.ide == 'vim':
+        VimIntegrationGenerator(gbuildparser).emit()
+    elif args.ide == 'debug':
+        DebugIntegrationGenerator(gbuildparser).emit()
     else:
         parser.print_help()
         sys.exit(1)


More information about the Libreoffice-commits mailing list