brintos

brintos / llvm-project-archived public Read only

0
0
Text · 842 B · a050db0 Raw
29 lines · python
1import inspect2import os3import sys4 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 = parent13 14        test_path = os.path.join(lldb_root, "use_lldb_suite_root.py")15        if os.path.isfile(test_path):16            return lldb_root17 18 19lldb_root = find_lldb_root()20 21import importlib.machinery22import importlib.util23 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