31 lines · python
1import inspect2import os3import sys4 5 6def find_lldb_root():7 lldb_root = os.path.realpath(8 os.path.dirname(inspect.getfile(inspect.currentframe()))9 )10 while True:11 parent = os.path.dirname(lldb_root)12 if parent == lldb_root: # dirname('/') == '/'13 raise Exception("use_lldb_suite_root.py not found")14 lldb_root = parent15 16 test_path = os.path.join(lldb_root, "use_lldb_suite_root.py")17 if os.path.isfile(test_path):18 return lldb_root19 20 21lldb_root = find_lldb_root()22 23import importlib.machinery24import importlib.util25 26path = os.path.join(lldb_root, "use_lldb_suite_root.py")27loader = importlib.machinery.SourceFileLoader("use_lldb_suite_root", path)28spec = importlib.util.spec_from_loader("use_lldb_suite_root", loader=loader)29module = importlib.util.module_from_spec(spec)30loader.exec_module(module)31