diff options
Diffstat (limited to 'lldb/scripts/swig_bot_lib/server.py')
| -rw-r--r-- | lldb/scripts/swig_bot_lib/server.py | 38 |
1 files changed, 35 insertions, 3 deletions
diff --git a/lldb/scripts/swig_bot_lib/server.py b/lldb/scripts/swig_bot_lib/server.py index b973ca9bcf1..b7f14cfd599 100644 --- a/lldb/scripts/swig_bot_lib/server.py +++ b/lldb/scripts/swig_bot_lib/server.py @@ -11,6 +11,7 @@ from __future__ import print_function # Python modules import argparse +import io import logging import os import select @@ -23,10 +24,12 @@ import traceback # LLDB modules import use_lldb_suite +from lldbsuite.support import fs from lldbsuite.support import sockutil # package imports from . import local +from . import remote default_port = 8537 @@ -40,6 +43,12 @@ def process_args(args): default=default_port, help=("The local port to bind to")) + parser.add_argument( + "--swig-executable", + action="store", + default=fs.find_executable("swig"), + dest="swig_executable") + # Process args. return parser.parse_args(args) @@ -75,9 +84,31 @@ def accept_once(sock, options): pack_location = local.unpack_archive("swig-bot", data) logging.debug("Successfully unpacked archive...") - logging.info("Sending {} byte response".format(len(data))) - client.sendall(struct.pack("!I", len(data))) - client.sendall(data) + config_file = os.path.normpath(os.path.join(pack_location, + "config.json")) + parsed_config = remote.parse_config(io.open(config_file)) + config = local.LocalConfig() + config.languages = parsed_config["languages"] + config.swig_executable = options.swig_executable + config.src_root = pack_location + config.target_dir = os.path.normpath( + os.path.join(config.src_root, "output")) + logging.info( + "Running swig. languages={}, swig={}, src_root={}, target={}" + .format(config.languages, config.swig_executable, + config.src_root, config.target_dir)) + + local.generate(config) + logging.debug("Finished running swig. Packaging up output") + zip_data = io.BytesIO() + zip_file = local.pack_archive(zip_data, + config.target_dir, + [(".", None)]) + zip_file.close() + response_data = zip_data.getvalue() + logging.info("Sending {} byte response".format(len(response_data))) + client.sendall(struct.pack("!I", len(response_data))) + client.sendall(response_data) finally: if pack_location is not None: logging.debug("Removing temporary folder {}" @@ -95,6 +126,7 @@ def accept_loop(sock, options): def run(args): options = process_args(args) + print(options) sock = initialize_listening_socket(options) accept_loop(sock, options) return options |

