Kaydet (Commit) 071c09d7 authored tarafından Markus Mohrhard's avatar Markus Mohrhard Kaydeden (comit) Markus Mohrhard

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/10820Reviewed-by: 's avatarMarkus Mohrhard <markus.mohrhard@googlemail.com>
Tested-by: 's avatarMarkus Mohrhard <markus.mohrhard@googlemail.com>
üst d4801c45
......@@ -340,8 +340,10 @@ $(1)-ide-integration:
endef
$(foreach ide,\
debug \
kdevelop \
vs2012 \
vim \
xcode, \
$(eval $(call gb_Top_GbuildToIdeIntegration,$(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)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment