summaryrefslogtreecommitdiffstats
path: root/packages/Python/lldbsuite/support
diff options
context:
space:
mode:
authordim <dim@FreeBSD.org>2016-01-06 20:12:03 +0000
committerdim <dim@FreeBSD.org>2016-01-06 20:12:03 +0000
commit78b9749c0a4ea980a8b934645da6ae98fcc665e8 (patch)
treedd2a1ddf0476664c2b823409c36cbccd52662ca7 /packages/Python/lldbsuite/support
parent60cb593f9d55fa5ca7a5372b731f2330345b4b9a (diff)
downloadFreeBSD-src-78b9749c0a4ea980a8b934645da6ae98fcc665e8.zip
FreeBSD-src-78b9749c0a4ea980a8b934645da6ae98fcc665e8.tar.gz
Vendor import of lldb trunk r256945:
https://llvm.org/svn/llvm-project/lldb/trunk@256945
Diffstat (limited to 'packages/Python/lldbsuite/support')
-rw-r--r--packages/Python/lldbsuite/support/__init__.py0
-rw-r--r--packages/Python/lldbsuite/support/fs.py64
-rw-r--r--packages/Python/lldbsuite/support/seven.py20
-rw-r--r--packages/Python/lldbsuite/support/sockutil.py23
4 files changed, 107 insertions, 0 deletions
diff --git a/packages/Python/lldbsuite/support/__init__.py b/packages/Python/lldbsuite/support/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/packages/Python/lldbsuite/support/__init__.py
diff --git a/packages/Python/lldbsuite/support/fs.py b/packages/Python/lldbsuite/support/fs.py
new file mode 100644
index 0000000..9a56808
--- /dev/null
+++ b/packages/Python/lldbsuite/support/fs.py
@@ -0,0 +1,64 @@
+"""
+ The LLVM Compiler Infrastructure
+
+This file is distributed under the University of Illinois Open Source
+License. See LICENSE.TXT for details.
+
+Prepares language bindings for LLDB build process. Run with --help
+to see a description of the supported command line arguments.
+"""
+
+# Python modules:
+import os
+import platform
+import sys
+
+
+def _find_file_in_paths(paths, exe_basename):
+ """Returns the full exe path for the first path match.
+
+ @params paths the list of directories to search for the exe_basename
+ executable
+ @params exe_basename the name of the file for which to search.
+ e.g. "swig" or "swig.exe".
+
+ @return the full path to the executable if found in one of the
+ given paths; otherwise, returns None.
+ """
+ for path in paths:
+ trial_exe_path = os.path.join(path, exe_basename)
+ if os.path.exists(trial_exe_path):
+ return os.path.normcase(trial_exe_path)
+ return None
+
+def find_executable(executable):
+ """Finds the specified executable in the PATH or known good locations."""
+
+ # Figure out what we're looking for.
+ if platform.system() == "Windows":
+ executable = executable + ".exe"
+ extra_dirs = []
+ else:
+ extra_dirs = ["/usr/local/bin"]
+
+ # Figure out what paths to check.
+ path_env = os.environ.get("PATH", None)
+ if path_env is not None:
+ paths_to_check = path_env.split(os.path.pathsep)
+ else:
+ paths_to_check = []
+
+ # Add in the extra dirs
+ paths_to_check.extend(extra_dirs)
+ if len(paths_to_check) < 1:
+ raise os.OSError(
+ "executable was not specified, PATH has no "
+ "contents, and there are no extra directories to search")
+
+ result = _find_file_in_paths(paths_to_check, executable)
+
+ if not result or len(result) < 1:
+ raise os.OSError(
+ "failed to find exe='%s' in paths='%s'" % (executable, paths_to_check))
+ return result
+
diff --git a/packages/Python/lldbsuite/support/seven.py b/packages/Python/lldbsuite/support/seven.py
new file mode 100644
index 0000000..56ddd8d
--- /dev/null
+++ b/packages/Python/lldbsuite/support/seven.py
@@ -0,0 +1,20 @@
+import six
+
+if six.PY2:
+ import commands
+ get_command_output = commands.getoutput
+ get_command_status_output = commands.getstatusoutput
+
+ cmp_ = cmp
+else:
+ def get_command_status_output(command):
+ try:
+ import subprocess
+ return (0, subprocess.check_output(command, shell=True, universal_newlines=True))
+ except subprocess.CalledProcessError as e:
+ return (e.returncode, e.output)
+
+ def get_command_output(command):
+ return get_command_status_output(command)[1]
+
+ cmp_ = lambda x, y: (x > y) - (x < y) \ No newline at end of file
diff --git a/packages/Python/lldbsuite/support/sockutil.py b/packages/Python/lldbsuite/support/sockutil.py
new file mode 100644
index 0000000..b3d81d14
--- /dev/null
+++ b/packages/Python/lldbsuite/support/sockutil.py
@@ -0,0 +1,23 @@
+"""
+ The LLVM Compiler Infrastructure
+
+This file is distributed under the University of Illinois Open Source
+License. See LICENSE.TXT for details.
+
+Helper functions for working with sockets.
+"""
+
+# Python modules:
+import io
+import socket
+
+# LLDB modules
+import use_lldb_suite
+
+def recvall(sock, size):
+ bytes = io.BytesIO()
+ while size > 0:
+ this_result = sock.recv(size)
+ bytes.write(this_result)
+ size -= len(this_result)
+ return bytes.getvalue()
OpenPOWER on IntegriCloud