Skip to content

Commit 80f5d3d

Browse files
authored
fix(cpn): llvm clang dll filename change breaking libsimulator builds (#4775)
1 parent 49c1cb8 commit 80f5d3d

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

radio/util/find_clang.py

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#
55
import os
66
import sys
7+
import re
78

89
from clang.cindex import *
910

@@ -82,12 +83,20 @@ def findLibClang():
8283
else:
8384
# Unsupported platform
8485
return None
85-
86+
8687
for path in knownPaths:
8788
# print("trying " + path)
8889
if os.path.exists(path + "/libclang" + libSuffix):
8990
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
91100
return None
92101

93102
def initLibClang():
@@ -100,13 +109,16 @@ def initLibClang():
100109
Config.set_library_path(library_path)
101110
else:
102111
Config.set_library_file(library_path)
112+
else:
113+
print("WARN (find_clang): libclang path not found", file=sys.stderr)
103114

104115
Config.set_compatibility_check(False)
105116

106117
try:
107118
index = Index.create()
108119
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)
110122
return False
111123

112124
global builtin_hdr_path

0 commit comments

Comments
 (0)