diff --git a/radio/util/find_clang.py b/radio/util/find_clang.py index b3da34736..52954c79a 100644 --- a/radio/util/find_clang.py +++ b/radio/util/find_clang.py @@ -4,6 +4,7 @@ # import os import sys +import re from clang.cindex import * @@ -82,12 +83,20 @@ def findLibClang(): else: # Unsupported platform return None - + for path in knownPaths: # print("trying " + path) if os.path.exists(path + "/libclang" + libSuffix): return path + elif (sys.platform == "win32" or sys.platform == "msys"): + # Check for versioned and non-versioned libclang.dll if on msys + pattern = re.compile(r'^libclang(-\d+(\.\d+)?)?\.dll$') + if os.path.exists(path): + for filename in os.listdir(path): + if pattern.match(filename): + return os.path.join(path, filename) + # If no known path is found return None def initLibClang(): @@ -100,13 +109,16 @@ def initLibClang(): Config.set_library_path(library_path) else: Config.set_library_file(library_path) + else: + print("WARN (find_clang): libclang path not found", file=sys.stderr) Config.set_compatibility_check(False) try: index = Index.create() except Exception as e: - print("ERROR: could not load libclang from '%s'." % library_path, file=sys.stderr) + print("ERROR (find_clang): could not load libclang from '%s'." % library_path, file=sys.stderr) + print(" : detected platform '%s'" % sys.platform, file=sys.stderr) return False global builtin_hdr_path