Skip to content

Commit 45bc525

Browse files
committed
Merge commit '1c630cb2fbc0' from apple/stable/20200714 into swift/main
Conflicts: lldb/cmake/modules/FindPythonInterpAndLibs.cmake lldb/test/Shell/lit.site.cfg.py.in
2 parents 894877c + 1c630cb commit 45bc525

File tree

34 files changed

+238
-208
lines changed

34 files changed

+238
-208
lines changed

lldb/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ endif()
6161

6262
if (LLDB_ENABLE_PYTHON)
6363
execute_process(
64-
COMMAND ${PYTHON_EXECUTABLE}
64+
COMMAND ${Python3_EXECUTABLE}
6565
-c "import distutils.sysconfig; print(distutils.sysconfig.get_python_lib(True, False, ''))"
6666
OUTPUT_VARIABLE LLDB_PYTHON_DEFAULT_RELATIVE_PATH
6767
OUTPUT_STRIP_TRAILING_WHITESPACE)

lldb/bindings/python/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ function(create_python_package swig_target working_dir pkg_dir)
2626
set(copy_cmd COMMAND ${CMAKE_COMMAND} -E copy ${ARG_FILES} ${pkg_dir})
2727
endif()
2828
if(NOT ARG_NOINIT)
29-
set(init_cmd COMMAND ${PYTHON_EXECUTABLE}
29+
set(init_cmd COMMAND ${Python3_EXECUTABLE}
3030
"${LLDB_SOURCE_DIR}/bindings/python/createPythonInit.py"
3131
"${pkg_dir}" ${ARG_FILES})
3232
endif()
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
#.rst:
2+
# FindPythonAndSwig
3+
# -----------
4+
#
5+
# Find the python interpreter and libraries as a whole.
6+
7+
macro(FindPython3)
8+
# Use PYTHON_HOME as a hint to find Python 3.
9+
set(Python3_ROOT_DIR "${PYTHON_HOME}")
10+
find_package(Python3 COMPONENTS Interpreter Development)
11+
if(Python3_FOUND AND Python3_Interpreter_FOUND)
12+
13+
# The install name for the Python 3 framework in Xcode is relative to
14+
# the framework's location and not the dylib itself.
15+
#
16+
# @rpath/Python3.framework/Versions/3.x/Python3
17+
#
18+
# This means that we need to compute the path to the Python3.framework
19+
# and use that as the RPATH instead of the usual dylib's directory.
20+
#
21+
# The check below shouldn't match Homebrew's Python framework as it is
22+
# called Python.framework instead of Python3.framework.
23+
if (APPLE AND Python3_LIBRARIES MATCHES "Python3.framework")
24+
string(FIND "${Python3_LIBRARIES}" "Python3.framework" python_framework_pos)
25+
string(SUBSTRING "${Python3_LIBRARIES}" "0" ${python_framework_pos} Python3_RPATH)
26+
endif()
27+
28+
set(PYTHON3_FOUND TRUE)
29+
mark_as_advanced(
30+
Python3_LIBRARIES
31+
Python3_INCLUDE_DIRS
32+
Python3_EXECUTABLE
33+
Python3_RPATH
34+
SWIG_EXECUTABLE)
35+
endif()
36+
endmacro()
37+
38+
if(Python3_LIBRARIES AND Python3_INCLUDE_DIRS AND Python3_EXECUTABLE AND SWIG_EXECUTABLE)
39+
set(PYTHONANDSWIG_FOUND TRUE)
40+
else()
41+
find_package(SWIG 2.0)
42+
if (SWIG_FOUND)
43+
FindPython3()
44+
else()
45+
message(STATUS "SWIG 2 or later is required for Python support in LLDB but could not be found")
46+
endif()
47+
48+
include(FindPackageHandleStandardArgs)
49+
find_package_handle_standard_args(PythonAndSwig
50+
FOUND_VAR
51+
PYTHONANDSWIG_FOUND
52+
REQUIRED_VARS
53+
Python3_LIBRARIES
54+
Python3_INCLUDE_DIRS
55+
Python3_EXECUTABLE
56+
SWIG_EXECUTABLE)
57+
endif()

lldb/cmake/modules/FindPythonInterpAndLibs.cmake

Lines changed: 0 additions & 116 deletions
This file was deleted.

lldb/cmake/modules/LLDBConfig.cmake

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ add_optional_dependency(LLDB_ENABLE_LIBEDIT "Enable editline support in LLDB" Li
5656
add_optional_dependency(LLDB_ENABLE_CURSES "Enable curses support in LLDB" CursesAndPanel CURSESANDPANEL_FOUND)
5757
add_optional_dependency(LLDB_ENABLE_LZMA "Enable LZMA compression support in LLDB" LibLZMA LIBLZMA_FOUND)
5858
add_optional_dependency(LLDB_ENABLE_LUA "Enable Lua scripting support in LLDB" LuaAndSwig LUAANDSWIG_FOUND)
59-
add_optional_dependency(LLDB_ENABLE_PYTHON "Enable Python scripting support in LLDB" PythonInterpAndLibs PYTHONINTERPANDLIBS_FOUND)
59+
add_optional_dependency(LLDB_ENABLE_PYTHON "Enable Python scripting support in LLDB" PythonAndSwig PYTHONANDSWIG_FOUND)
6060
add_optional_dependency(LLDB_ENABLE_LIBXML2 "Enable Libxml 2 support in LLDB" LibXml2 LIBXML2_FOUND VERSION 2.8)
6161

6262
option(LLDB_USE_SYSTEM_SIX "Use six.py shipped with system and do not install a copy of it" OFF)
@@ -88,11 +88,6 @@ if(LLDB_BUILD_FRAMEWORK)
8888
if(NOT APPLE)
8989
message(FATAL_ERROR "LLDB.framework can only be generated when targeting Apple platforms")
9090
endif()
91-
# CMake 3.6 did not correctly emit POST_BUILD commands for Apple Framework targets
92-
# CMake < 3.8 did not have the BUILD_RPATH target property
93-
if(CMAKE_VERSION VERSION_LESS 3.8)
94-
message(FATAL_ERROR "LLDB_BUILD_FRAMEWORK is not supported on CMake < 3.8")
95-
endif()
9691

9792
set(LLDB_FRAMEWORK_VERSION A CACHE STRING "LLDB.framework version (default is A)")
9893
set(LLDB_FRAMEWORK_BUILD_DIR bin CACHE STRING "Output directory for LLDB.framework")
@@ -158,9 +153,9 @@ if (LLDB_ENABLE_PYTHON)
158153
"Embed PYTHONHOME in the binary. If set to OFF, PYTHONHOME environment variable will be used to to locate Python."
159154
${default_embed_python_home})
160155

161-
include_directories(${PYTHON_INCLUDE_DIRS})
156+
include_directories(${Python3_INCLUDE_DIRS})
162157
if (LLDB_EMBED_PYTHON_HOME)
163-
get_filename_component(PYTHON_HOME "${PYTHON_EXECUTABLE}" DIRECTORY)
158+
get_filename_component(PYTHON_HOME "${Python3_EXECUTABLE}" DIRECTORY)
164159
set(LLDB_PYTHON_HOME "${PYTHON_HOME}" CACHE STRING
165160
"Path to use as PYTHONHOME in lldb. If a relative path is specified, it will be resolved at runtime relative to liblldb directory.")
166161
endif()

lldb/source/API/CMakeLists.txt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -134,9 +134,9 @@ if(LLDB_ENABLE_PYTHON AND (BUILD_SHARED_LIBS OR LLVM_LINK_LLVM_DYLIB) AND UNIX A
134134
set_property(TARGET liblldb APPEND PROPERTY INSTALL_RPATH "\$ORIGIN/../../../../lib${LLVM_LIBDIR_SUFFIX}")
135135
endif()
136136

137-
if(PYTHON_RPATH)
138-
set_property(TARGET liblldb APPEND PROPERTY INSTALL_RPATH "${PYTHON_RPATH}")
139-
set_property(TARGET liblldb APPEND PROPERTY BUILD_RPATH "${PYTHON_RPATH}")
137+
if(Python3_RPATH)
138+
set_property(TARGET liblldb APPEND PROPERTY INSTALL_RPATH "${Python3_RPATH}")
139+
set_property(TARGET liblldb APPEND PROPERTY BUILD_RPATH "${Python3_RPATH}")
140140
endif()
141141

142142
if (MSVC)
@@ -200,9 +200,9 @@ endif()
200200

201201
if ( CMAKE_SYSTEM_NAME MATCHES "Windows" )
202202
# Only MSVC has the ABI compatibility problem and avoids using FindPythonLibs,
203-
# so only it needs to explicitly link against ${PYTHON_LIBRARIES}
203+
# so only it needs to explicitly link against ${Python3_LIBRARIES}
204204
if (MSVC AND LLDB_ENABLE_PYTHON)
205-
target_link_libraries(liblldb PRIVATE ${PYTHON_LIBRARIES})
205+
target_link_libraries(liblldb PRIVATE ${Python3_LIBRARIES})
206206
endif()
207207
else()
208208
set_target_properties(liblldb

lldb/source/Plugins/ObjectFile/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ add_subdirectory(ELF)
33
add_subdirectory(Mach-O)
44
add_subdirectory(PECOFF)
55
add_subdirectory(JIT)
6-
add_subdirectory(wasm)
6+
add_subdirectory(wasm)

lldb/source/Plugins/ScriptInterpreter/None/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ add_lldb_library(lldbPluginScriptInterpreterNone PLUGIN
44
LINK_LIBS
55
lldbCore
66
lldbInterpreter
7-
)
7+
)

lldb/source/Plugins/ScriptInterpreter/Python/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ add_lldb_library(lldbPluginScriptInterpreterPython PLUGIN
1919
lldbHost
2020
lldbInterpreter
2121
lldbTarget
22-
${PYTHON_LIBRARIES}
22+
${Python3_LIBRARIES}
2323
${LLDB_LIBEDIT_LIBS}
2424

2525
LINK_COMPONENTS

lldb/test/API/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
function(add_python_test_target name test_script args comment)
22
set(PYTHON_TEST_COMMAND
3-
${PYTHON_EXECUTABLE}
3+
${Python3_EXECUTABLE}
44
${test_script}
55
${args}
66
)

0 commit comments

Comments
 (0)