File tree 1 file changed +15
-3
lines changed
1 file changed +15
-3
lines changed Original file line number Diff line number Diff line change 4
4
#
5
5
import os
6
6
import sys
7
+ import re
7
8
8
9
from clang .cindex import *
9
10
@@ -82,12 +83,20 @@ def findLibClang():
82
83
else :
83
84
# Unsupported platform
84
85
return None
85
-
86
+
86
87
for path in knownPaths :
87
88
# print("trying " + path)
88
89
if os .path .exists (path + "/libclang" + libSuffix ):
89
90
return path
90
-
91
+ elif (sys .platform == "win32" or sys .platform == "msys" ):
92
+ # Check for versioned and non-versioned libclang.dll if on msys
93
+ pattern = re .compile (r'^libclang(-\d+(\.\d+)?)?\.dll$' )
94
+ if os .path .exists (path ):
95
+ for filename in os .listdir (path ):
96
+ if pattern .match (filename ):
97
+ return os .path .join (path , filename )
98
+
99
+ # If no known path is found
91
100
return None
92
101
93
102
def initLibClang ():
@@ -100,13 +109,16 @@ def initLibClang():
100
109
Config .set_library_path (library_path )
101
110
else :
102
111
Config .set_library_file (library_path )
112
+ else :
113
+ print ("WARN (find_clang): libclang path not found" , file = sys .stderr )
103
114
104
115
Config .set_compatibility_check (False )
105
116
106
117
try :
107
118
index = Index .create ()
108
119
except Exception as e :
109
- print ("ERROR: could not load libclang from '%s'." % library_path , file = sys .stderr )
120
+ print ("ERROR (find_clang): could not load libclang from '%s'." % library_path , file = sys .stderr )
121
+ print (" : detected platform '%s'" % sys .platform , file = sys .stderr )
110
122
return False
111
123
112
124
global builtin_hdr_path
You can’t perform that action at this time.
0 commit comments