Skip to content

Commit 7c67fc2

Browse files
committed
LLDB: Generate and install Python.zip and shared library file (3)
Fixes build on Linux. Change-Id: Ie06b91d5825bf1c4aa447adae6889560f842673a Reviewed-by: Cristian Adam <[email protected]>
1 parent 7c16c1e commit 7c67fc2

File tree

2 files changed

+18
-12
lines changed

2 files changed

+18
-12
lines changed

lldb/CMakeLists.txt

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -73,29 +73,37 @@ if (LLDB_ENABLE_PYTHON)
7373
endforeach()
7474

7575
# For Python3.dll and Python3.zip deployment
76-
find_package(Python3 3.8 COMPONENTS Development)
76+
find_package(Python3 3.8 COMPONENTS Interpreter Development)
7777

7878
if (NOT ${Python3_Development_FOUND})
7979
message(WARNING "PythonLibs (at least version 3.8) not found. qtcreatorcdbext will be built without Python support.")
8080
return()
8181
endif()
8282

83-
set(PythonRegex "^(.*)/(.*)/(python([0-9]+))\.[a-z]+$")
83+
84+
set(PythonNameWithVersion "${CMAKE_SHARED_LIBRARY_PREFIX}python${Python3_VERSION_MAJOR}.${Python3_VERSION_MINOR}")
85+
set(PythonVersion "${Python3_VERSION_MAJOR}${Python3_VERSION_MINOR}")
86+
if (WIN32)
87+
set(PythonNameWithVersion "python${Python3_VERSION_MAJOR}${Python3_VERSION_MINOR}")
88+
endif()
89+
90+
set(PythonRegex "^(.*)/(.*)/${PythonNameWithVersion}\.[a-z]+$")
8491
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
85-
set(PythonRegex "^(.*)/(.*)/(python([0-9]+)_d)\.[a-z]+$")
92+
set(PythonRegex "^(.*)/(.*)/${PythonNameWithVersion}_d\.[a-z]+$")
8693
endif()
8794

8895
foreach(lib IN LISTS Python3_LIBRARIES)
8996
if (lib MATCHES ${PythonRegex})
9097
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
91-
set(PythonZipFileName "python${CMAKE_MATCH_4}_d.zip")
98+
set(PythonZipFileName "python${PythonVersion}_d.zip")
9299
else()
93-
set(PythonZipFileName "python${CMAKE_MATCH_4}.zip")
100+
set(PythonZipFileName "python${PythonVersion}.zip")
94101
endif()
95-
set(PythonNameWithVersion "${CMAKE_MATCH_3}")
96102

97-
set(PythonDll "${CMAKE_MATCH_1}/${PythonNameWithVersion}${CMAKE_SHARED_LIBRARY_SUFFIX}")
98-
set(PythonExe "${CMAKE_MATCH_1}/python${CMAKE_EXECUTABLE_SUFFIX}")
103+
set(PythonDll "${lib}")
104+
if (WIN32)
105+
set(PythonDll "${CMAKE_MATCH_1}/${PythonNameWithVersion}${CMAKE_SHARED_LIBRARY_SUFFIX}")
106+
endif()
99107
set(PythonZip "${CMAKE_MATCH_1}/${PythonZipFileName}")
100108

101109
break()
@@ -105,7 +113,7 @@ if (LLDB_ENABLE_PYTHON)
105113
if (NOT EXISTS "${PythonZip}" AND
106114
NOT EXISTS "${CMAKE_CURRENT_BINARY_DIR}/${PythonZipFileName}")
107115
include(CreatePythonXY)
108-
create_python_xy("${PythonExe}" "${CMAKE_CURRENT_BINARY_DIR}/${PythonZipFileName}")
116+
create_python_xy("${Python3_EXECUTABLE}" "${Python3_STDLIB}" "${CMAKE_CURRENT_BINARY_DIR}/${PythonZipFileName}")
109117
endif()
110118

111119
if (NOT EXISTS "${PythonZip}" AND

lldb/cmake/modules/CreatePythonXY.cmake

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
# create_python_xy function will precompile the Python/lib/*.py files
22
# and create a zip file containing all the pyc files
3-
function(create_python_xy PythonExe PythonZipFilePath)
4-
get_filename_component(python_lib_dir "${PythonExe}" DIRECTORY)
5-
get_filename_component(python_lib_dir "${python_lib_dir}/Lib" ABSOLUTE)
3+
function(create_python_xy PythonExe python_lib_dir PythonZipFilePath)
64
foreach(dir collections encodings importlib json urllib re)
75
file(COPY ${python_lib_dir}/${dir}
86
DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/python-lib

0 commit comments

Comments
 (0)