summaryrefslogtreecommitdiff
path: root/lldb/CMakeLists.txt
diff options
context:
space:
mode:
authorLawrence D'Anna <larry@elder-gods.org>2021-11-16 13:50:18 -0800
committerLawrence D'Anna <lawrence_danna@apple.com>2021-11-16 13:50:20 -0800
commit4c2cf3a314d9131b1b288e7c8ab0c75ac1b2be1d (patch)
tree204b684bb3e3adb769b447893bb130c21e5b5012 /lldb/CMakeLists.txt
parent913d78c40c37c9c3428285d868ce454b058e40f3 (diff)
downloadllvm-4c2cf3a314d9131b1b288e7c8ab0c75ac1b2be1d.tar.gz
[lldb] fix -print-script-interpreter-info on windows
Apparently "{sys.prefix}/bin/python3" isn't where you find the python interpreter on windows, so the test I wrote for -print-script-interpreter-info is failing. We can't rely on sys.executable at runtime, because that will point to lldb.exe not python.exe. We can't just record sys.executable from build time, because python could have been moved to a different location. But it should be OK to apply relative path from sys.prefix to sys.executable from build-time to the sys.prefix at runtime. Reviewed By: JDevlieghere Differential Revision: https://reviews.llvm.org/D113650
Diffstat (limited to 'lldb/CMakeLists.txt')
-rw-r--r--lldb/CMakeLists.txt40
1 files changed, 22 insertions, 18 deletions
diff --git a/lldb/CMakeLists.txt b/lldb/CMakeLists.txt
index 028dadbb8c73..1a54addf3d55 100644
--- a/lldb/CMakeLists.txt
+++ b/lldb/CMakeLists.txt
@@ -31,24 +31,28 @@ if (WIN32)
endif()
if (LLDB_ENABLE_PYTHON)
- if (NOT CMAKE_CROSSCOMPILING)
- execute_process(
- COMMAND ${Python3_EXECUTABLE}
- -c "import distutils.sysconfig; print(distutils.sysconfig.get_python_lib(True, False, ''))"
- OUTPUT_VARIABLE LLDB_PYTHON_DEFAULT_RELATIVE_PATH
- OUTPUT_STRIP_TRAILING_WHITESPACE)
-
- file(TO_CMAKE_PATH ${LLDB_PYTHON_DEFAULT_RELATIVE_PATH} LLDB_PYTHON_DEFAULT_RELATIVE_PATH)
- else ()
- if ("${LLDB_PYTHON_RELATIVE_PATH}" STREQUAL "")
- message(FATAL_ERROR
- "Crosscompiling LLDB with Python requires manually setting
- LLDB_PYTHON_RELATIVE_PATH.")
- endif ()
- endif ()
-
- set(LLDB_PYTHON_RELATIVE_PATH ${LLDB_PYTHON_DEFAULT_RELATIVE_PATH}
- CACHE STRING "Path where Python modules are installed, relative to install prefix")
+ set(cachestring_LLDB_PYTHON_RELATIVE_PATH
+ "Path where Python modules are installed, relative to install prefix")
+ set(cachestring_LLDB_PYTHON_EXE_RELATIVE_PATH
+ "Path to python interpreter exectuable, relative to install prefix")
+
+ foreach(var LLDB_PYTHON_RELATIVE_PATH LLDB_PYTHON_EXE_RELATIVE_PATH)
+ if(NOT DEFINED ${var} AND NOT CMAKE_CROSSCOMPILING)
+ execute_process(
+ COMMAND ${Python3_EXECUTABLE}
+ ${CMAKE_CURRENT_SOURCE_DIR}/bindings/python/get-python-config.py
+ ${var}
+ OUTPUT_VARIABLE value
+ OUTPUT_STRIP_TRAILING_WHITESPACE)
+ file(TO_CMAKE_PATH "${value}" value)
+ set(${var} ${value} CACHE STRING ${cachestring_${var}})
+ else()
+ if ("${${var}}" STREQUAL "")
+ message(FATAL_ERROR
+ "Crosscompiling LLDB with Python requires manually setting ${var}.")
+ endif()
+ endif()
+ endforeach()
endif ()
if (LLDB_ENABLE_LUA)