16498aff2SJonas Devlieghereimport os 26498aff2SJonas Devlieghereimport sys 36498aff2SJonas Devlieghere 46498aff2SJonas DevliegherepkgRelDir = sys.argv[1] 56498aff2SJonas DevliegherepkgFiles = sys.argv[2:] 66498aff2SJonas Devlieghere 76498aff2SJonas DevliegheregetFileName = lambda f: os.path.splitext(os.path.basename(f))[0] 86498aff2SJonas DevlieghereimportNames = ', '.join('"{}"'.format(getFileName(f)) for f in pkgFiles) 96498aff2SJonas Devlieghere 106498aff2SJonas Devliegherescript = """__all__ = [{import_names}] 116498aff2SJonas Devliegherefor x in __all__: 126498aff2SJonas Devlieghere __import__('lldb.{pkg_name}.' + x) 13*bf02586cSDave Lee 14*bf02586cSDave Leedef __lldb_init_module(debugger, internal_dict): 15*bf02586cSDave Lee import lldb 16*bf02586cSDave Lee for x in __all__: 17*bf02586cSDave Lee submodule = getattr(lldb.{pkg_name}, x) 18*bf02586cSDave Lee lldb_init = getattr(submodule, '__lldb_init_module', None) 19*bf02586cSDave Lee if lldb_init: 20*bf02586cSDave Lee lldb_init(debugger, internal_dict) 216498aff2SJonas Devlieghere""".format(import_names=importNames, pkg_name=pkgRelDir.replace("/", ".")) 226498aff2SJonas Devlieghere 236498aff2SJonas DevliegherepkgIniFile = os.path.normpath(os.path.join(pkgRelDir, "__init__.py")) 246498aff2SJonas Devliegherewith open(pkgIniFile, "w") as f: 256498aff2SJonas Devlieghere f.write(script) 26