diff options
author | Todd Fiala <todd.fiala@gmail.com> | 2015-11-18 08:52:33 +0000 |
---|---|---|
committer | Todd Fiala <todd.fiala@gmail.com> | 2015-11-18 08:52:33 +0000 |
commit | d434a1d3e05eeda059ae82ad80fa6eb938bbff1a (patch) | |
tree | 47af6efc05b40577e1e9f3eceec539fc0305a4c2 /lldb/scripts/Python/prepare_binding_Python.py | |
parent | 5574730454e82f0e866e633a301f1a86fd6a7b86 (diff) | |
download | bcm5719-llvm-d434a1d3e05eeda059ae82ad80fa6eb938bbff1a.tar.gz bcm5719-llvm-d434a1d3e05eeda059ae82ad80fa6eb938bbff1a.zip |
prepare_bindings.py: enable static bindings
Added a new flag, --allow-static-binding. When specified,
if (and only if) the swig binary cannot be found, then the
LLDBWrapPython.cpp and lldb.py from the
scripts/Python/{static-binding-dir} are copied into the place where
swig would have generated them.
{static-binding-dir} defaults to static-binding, and can be
overridden with the --static-binding-dir command line argument.
The static bindings checked in are from r253424.
llvm-svn: 253448
Diffstat (limited to 'lldb/scripts/Python/prepare_binding_Python.py')
-rw-r--r-- | lldb/scripts/Python/prepare_binding_Python.py | 57 |
1 files changed, 50 insertions, 7 deletions
diff --git a/lldb/scripts/Python/prepare_binding_Python.py b/lldb/scripts/Python/prepare_binding_Python.py index 1996841baf1..6dbc94ea9d1 100644 --- a/lldb/scripts/Python/prepare_binding_Python.py +++ b/lldb/scripts/Python/prepare_binding_Python.py @@ -251,6 +251,42 @@ def do_swig_rebuild(options, dependency_file, config_build_dir, settings): sys.exit(-10) +def copy_static_bindings(options, config_build_dir, settings): + """Copies the static Python bindings over to the build dir. + """ + + # Copy the LLDBWrapPython.cpp C++ binding file impl over. + lldb_wrap_python_src_path = os.path.join( + options.src_root, + "scripts", + "Python", + options.static_binding_dir, + "LLDBWrapPython.cpp") + if not os.path.exists(lldb_wrap_python_src_path): + logging.error( + "failed to find static Python binding .cpp file at '%s'", + lldb_wrap_python_src_path) + sys.exit(-12) + shutil.copyfile(lldb_wrap_python_src_path, settings.output_file) + + # Copy the lldb.py impl over. + lldb_py_src_path = os.path.join( + options.src_root, + "scripts", + "Python", + options.static_binding_dir, + "lldb.py") + if not os.path.exists(lldb_py_src_path): + logging.error( + "failed to find static Python binding .py file at '%s'", + lldb_py_src_path) + sys.exit(-13) + lldb_py_dest_path = os.path.join( + os.path.dirname(settings.output_file), + "lldb.py") + shutil.copyfile(lldb_py_src_path, lldb_py_dest_path) + + def run_python_script(script_and_args): """Runs a python script, logging appropriately. @@ -418,14 +454,21 @@ def main(options): "Skipping Python binding generation: everything is up to date") return - # Generate the Python binding with swig. - logging.info("Python binding is out of date, regenerating") - do_swig_rebuild(options, dependency_file, config_build_dir, settings) - if options.generate_dependency_file: - return + # Generate the Python binding with swig, or use the static bindings if no swig. + if not options.swig_executable or not os.path.exists(options.swig_executable): + # Copy over the static bindings. We capture the the modified (i.e. post-processed) + # binding, so we don't do the modify step here - the modifications have + # already been applied. + copy_static_bindings(options, config_build_dir, settings) + else: + # Generate the bindings with swig. + logging.info("Python binding is out of date, regenerating") + do_swig_rebuild(options, dependency_file, config_build_dir, settings) + if options.generate_dependency_file: + return - # Post process the swig-generated file. - do_modify_python_lldb(options, config_build_dir) + # Post process the swig-generated file. + do_modify_python_lldb(options, config_build_dir) # This script can be called by another Python script by calling the main() |