summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorMarkus Mohrhard <markus.mohrhard@collabora.co.uk>2014-08-07 22:11:50 +0200
committerMarkus Mohrhard <markus.mohrhard@googlemail.com>2014-08-11 12:40:22 +0000
commit071c09d7d9092a83194ae9d5082cde6ca4ef87ce (patch)
tree8e507224c709c65d5682089384957d205aefedc0 /bin
parentd4801c45caa05585c14f800e2dfe2cfc8642499d (diff)
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@googlemail.com> Tested-by: Markus Mohrhard <markus.mohrhard@googlemail.com>
Diffstat (limited to 'bin')
-rwxr-xr-xbin/gbuild-to-ide44
1 files changed, 43 insertions, 1 deletions
diff --git a/bin/gbuild-to-ide b/bin/gbuild-to-ide
index fcc12360bc24..0e9ab7c43daa 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)