xref: /llvm-project/lldb/scripts/use_lldb_suite.py (revision 2260ebf7b6df15db96c76039758dd9dbf009c334)
1import inspect
2import os
3import sys
4
5
6def find_lldb_root():
7    lldb_root = os.path.dirname(inspect.getfile(inspect.currentframe()))
8    while True:
9        parent = os.path.dirname(lldb_root)
10        if parent == lldb_root:  # dirname('/') == '/'
11            raise Exception("use_lldb_suite_root.py not found")
12        lldb_root = parent
13
14        test_path = os.path.join(lldb_root, "use_lldb_suite_root.py")
15        if os.path.isfile(test_path):
16            return lldb_root
17
18
19lldb_root = find_lldb_root()
20
21import importlib.machinery
22import importlib.util
23
24path = os.path.join(lldb_root, "use_lldb_suite_root.py")
25loader = importlib.machinery.SourceFileLoader("use_lldb_suite_root", path)
26spec = importlib.util.spec_from_loader("use_lldb_suite_root", loader=loader)
27module = importlib.util.module_from_spec(spec)
28loader.exec_module(module)
29