summaryrefslogtreecommitdiffstats
path: root/lldb/source/Host
diff options
context:
space:
mode:
authorPavel Labath <labath@google.com>2018-06-20 08:35:45 +0000
committerPavel Labath <labath@google.com>2018-06-20 08:35:45 +0000
commit2df331b0f78b90a5b0be1e247f3cce97709af964 (patch)
tree3db24e1ba9d0a8ef84761453bd883172a98d587c /lldb/source/Host
parentf29d777f847b2a3d0aec2a499490fa34815fc918 (diff)
downloadbcm5719-llvm-2df331b0f78b90a5b0be1e247f3cce97709af964.tar.gz
bcm5719-llvm-2df331b0f78b90a5b0be1e247f3cce97709af964.zip
Remove dependency from Host to python
Summary: The only reason python was used in the Host module was to compute the python path. I resolve this the same way as D47384 did for clang, by moving the path computation into the python plugin and modifying SBHostOS class to call into this module for ePathTypePythonDir. Reviewers: zturner, jingham, davide Subscribers: mgorny, lldb-commits Differential Revision: https://reviews.llvm.org/D48215 llvm-svn: 335104
Diffstat (limited to 'lldb/source/Host')
-rw-r--r--lldb/source/Host/CMakeLists.txt28
-rw-r--r--lldb/source/Host/common/HostInfoBase.cpp12
-rw-r--r--lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm34
-rw-r--r--lldb/source/Host/posix/HostInfoPosix.cpp44
-rw-r--r--lldb/source/Host/windows/HostInfoWindows.cpp12
5 files changed, 0 insertions, 130 deletions
diff --git a/lldb/source/Host/CMakeLists.txt b/lldb/source/Host/CMakeLists.txt
index 4ae53bd1233..5a92447edf3 100644
--- a/lldb/source/Host/CMakeLists.txt
+++ b/lldb/source/Host/CMakeLists.txt
@@ -51,11 +51,6 @@ add_host_subdirectory(common
common/UDPSocket.cpp
)
-# Keep track of whether we want to provide a define for the
-# Python's architecture-specific lib path (i.e. where a
-# Python lldb module would go).
-set (get_python_libdir 0)
-
if (NOT LLDB_DISABLE_LIBEDIT)
add_host_subdirectory(common
common/Editline.cpp
@@ -66,10 +61,6 @@ add_host_subdirectory(posix
posix/ConnectionFileDescriptorPosix.cpp
)
-if(NOT LLDB_DISABLE_PYTHON)
- list(APPEND LLDB_PLUGINS lldbPluginScriptInterpreterPython)
-endif()
-
if (CMAKE_SYSTEM_NAME MATCHES "Windows")
add_host_subdirectory(windows
windows/ConnectionGenericFileWindows.cpp
@@ -86,11 +77,6 @@ if (CMAKE_SYSTEM_NAME MATCHES "Windows")
windows/Windows.cpp
)
else()
- if (NOT LLDB_DISABLE_PYTHON)
- # We'll grab the arch-specific python libdir on POSIX systems.
- set (get_python_libdir 1)
- endif()
-
add_host_subdirectory(posix
posix/DomainSocket.cpp
posix/FileSystem.cpp
@@ -155,19 +141,6 @@ else()
endif()
endif()
-if (${get_python_libdir})
- # Call a python script to gather the arch-specific libdir for
- # modules like the lldb module.
- execute_process(
- COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/../../scripts/get_relative_lib_dir.py
- RESULT_VARIABLE get_libdir_status
- OUTPUT_VARIABLE relative_libdir
- )
- if (get_libdir_status EQUAL 0)
- add_definitions(-DLLDB_PYTHON_RELATIVE_LIBDIR="${relative_libdir}")
- endif()
-endif()
-
set(EXTRA_LIBS)
if (CMAKE_SYSTEM_NAME MATCHES "NetBSD")
list(APPEND EXTRA_LIBS kvm)
@@ -194,7 +167,6 @@ add_lldb_library(lldbHost
lldbSymbol
lldbTarget
lldbUtility
- ${LLDB_PLUGINS}
${EXTRA_LIBS}
${LLDBObjCLibs}
diff --git a/lldb/source/Host/common/HostInfoBase.cpp b/lldb/source/Host/common/HostInfoBase.cpp
index b023338c080..4de6953a91e 100644
--- a/lldb/source/Host/common/HostInfoBase.cpp
+++ b/lldb/source/Host/common/HostInfoBase.cpp
@@ -58,7 +58,6 @@ struct HostInfoBaseFields {
FileSpec m_lldb_so_dir;
FileSpec m_lldb_support_exe_dir;
FileSpec m_lldb_headers_dir;
- FileSpec m_lldb_python_dir;
FileSpec m_lldb_clang_resource_dir;
FileSpec m_lldb_system_plugin_dir;
FileSpec m_lldb_user_plugin_dir;
@@ -145,17 +144,6 @@ FileSpec HostInfoBase::GetHeaderDir() {
return success ? g_fields->m_lldb_headers_dir : FileSpec();
}
-FileSpec HostInfoBase::GetPythonDir() {
- static llvm::once_flag g_once_flag;
- static bool success = false;
- llvm::call_once(g_once_flag, []() {
- success = HostInfo::ComputePythonDirectory(g_fields->m_lldb_python_dir);
- Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST);
- LLDB_LOG(log, "python dir -> `{0}`", g_fields->m_lldb_python_dir);
- });
- return success ? g_fields->m_lldb_python_dir : FileSpec();
-}
-
FileSpec HostInfoBase::GetSystemPluginDir() {
static llvm::once_flag g_once_flag;
static bool success = false;
diff --git a/lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm b/lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm
index 085f553f1c9..a39d26aa31a 100644
--- a/lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm
+++ b/lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm
@@ -7,10 +7,6 @@
//
//===----------------------------------------------------------------------===//
-#if !defined(LLDB_DISABLE_PYTHON)
-#include "Plugins/ScriptInterpreter/Python/lldb-python.h"
-#endif
-
#include "lldb/Host/HostInfo.h"
#include "lldb/Host/macosx/HostInfoMacOSX.h"
#include "lldb/Utility/Args.h"
@@ -188,36 +184,6 @@ bool HostInfoMacOSX::ComputeHeaderDirectory(FileSpec &file_spec) {
return true;
}
-bool HostInfoMacOSX::ComputePythonDirectory(FileSpec &file_spec) {
-#ifndef LLDB_DISABLE_PYTHON
- FileSpec lldb_file_spec = GetShlibDir();
- if (!lldb_file_spec)
- return false;
-
- std::string raw_path = lldb_file_spec.GetPath();
-
- size_t framework_pos = raw_path.find("LLDB.framework");
- if (framework_pos != std::string::npos) {
- framework_pos += strlen("LLDB.framework");
- raw_path.resize(framework_pos);
- raw_path.append("/Resources/Python");
- } else {
- llvm::SmallString<256> python_version_dir;
- llvm::raw_svector_ostream os(python_version_dir);
- os << "/python" << PY_MAJOR_VERSION << '.' << PY_MINOR_VERSION
- << "/site-packages";
-
- // We may get our string truncated. Should we protect this with an assert?
- raw_path.append(python_version_dir.c_str());
- }
- file_spec.GetDirectory().SetString(
- llvm::StringRef(raw_path.c_str(), raw_path.size()));
- return true;
-#else
- return false;
-#endif
-}
-
bool HostInfoMacOSX::ComputeSystemPluginsDirectory(FileSpec &file_spec) {
FileSpec lldb_file_spec = GetShlibDir();
if (!lldb_file_spec)
diff --git a/lldb/source/Host/posix/HostInfoPosix.cpp b/lldb/source/Host/posix/HostInfoPosix.cpp
index 3f82a126ec0..62c70fa3edc 100644
--- a/lldb/source/Host/posix/HostInfoPosix.cpp
+++ b/lldb/source/Host/posix/HostInfoPosix.cpp
@@ -7,10 +7,6 @@
//
//===----------------------------------------------------------------------===//
-#if !defined(LLDB_DISABLE_PYTHON)
-#include "Plugins/ScriptInterpreter/Python/lldb-python.h"
-#endif
-
#include "lldb/Host/posix/HostInfoPosix.h"
#include "lldb/Utility/Log.h"
@@ -172,46 +168,6 @@ bool HostInfoPosix::ComputeHeaderDirectory(FileSpec &file_spec) {
return true;
}
-bool HostInfoPosix::ComputePythonDirectory(FileSpec &file_spec) {
-#ifndef LLDB_DISABLE_PYTHON
- FileSpec lldb_file_spec = GetShlibDir();
- if (!lldb_file_spec)
- return false;
-
- char raw_path[PATH_MAX];
- lldb_file_spec.GetPath(raw_path, sizeof(raw_path));
-
-#if defined(LLDB_PYTHON_RELATIVE_LIBDIR)
- // Build the path by backing out of the lib dir, then building with whatever
- // the real python interpreter uses. (e.g. lib for most, lib64 on RHEL
- // x86_64).
- char python_path[PATH_MAX];
- ::snprintf(python_path, sizeof(python_path), "%s/../%s", raw_path,
- LLDB_PYTHON_RELATIVE_LIBDIR);
-
- char final_path[PATH_MAX];
- realpath(python_path, final_path);
- file_spec.GetDirectory().SetCString(final_path);
-
- return true;
-#else
- llvm::SmallString<256> python_version_dir;
- llvm::raw_svector_ostream os(python_version_dir);
- os << "/python" << PY_MAJOR_VERSION << '.' << PY_MINOR_VERSION
- << "/site-packages";
-
- // We may get our string truncated. Should we protect this with an assert?
- ::strncat(raw_path, python_version_dir.c_str(),
- sizeof(raw_path) - strlen(raw_path) - 1);
-
- file_spec.GetDirectory().SetCString(raw_path);
- return true;
-#endif
-#else
- return false;
-#endif
-}
-
bool HostInfoPosix::GetEnvironmentVar(const std::string &var_name,
std::string &var) {
if (const char *pvar = ::getenv(var_name.c_str())) {
diff --git a/lldb/source/Host/windows/HostInfoWindows.cpp b/lldb/source/Host/windows/HostInfoWindows.cpp
index 25df5a400f0..4b984967be5 100644
--- a/lldb/source/Host/windows/HostInfoWindows.cpp
+++ b/lldb/source/Host/windows/HostInfoWindows.cpp
@@ -103,18 +103,6 @@ FileSpec HostInfoWindows::GetDefaultShell() {
return FileSpec(shell, false);
}
-bool HostInfoWindows::ComputePythonDirectory(FileSpec &file_spec) {
- FileSpec lldb_file_spec = GetShlibDir();
- if (!lldb_file_spec)
- return false;
- llvm::SmallString<64> path(lldb_file_spec.GetDirectory().AsCString());
- llvm::sys::path::remove_filename(path);
- llvm::sys::path::append(path, "lib", "site-packages");
- std::replace(path.begin(), path.end(), '\\', '/');
- file_spec.GetDirectory().SetString(path.c_str());
- return true;
-}
-
bool HostInfoWindows::GetEnvironmentVar(const std::string &var_name,
std::string &var) {
std::wstring wvar_name;
OpenPOWER on IntegriCloud