summaryrefslogtreecommitdiffstats
path: root/lldb/scripts/swig_bot_lib
diff options
context:
space:
mode:
authorKate Stone <katherine.stone@apple.com>2016-09-06 20:57:50 +0000
committerKate Stone <katherine.stone@apple.com>2016-09-06 20:57:50 +0000
commitb9c1b51e45b845debb76d8658edabca70ca56079 (patch)
treedfcb5a13ef2b014202340f47036da383eaee74aa /lldb/scripts/swig_bot_lib
parentd5aa73376966339caad04013510626ec2e42c760 (diff)
downloadbcm5719-llvm-b9c1b51e45b845debb76d8658edabca70ca56079.tar.gz
bcm5719-llvm-b9c1b51e45b845debb76d8658edabca70ca56079.zip
*** This commit represents a complete reformatting of the LLDB source code
*** to conform to clang-format’s LLVM style. This kind of mass change has *** two obvious implications: Firstly, merging this particular commit into a downstream fork may be a huge effort. Alternatively, it may be worth merging all changes up to this commit, performing the same reformatting operation locally, and then discarding the merge for this particular commit. The commands used to accomplish this reformatting were as follows (with current working directory as the root of the repository): find . \( -iname "*.c" -or -iname "*.cpp" -or -iname "*.h" -or -iname "*.mm" \) -exec clang-format -i {} + find . -iname "*.py" -exec autopep8 --in-place --aggressive --aggressive {} + ; The version of clang-format used was 3.9.0, and autopep8 was 1.2.4. Secondly, “blame” style tools will generally point to this commit instead of a meaningful prior commit. There are alternatives available that will attempt to look through this change and find the appropriate prior commit. YMMV. llvm-svn: 280751
Diffstat (limited to 'lldb/scripts/swig_bot_lib')
-rw-r--r--lldb/scripts/swig_bot_lib/client.py27
-rw-r--r--lldb/scripts/swig_bot_lib/local.py10
-rw-r--r--lldb/scripts/swig_bot_lib/remote.py4
-rw-r--r--lldb/scripts/swig_bot_lib/server.py6
4 files changed, 36 insertions, 11 deletions
diff --git a/lldb/scripts/swig_bot_lib/client.py b/lldb/scripts/swig_bot_lib/client.py
index 9bf55b42b66..d9f0fb47e01 100644
--- a/lldb/scripts/swig_bot_lib/client.py
+++ b/lldb/scripts/swig_bot_lib/client.py
@@ -30,6 +30,7 @@ from . import remote
default_ip = "127.0.0.1"
default_port = 8537
+
def add_subparser_args(parser):
"""Returns options processed from the provided command line.
@@ -41,9 +42,11 @@ def add_subparser_args(parser):
# searches for a copy of swig located on the physical machine. If
# used with 1 argument, the argument is the path to a swig executable.
class FindLocalSwigAction(argparse.Action):
+
def __init__(self, option_strings, dest, **kwargs):
super(FindLocalSwigAction, self).__init__(
option_strings, dest, nargs='?', **kwargs)
+
def __call__(self, parser, namespace, values, option_string=None):
swig_exe = None
if values is None:
@@ -58,18 +61,20 @@ def add_subparser_args(parser):
# of the form `ip_address[:port]`. If the port is unspecified, the
# default port is used.
class RemoteIpAction(argparse.Action):
+
def __init__(self, option_strings, dest, **kwargs):
super(RemoteIpAction, self).__init__(
option_strings, dest, nargs='?', **kwargs)
+
def __call__(self, parser, namespace, values, option_string=None):
ip_port = None
if values is None:
ip_port = (default_ip, default_port)
else:
result = values.split(':')
- if len(result)==1:
+ if len(result) == 1:
ip_port = (result[0], default_port)
- elif len(result)==2:
+ elif len(result) == 2:
ip_port = (result[0], int(result[1]))
else:
raise ValueError("Invalid connection string")
@@ -108,6 +113,7 @@ def add_subparser_args(parser):
action="append",
help="Specifies the language to generate bindings for")
+
def finalize_subparser_options(options):
if options.languages is None:
options.languages = ['python']
@@ -118,6 +124,7 @@ def finalize_subparser_options(options):
return options
+
def establish_remote_connection(ip_port):
logging.debug("Creating socket...")
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
@@ -127,6 +134,7 @@ def establish_remote_connection(ip_port):
logging.info("Connection established...")
return s
+
def transmit_request(connection, packed_input):
logging.info("Sending {} bytes of compressed data."
.format(len(packed_input)))
@@ -138,27 +146,28 @@ def transmit_request(connection, packed_input):
response = sockutil.recvall(connection, response_len)
return response
+
def handle_response(options, connection, response):
logging.debug("Received {} byte response.".format(len(response)))
logging.debug("Creating output directory {}"
- .format(options.target_dir))
+ .format(options.target_dir))
os.makedirs(options.target_dir, exist_ok=True)
logging.info("Unpacking response archive into {}"
- .format(options.target_dir))
+ .format(options.target_dir))
local.unpack_archive(options.target_dir, response)
response_file_path = os.path.normpath(
os.path.join(options.target_dir, "swig_output.json"))
if not os.path.isfile(response_file_path):
logging.error("Response file '{}' does not exist."
- .format(response_file_path))
+ .format(response_file_path))
return
try:
response = remote.deserialize_response_status(
io.open(response_file_path))
if response[0] != 0:
logging.error("An error occurred during generation. Status={}"
- .format(response[0]))
+ .format(response[0]))
logging.error(response[1])
else:
logging.info("SWIG generation successful.")
@@ -167,6 +176,7 @@ def handle_response(options, connection, response):
finally:
os.unlink(response_file_path)
+
def run(options):
if options.remote is None:
logging.info("swig bot client using local swig installation at '{}'"
@@ -193,7 +203,8 @@ def run(options):
("scripts/Python", ".swig"),
("scripts/interface", ".i")]
zip_data = io.BytesIO()
- packed_input = local.pack_archive(zip_data, options.src_root, inputs)
+ packed_input = local.pack_archive(
+ zip_data, options.src_root, inputs)
logging.info("(null) -> config.json")
packed_input.writestr("config.json", config)
packed_input.close()
@@ -202,4 +213,4 @@ def run(options):
handle_response(options, connection, response)
finally:
if connection is not None:
- connection.close() \ No newline at end of file
+ connection.close()
diff --git a/lldb/scripts/swig_bot_lib/local.py b/lldb/scripts/swig_bot_lib/local.py
index 7cca0b3cabb..b26ea2f53ea 100644
--- a/lldb/scripts/swig_bot_lib/local.py
+++ b/lldb/scripts/swig_bot_lib/local.py
@@ -26,12 +26,14 @@ import use_lldb_suite
# Package imports
from lldbsuite.support import fs
+
class LocalConfig(object):
src_root = None
target_dir = None
languages = None
swig_executable = None
+
def pack_archive(bytes_io, src_root, filters):
logging.info("Creating input file package...")
zip_file = None
@@ -53,9 +55,9 @@ def pack_archive(bytes_io, src_root, filters):
candidates = [os.path.normpath(os.path.join(full_path, f))
for f in os.listdir(full_path)]
actual = filter(
- lambda f : os.path.isfile(f) and os.path.splitext(f)[1] == ext,
+ lambda f: os.path.isfile(f) and os.path.splitext(f)[1] == ext,
candidates)
- return (subfolder, map(lambda f : os.path.basename(f), actual))
+ return (subfolder, map(lambda f: os.path.basename(f), actual))
archive_entries = map(filter_func, filters)
else:
for (root, dirs, files) in os.walk(src_root):
@@ -77,6 +79,7 @@ def pack_archive(bytes_io, src_root, filters):
return zip_file
+
def unpack_archive(folder, archive_bytes):
zip_data = io.BytesIO(archive_bytes)
logging.debug("Opening zip archive...")
@@ -84,6 +87,7 @@ def unpack_archive(folder, archive_bytes):
zip_file.extractall(folder)
zip_file.close()
+
def generate(options):
include_folder = os.path.join(options.src_root, "include")
in_file = os.path.join(options.src_root, "scripts", "lldb.swig")
@@ -128,4 +132,4 @@ def generate(options):
logging.error("An error occurred executing swig. returncode={}"
.format(e.returncode))
logging.error(e.output)
- return (e.returncode, e.output) \ No newline at end of file
+ return (e.returncode, e.output)
diff --git a/lldb/scripts/swig_bot_lib/remote.py b/lldb/scripts/swig_bot_lib/remote.py
index 590a873d627..712a5e2a51e 100644
--- a/lldb/scripts/swig_bot_lib/remote.py
+++ b/lldb/scripts/swig_bot_lib/remote.py
@@ -20,19 +20,23 @@ import sys
# LLDB modules
import use_lldb_suite
+
def generate_config(languages):
config = {"languages": languages}
return json.dumps(config)
+
def parse_config(json_reader):
json_data = json_reader.read()
options_dict = json.loads(json_data)
return options_dict
+
def serialize_response_status(status):
status = {"retcode": status[0], "output": status[1]}
return json.dumps(status)
+
def deserialize_response_status(json_reader):
json_data = json_reader.read()
response_dict = json.loads(json_data)
diff --git a/lldb/scripts/swig_bot_lib/server.py b/lldb/scripts/swig_bot_lib/server.py
index cc25cee4d4b..57fb8d9db4e 100644
--- a/lldb/scripts/swig_bot_lib/server.py
+++ b/lldb/scripts/swig_bot_lib/server.py
@@ -33,6 +33,7 @@ from . import remote
default_port = 8537
+
def add_subparser_args(parser):
parser.add_argument(
"--port",
@@ -46,9 +47,11 @@ def add_subparser_args(parser):
default=fs.find_executable("swig"),
dest="swig_executable")
+
def finalize_subparser_options(options):
pass
+
def initialize_listening_socket(options):
logging.debug("Creating socket...")
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
@@ -60,6 +63,7 @@ def initialize_listening_socket(options):
s.listen()
return s
+
def accept_once(sock, options):
logging.debug("Waiting for connection...")
while True:
@@ -122,6 +126,7 @@ def accept_once(sock, options):
.format(pack_location))
shutil.rmtree(pack_location)
+
def accept_loop(sock, options):
while True:
try:
@@ -131,6 +136,7 @@ def accept_loop(sock, options):
logging.error("An error occurred while processing the connection.")
logging.error(error)
+
def run(options):
print(options)
sock = initialize_listening_socket(options)
OpenPOWER on IntegriCloud