[libgit2-glib] Better detection of libclang



commit 6f07b7ffd863a4851b8fd8300858576a0df4958a
Author: Jesse van den Kieboom <jessevdk gmail com>
Date:   Sat Nov 23 13:24:58 2013 +0100

    Better detection of libclang

 tools/coverage.py |   22 +++++++++++++++-------
 1 files changed, 15 insertions(+), 7 deletions(-)
---
diff --git a/tools/coverage.py b/tools/coverage.py
index 85dd75e..12110eb 100755
--- a/tools/coverage.py
+++ b/tools/coverage.py
@@ -1,21 +1,29 @@
 #!/usr/bin/env python3
 
-import os, sys, glob, pickle
+import os, sys, glob, pickle, subprocess
 
 sys.path.insert(0, os.path.dirname(__file__))
 from clang import cindex
 sys.path = sys.path[1:]
 
 def configure_libclang():
-    llvm_libdir = '/usr/lib/llvm-3.2/lib'
+    llvm_libdirs = ['/usr/lib/llvm-3.2/lib']
 
-    libdir = llvm_libdir
-    cindex.Config.set_library_path(libdir)
+    try:
+        libdir = subprocess.check_output(['llvm-config', '--libdir']).decode('utf-8')
+        llvm_libdirs.insert(0, libdir)
+    except:
+        pass
+
+    for d in llvm_libdirs:
+        if not os.path.exists(d):
+            continue
 
-    files = glob.glob(os.path.join(libdir, 'libclang.so*'))
+        files = glob.glob(os.path.join(d, 'libclang.so*'))
 
-    if len(files) != 0:
-        cindex.Config.set_library_file(files[0])
+        if len(files) != 0:
+            cindex.Config.set_library_file(files[0])
+            return
 
 class Call:
     def __init__(self, cursor, decl):


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]