summaryrefslogtreecommitdiff
path: root/lldb/bindings/python/createPythonInit.py
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2020-04-02 19:52:43 +0000
committerDimitry Andric <dim@FreeBSD.org>2020-04-02 19:52:43 +0000
commit4c8711804d577470fbe78eed165ac2de66b5653b (patch)
tree26e7a8e5c8bbe80c21b8bf59c7a196780c16dd5e /lldb/bindings/python/createPythonInit.py
parenteb4ff84dc5f98e31aebadff6c8aa38454c69a572 (diff)
Notes
Diffstat (limited to 'lldb/bindings/python/createPythonInit.py')
-rw-r--r--lldb/bindings/python/createPythonInit.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/lldb/bindings/python/createPythonInit.py b/lldb/bindings/python/createPythonInit.py
new file mode 100644
index 000000000000..3deb9159b702
--- /dev/null
+++ b/lldb/bindings/python/createPythonInit.py
@@ -0,0 +1,17 @@
+import os
+import sys
+
+pkgRelDir = sys.argv[1]
+pkgFiles = sys.argv[2:]
+
+getFileName = lambda f: os.path.splitext(os.path.basename(f))[0]
+importNames = ', '.join('"{}"'.format(getFileName(f)) for f in pkgFiles)
+
+script = """__all__ = [{import_names}]
+for x in __all__:
+ __import__('lldb.{pkg_name}.' + x)
+""".format(import_names=importNames, pkg_name=pkgRelDir.replace("/", "."))
+
+pkgIniFile = os.path.normpath(os.path.join(pkgRelDir, "__init__.py"))
+with open(pkgIniFile, "w") as f:
+ f.write(script)