qtcreatorcdbext: Deploy LLVM only once

In the multi-architecture build we don't need to copy LLVM multiple
times. Otherwise it copies files from the same source to the same target
multiple times in parallel, which can lead to failures.

Change-Id: I7e3f478560ebbb53690cff21d85b881d047a111d
Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
Eike Ziller
2024-10-11 09:47:52 +02:00
parent acb27cc41c
commit a8f9f742c9

View File

@@ -8,6 +8,10 @@ set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF) set(CMAKE_CXX_EXTENSIONS OFF)
if (NOT DEFINED QTCREATORCDBEXT_INSTALL_LLVM)
set(QTCREATORCDBEXT_INSTALL_LLVM YES) # default
endif()
if (NOT QT_CREATOR_API_DEFINED) if (NOT QT_CREATOR_API_DEFINED)
# standalone build # standalone build
include(QtCreatorIDEBranding) include(QtCreatorIDEBranding)
@@ -25,7 +29,7 @@ if (NOT QT_CREATOR_API_DEFINED)
string(REPLACE ";" "|" CMAKE_PREFIX_PATH_ALT_SEP "${CMAKE_PREFIX_PATH}") string(REPLACE ";" "|" CMAKE_PREFIX_PATH_ALT_SEP "${CMAKE_PREFIX_PATH}")
macro (setup_library arch) macro (setup_library arch install_llvm)
ExternalProject_Add(${arch}-bld ExternalProject_Add(${arch}-bld
SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}" SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}"
CMAKE_GENERATOR "${generator}" CMAKE_GENERATOR "${generator}"
@@ -36,6 +40,7 @@ if (NOT QT_CREATOR_API_DEFINED)
-DPythonTargetArchDll=${PythonTarget${arch}Dll} -DPythonTargetArchDll=${PythonTarget${arch}Dll}
-DPython3_ROOT_DIR=${Python3_ROOT_DIR} -DPython3_ROOT_DIR=${Python3_ROOT_DIR}
-DCMAKE_PREFIX_PATH=${CMAKE_PREFIX_PATH_ALT_SEP} -DCMAKE_PREFIX_PATH=${CMAKE_PREFIX_PATH_ALT_SEP}
-DQTCREATORCDBEXT_INSTALL_LLVM=${install_llvm}
BUILD_COMMAND BUILD_COMMAND
${CMAKE_COMMAND} --build . --config ${CMAKE_BUILD_TYPE} ${CMAKE_COMMAND} --build . --config ${CMAKE_BUILD_TYPE}
INSTALL_COMMAND INSTALL_COMMAND
@@ -47,8 +52,10 @@ if (NOT QT_CREATOR_API_DEFINED)
if (NOT QTCREATORCDBEXT_BUILD_ARCHS) if (NOT QTCREATORCDBEXT_BUILD_ARCHS)
set(QTCREATORCDBEXT_BUILD_ARCHS arm64 win32 x64) set(QTCREATORCDBEXT_BUILD_ARCHS arm64 win32 x64)
endif() endif()
set(install_llvm YES)
foreach(arch IN LISTS QTCREATORCDBEXT_BUILD_ARCHS) foreach(arch IN LISTS QTCREATORCDBEXT_BUILD_ARCHS)
setup_library(${arch}) setup_library(${arch} ${install_llvm})
set(install_llvm NO)
endforeach() endforeach()
list(LENGTH QTCREATORCDBEXT_BUILD_ARCHS build_archs_length) list(LENGTH QTCREATORCDBEXT_BUILD_ARCHS build_archs_length)
@@ -60,6 +67,7 @@ if (NOT QT_CREATOR_API_DEFINED)
) )
install(CODE install(CODE
"if (EXISTS \"${CMAKE_BINARY_DIR}/bin\") "if (EXISTS \"${CMAKE_BINARY_DIR}/bin\")
message(\"Copying ${CMAKE_BINARY_DIR}/bin to ${CMAKE_INSTALL_PREFIX}\")
file(COPY \"${CMAKE_BINARY_DIR}/bin\" DESTINATION \"${CMAKE_INSTALL_PREFIX}\") file(COPY \"${CMAKE_BINARY_DIR}/bin\" DESTINATION \"${CMAKE_INSTALL_PREFIX}\")
endif()" endif()"
COMPONENT qtcreatorcdbext COMPONENT qtcreatorcdbext
@@ -274,22 +282,24 @@ if (_library_enabled)
VERBATIM VERBATIM
) )
# Deploy lldb.exe and its Python dependency if (QTCREATORCDBEXT_INSTALL_LLVM)
find_package(Clang QUIET) # Deploy lldb.exe and its Python dependency
if (LLVM_TOOLS_BINARY_DIR AND LLVM_LIBRARY_DIRS) find_package(Clang QUIET)
foreach(lldb_file lldb.exe lldb-dap.exe liblldb.dll python311.zip python311.dll) if (LLVM_TOOLS_BINARY_DIR AND LLVM_LIBRARY_DIRS)
if (EXISTS ${LLVM_TOOLS_BINARY_DIR}/${lldb_file}) foreach(lldb_file lldb.exe lldb-dap.exe liblldb.dll python311.zip python311.dll)
install(FILES ${LLVM_TOOLS_BINARY_DIR}/${lldb_file} if (EXISTS ${LLVM_TOOLS_BINARY_DIR}/${lldb_file})
DESTINATION bin/clang/bin install(FILES ${LLVM_TOOLS_BINARY_DIR}/${lldb_file}
COMPONENT qtcreatorcdbext) DESTINATION bin/clang/bin
endif() COMPONENT qtcreatorcdbext)
endforeach() endif()
endforeach()
if (EXISTS ${LLVM_LIBRARY_DIRS}/site-packages) if (EXISTS ${LLVM_LIBRARY_DIRS}/site-packages)
install(DIRECTORY ${LLVM_LIBRARY_DIRS}/site-packages install(DIRECTORY ${LLVM_LIBRARY_DIRS}/site-packages
DESTINATION bin/clang/lib DESTINATION bin/clang/lib
COMPONENT qtcreatorcdbext COMPONENT qtcreatorcdbext
PATTERN _lldb.cp311-win_amd64.pyd EXCLUDE) PATTERN _lldb.cp311-win_amd64.pyd EXCLUDE)
endif()
endif() endif()
endif() endif()