Imported Upstream version 6.10.0.49

Former-commit-id: 1d6753294b2993e1fbf92de9366bb9544db4189b
This commit is contained in:
Xamarin Public Jenkins (auto-signing)
2020-01-16 16:38:04 +00:00
parent d94e79959b
commit 468663ddbb
48518 changed files with 2789335 additions and 61176 deletions

View File

@ -0,0 +1,65 @@
"""
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 io
# Third party modules
import six
def _encoded_read(old_read, encoding):
def impl(size):
result = old_read(size)
# If this is Python 2 then we need to convert the resulting `unicode` back
# into a `str` before returning
if six.PY2:
result = result.encode(encoding)
return result
return impl
def _encoded_write(old_write, encoding):
def impl(s):
# If we were asked to write a `str` (in Py2) or a `bytes` (in Py3) decode it
# as unicode before attempting to write.
if isinstance(s, six.binary_type):
s = s.decode(encoding)
return old_write(s)
return impl
'''
Create a Text I/O file object that can be written to with either unicode strings or byte strings
under Python 2 and Python 3, and automatically encodes and decodes as necessary to return the
native string type for the current Python version
'''
def open(
file,
encoding,
mode='r',
buffering=-1,
errors=None,
newline=None,
closefd=True):
wrapped_file = io.open(
file,
mode=mode,
buffering=buffering,
encoding=encoding,
errors=errors,
newline=newline,
closefd=closefd)
new_read = _encoded_read(getattr(wrapped_file, 'read'), encoding)
new_write = _encoded_write(getattr(wrapped_file, 'write'), encoding)
setattr(wrapped_file, 'read', new_read)
setattr(wrapped_file, 'write', new_write)
return wrapped_file

View File

@ -0,0 +1,65 @@
"""
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

View File

@ -0,0 +1,24 @@
from __future__ import print_function
from __future__ import absolute_import
# System modules
import inspect
# Third-party modules
# LLDB modules
def requires_self(func):
func_argc = len(inspect.getargspec(func).args)
if func_argc == 0 or (
getattr(
func,
'im_self',
None) is not None) or (
hasattr(
func,
'__self__')):
return False
else:
return True

View File

@ -0,0 +1,29 @@
from __future__ import absolute_import
from __future__ import print_function
# System modules
import os
import re
GMODULES_SUPPORT_MAP = {}
GMODULES_HELP_REGEX = re.compile(r"\s-gmodules\s")
def is_compiler_clang_with_gmodules(compiler_path):
# Before computing the result, check if we already have it cached.
if compiler_path in GMODULES_SUPPORT_MAP:
return GMODULES_SUPPORT_MAP[compiler_path]
def _gmodules_supported_internal():
compiler = os.path.basename(compiler_path)
if "clang" not in compiler:
return False
else:
# Check the compiler help for the -gmodules option.
clang_help = os.popen("%s --help" % compiler_path).read()
return GMODULES_HELP_REGEX.search(
clang_help, re.DOTALL) is not None
GMODULES_SUPPORT_MAP[compiler_path] = _gmodules_supported_internal()
return GMODULES_SUPPORT_MAP[compiler_path]

View File

@ -0,0 +1,58 @@
# ====================================================================
# Provides a with-style resource handler for optionally-None resources
# ====================================================================
class optional_with(object):
# pylint: disable=too-few-public-methods
# This is a wrapper - it is not meant to provide any extra methods.
"""Provides a wrapper for objects supporting "with", allowing None.
This lets a user use the "with object" syntax for resource usage
(e.g. locks) even when the wrapped with object is None.
e.g.
wrapped_lock = optional_with(thread.Lock())
with wrapped_lock:
# Do something while the lock is obtained.
pass
might_be_none = None
wrapped_none = optional_with(might_be_none)
with wrapped_none:
# This code here still works.
pass
This prevents having to write code like this when
a lock is optional:
if lock:
lock.acquire()
try:
code_fragment_always_run()
finally:
if lock:
lock.release()
And I'd posit it is safer, as it becomes impossible to
forget the try/finally using optional_with(), since
the with syntax can be used.
"""
def __init__(self, wrapped_object):
self.wrapped_object = wrapped_object
def __enter__(self):
if self.wrapped_object is not None:
return self.wrapped_object.__enter__()
else:
return self
def __exit__(self, the_type, value, traceback):
if self.wrapped_object is not None:
return self.wrapped_object.__exit__(the_type, value, traceback)
else:
# Don't suppress any exceptions
return False

View File

@ -0,0 +1,25 @@
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)

View File

@ -0,0 +1,24 @@
"""
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()