Skip to content

Commit 4832ccb

Browse files
committed
[lldb] Add script to copy the static bindings
(cherry picked from commit f5e3a0c)
1 parent d090d09 commit 4832ccb

File tree

1 file changed

+59
-0
lines changed

1 file changed

+59
-0
lines changed

lldb/scripts/copy-static-bindings.py

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
#!/usr/bin/env python
2+
3+
"""SWIG Static Binding Copier
4+
5+
This script copies over the Python bindings generated by SWIG from the build
6+
directory to the source directory. Before using the script, make sure you have
7+
LLDB_USE_STATIC_BINDINGS set to OFF by looking at CMakeCache.txt in the LLDB
8+
build directory.
9+
10+
The scripts knows the location of the static bindings in the source directory
11+
based on its own location. The build directory must be specified as a position
12+
argument.
13+
14+
$ copy-static-bindings.py <path to LLDB build directory>
15+
16+
Run this script whenever you're changing any of the .i interface files in the
17+
bindings directory.
18+
"""
19+
20+
import argparse
21+
import os
22+
import sys
23+
import shutil
24+
25+
26+
def main():
27+
parser = argparse.ArgumentParser(description='Copy the static bindings')
28+
parser.add_argument('build_dir',
29+
type=str,
30+
help='Path to the root of the LLDB build directory')
31+
32+
args = parser.parse_args()
33+
34+
build_dir = args.build_dir
35+
if not os.path.exists(build_dir):
36+
print("error: the build directory does not exist: {}".format(
37+
args.build_dir))
38+
sys.exit(1)
39+
40+
source_dir = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))
41+
if not os.path.exists(source_dir):
42+
print("error: the source directory does not exist: {}".format(
43+
source_dir))
44+
sys.exit(1)
45+
46+
binding_build_dir = os.path.join(build_dir, 'bindings', 'python')
47+
binding_source_dir = os.path.join(source_dir, 'bindings', 'python',
48+
'static-binding')
49+
50+
for root, _, files in os.walk(binding_build_dir):
51+
for file in files:
52+
_, extension = os.path.splitext(file)
53+
filepath = os.path.join(root, file)
54+
if extension == '.py' or extension == '.cpp':
55+
shutil.copy(filepath, os.path.join(binding_source_dir, file))
56+
57+
58+
if __name__ == "__main__":
59+
main()

0 commit comments

Comments
 (0)