Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/freebsd-src
Path: blob/main/contrib/llvm-project/lldb/bindings/python/createPythonInit.py
34907 views
1
import os
2
import sys
3
4
pkgRelDir = sys.argv[1]
5
pkgFiles = sys.argv[2:]
6
7
getFileName = lambda f: os.path.splitext(os.path.basename(f))[0]
8
importNames = ", ".join('"{}"'.format(getFileName(f)) for f in pkgFiles)
9
10
script = """__all__ = [{import_names}]
11
for x in __all__:
12
__import__('lldb.{pkg_name}.' + x)
13
14
def __lldb_init_module(debugger, internal_dict):
15
import lldb
16
for x in __all__:
17
submodule = getattr(lldb.{pkg_name}, x)
18
lldb_init = getattr(submodule, '__lldb_init_module', None)
19
if lldb_init:
20
lldb_init(debugger, internal_dict)
21
""".format(
22
import_names=importNames, pkg_name=pkgRelDir.replace("/", ".")
23
)
24
25
pkgIniFile = os.path.normpath(os.path.join(pkgRelDir, "__init__.py"))
26
with open(pkgIniFile, "w") as f:
27
f.write(script)
28
29