[gnome-code-assistance] Add global system include dir if found
- From: Jesse van den Kieboom <jessevdk src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-code-assistance] Add global system include dir if found
- Date: Tue, 24 Jun 2014 19:49:17 +0000 (UTC)
commit 3e250d6bed5f0aa2f56c4ef8ceed5aaa64c3dffa
Author: Jesse van den Kieboom <jessevdk gnome org>
Date: Tue Jun 24 21:48:59 2014 +0200
Add global system include dir if found
backends/c/service.py | 19 ++++++++++++++++++-
1 files changed, 18 insertions(+), 1 deletions(-)
---
diff --git a/backends/c/service.py b/backends/c/service.py
index fb78860..9e7fde1 100644
--- a/backends/c/service.py
+++ b/backends/c/service.py
@@ -19,12 +19,14 @@ from gnome.codeassistance.c import clangimporter, makefileintegration, config
from gnome.codeassistance import transport, types
import clang.cindex as cindex
-import glob, os
+import glob, os, subprocess
_did_libclang_config = False
+_global_sysinclude = None
def config_libclang():
global _did_libclang_config
+ global _global_sysinclude
if _did_libclang_config:
return
@@ -39,6 +41,13 @@ def config_libclang():
if len(files) != 0:
cindex.Config.set_library_file(files[0])
+ try:
+ _global_sysinclude = subprocess.check_output(['llvm-clang', '-print-file-name=include']).strip()
+ except:
+ pass
+
+ print(_global_sysinclude)
+
class Service(transport.Service, transport.Project):
language = 'c'
@@ -54,8 +63,15 @@ class Service(transport.Service, transport.Project):
if (not doc.tu is None) and not self.makefile.changed_for_file(doc.path):
doc.tu.reparse(unsaved)
else:
+ global _global_sysinclude
+
args = self.makefile.flags_for_file(doc.path)
+ if not _global_sysinclude is None:
+ args = list(args)
+ args.append('-isystem')
+ args.append(_global_sysinclude)
+
doc.tu = cindex.TranslationUnit.from_source(doc.path,
args=args,
unsaved_files=unsaved,
@@ -112,6 +128,7 @@ class Service(transport.Service, transport.Project):
resolved = {}
for d in tu.diagnostics:
+ print(d)
if d.location is None or d.location.file is None:
continue
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]