Skip to content

Commit 192b341

Browse files
committed
[lldb] Get rid of helper CMake variables for Python
This patch is a big sed to rename the following variables: s/PYTHON_LIBRARIES/Python3_LIBRARIES/g s/PYTHON_INCLUDE_DIRS/Python3_INCLUDE_DIRS/g s/PYTHON_EXECUTABLE/Python3_EXECUTABLE/g s/PYTHON_RPATH/Python3_RPATH/g I've also renamed the CMake module to better express its purpose and for consistency with FindLuaAndSwig. Differential revision: https://reviews.llvm.org/D85976 (cherry picked from commit 75966ee)
1 parent 1249f40 commit 192b341

File tree

21 files changed

+44
-47
lines changed

21 files changed

+44
-47
lines changed

lldb/CMakeLists.txt

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

4646
if (LLDB_ENABLE_PYTHON)
4747
execute_process(
48-
COMMAND ${PYTHON_EXECUTABLE}
48+
COMMAND ${Python3_EXECUTABLE}
4949
-c "import distutils.sysconfig; print(distutils.sysconfig.get_python_lib(True, False, ''))"
5050
OUTPUT_VARIABLE LLDB_PYTHON_DEFAULT_RELATIVE_PATH
5151
OUTPUT_STRIP_TRAILING_WHITESPACE)

lldb/bindings/python/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ function(create_python_package swig_target working_dir pkg_dir)
2828
set(copy_cmd COMMAND ${CMAKE_COMMAND} -E copy ${ARG_FILES} ${pkg_dir})
2929
endif()
3030
if(NOT ARG_NOINIT)
31-
set(init_cmd COMMAND ${PYTHON_EXECUTABLE}
31+
set(init_cmd COMMAND ${Python3_EXECUTABLE}
3232
"${LLDB_SOURCE_DIR}/bindings/python/createPythonInit.py"
3333
"${pkg_dir}" ${ARG_FILES})
3434
endif()
Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#.rst:
2-
# FindPythonInterpAndLibs
2+
# FindPythonAndSwig
33
# -----------
44
#
55
# Find the python interpreter and libraries as a whole.
@@ -9,9 +9,6 @@ macro(FindPython3)
99
set(Python3_ROOT_DIR "${PYTHON_HOME}")
1010
find_package(Python3 COMPONENTS Interpreter Development)
1111
if(Python3_FOUND AND Python3_Interpreter_FOUND)
12-
set(PYTHON_LIBRARIES ${Python3_LIBRARIES})
13-
set(PYTHON_INCLUDE_DIRS ${Python3_INCLUDE_DIRS})
14-
set(PYTHON_EXECUTABLE ${Python3_EXECUTABLE})
1512

1613
# The install name for the Python 3 framework in Xcode is relative to
1714
# the framework's location and not the dylib itself.
@@ -25,21 +22,21 @@ macro(FindPython3)
2522
# called Python.framework instead of Python3.framework.
2623
if (APPLE AND Python3_LIBRARIES MATCHES "Python3.framework")
2724
string(FIND "${Python3_LIBRARIES}" "Python3.framework" python_framework_pos)
28-
string(SUBSTRING "${Python3_LIBRARIES}" "0" ${python_framework_pos} PYTHON_RPATH)
25+
string(SUBSTRING "${Python3_LIBRARIES}" "0" ${python_framework_pos} Python3_RPATH)
2926
endif()
3027

3128
set(PYTHON3_FOUND TRUE)
3229
mark_as_advanced(
33-
PYTHON_LIBRARIES
34-
PYTHON_INCLUDE_DIRS
35-
PYTHON_EXECUTABLE
36-
PYTHON_RPATH
30+
Python3_LIBRARIES
31+
Python3_INCLUDE_DIRS
32+
Python3_EXECUTABLE
33+
Python3_RPATH
3734
SWIG_EXECUTABLE)
3835
endif()
3936
endmacro()
4037

41-
if(PYTHON_LIBRARIES AND PYTHON_INCLUDE_DIRS AND PYTHON_EXECUTABLE AND SWIG_EXECUTABLE)
42-
set(PYTHONINTERPANDLIBS_FOUND TRUE)
38+
if(Python3_LIBRARIES AND Python3_INCLUDE_DIRS AND Python3_EXECUTABLE AND SWIG_EXECUTABLE)
39+
set(PYTHONANDSWIG_FOUND TRUE)
4340
else()
4441
find_package(SWIG 2.0)
4542
if (SWIG_FOUND)
@@ -49,12 +46,12 @@ else()
4946
endif()
5047

5148
include(FindPackageHandleStandardArgs)
52-
find_package_handle_standard_args(PythonInterpAndLibs
49+
find_package_handle_standard_args(PythonAndSwig
5350
FOUND_VAR
54-
PYTHONINTERPANDLIBS_FOUND
51+
PYTHONANDSWIG_FOUND
5552
REQUIRED_VARS
56-
PYTHON_LIBRARIES
57-
PYTHON_INCLUDE_DIRS
58-
PYTHON_EXECUTABLE
53+
Python3_LIBRARIES
54+
Python3_INCLUDE_DIRS
55+
Python3_EXECUTABLE
5956
SWIG_EXECUTABLE)
6057
endif()

lldb/cmake/modules/LLDBConfig.cmake

Lines changed: 3 additions & 3 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)
@@ -143,9 +143,9 @@ if (LLDB_ENABLE_PYTHON)
143143
"Embed PYTHONHOME in the binary. If set to OFF, PYTHONHOME environment variable will be used to to locate Python."
144144
${default_embed_python_home})
145145

146-
include_directories(${PYTHON_INCLUDE_DIRS})
146+
include_directories(${Python3_INCLUDE_DIRS})
147147
if (LLDB_EMBED_PYTHON_HOME)
148-
get_filename_component(PYTHON_HOME "${PYTHON_EXECUTABLE}" DIRECTORY)
148+
get_filename_component(PYTHON_HOME "${Python3_EXECUTABLE}" DIRECTORY)
149149
set(LLDB_PYTHON_HOME "${PYTHON_HOME}" CACHE STRING
150150
"Path to use as PYTHONHOME in lldb. If a relative path is specified, it will be resolved at runtime relative to liblldb directory.")
151151
endif()

lldb/source/API/CMakeLists.txt

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

124-
if(PYTHON_RPATH)
125-
set_property(TARGET liblldb APPEND PROPERTY INSTALL_RPATH "${PYTHON_RPATH}")
126-
set_property(TARGET liblldb APPEND PROPERTY BUILD_RPATH "${PYTHON_RPATH}")
124+
if(Python3_RPATH)
125+
set_property(TARGET liblldb APPEND PROPERTY INSTALL_RPATH "${Python3_RPATH}")
126+
set_property(TARGET liblldb APPEND PROPERTY BUILD_RPATH "${Python3_RPATH}")
127127
endif()
128128

129129
if (MSVC)
@@ -187,9 +187,9 @@ endif()
187187

188188
if ( CMAKE_SYSTEM_NAME MATCHES "Windows" )
189189
# Only MSVC has the ABI compatibility problem and avoids using FindPythonLibs,
190-
# so only it needs to explicitly link against ${PYTHON_LIBRARIES}
190+
# so only it needs to explicitly link against ${Python3_LIBRARIES}
191191
if (MSVC AND LLDB_ENABLE_PYTHON)
192-
target_link_libraries(liblldb PRIVATE ${PYTHON_LIBRARIES})
192+
target_link_libraries(liblldb PRIVATE ${Python3_LIBRARIES})
193193
endif()
194194
else()
195195
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
)

lldb/test/API/lit.site.cfg.py.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ config.llvm_use_sanitizer = "@LLVM_USE_SANITIZER@"
1919
config.target_triple = "@TARGET_TRIPLE@"
2020
config.lldb_build_directory = "@LLDB_TEST_BUILD_DIRECTORY@"
2121
config.lldb_reproducer_directory = os.path.join("@LLDB_TEST_BUILD_DIRECTORY@", "reproducers")
22-
config.python_executable = "@PYTHON_EXECUTABLE@"
22+
config.python_executable = "@Python3_EXECUTABLE@"
2323
config.dotest_path = "@LLDB_SOURCE_DIR@/test/API/dotest.py"
2424
config.dotest_args_str = "@LLDB_DOTEST_ARGS@"
2525
config.lldb_enable_python = @LLDB_ENABLE_PYTHON@

0 commit comments

Comments
 (0)