From aeda626d8080c403c18cfe6a9aae5b04ece0a9a5 Mon Sep 17 00:00:00 2001 From: Zachary Turner Date: Tue, 17 Feb 2015 22:20:29 +0000 Subject: [PATCH] [CMake] Create a custom target for generating extension module. Previously we would create the extension module as a post-build step of creating liblldb. As part of this process, we created symlinks and did other stuff. This had several longstanding issues related to target dependencies, such as not re-creating the symlink if liblldb.dll failed to link, or if the build was Ctrl+C'ed from. Then, the script that creates the symlinks began to grow to include other things, such as argdumper, and it would try to create symlinks before it had finished building the targets it needed to symlink to. This patches addresses all of these problems by creating an explicit target for the script to run, and making it have a dependency on all the targets it needs to create symlinks from/to. llvm-svn: 229569 --- lldb/CMakeLists.txt | 10 ++++++++++ lldb/source/CMakeLists.txt | 12 +----------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/lldb/CMakeLists.txt b/lldb/CMakeLists.txt index 65c5b2ab9689..efc866dad6c8 100644 --- a/lldb/CMakeLists.txt +++ b/lldb/CMakeLists.txt @@ -375,3 +375,13 @@ endif () add_subdirectory(source) add_subdirectory(test) add_subdirectory(tools) + + +if ( LLDB_ENABLE_PYTHON_SCRIPTS_SWIG_API_GENERATION AND NOT LLDB_DISABLE_PYTHON ) + # Add a Post-Build Event to copy over Python files and create the symlink to liblldb.so for the Python API(hardlink on Windows) + add_custom_target( finish_swig ALL + COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/scripts/finishSwigWrapperClasses.py --buildConfig=${CMAKE_BUILD_TYPE} "--srcRoot=${LLDB_SOURCE_DIR}" "--targetDir=${CMAKE_CURRENT_BINARY_DIR}/scripts" "--cfgBldDir=${CMAKE_CURRENT_BINARY_DIR}/scripts" "--prefix=${CMAKE_BINARY_DIR}" "--cmakeBuildConfiguration=${CMAKE_CFG_INTDIR}" -m + DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/scripts/finishSwigWrapperClasses.py + COMMENT "Python script sym-linking LLDB Python API") + add_dependencies(finish_swig liblldb argdumper) +endif () diff --git a/lldb/source/CMakeLists.txt b/lldb/source/CMakeLists.txt index 8c9c7526ae2d..ee97a8c1afd3 100644 --- a/lldb/source/CMakeLists.txt +++ b/lldb/source/CMakeLists.txt @@ -65,6 +65,7 @@ endif() if (LLDB_WRAP_PYTHON OR LLDB_VERS_GENERATED_FILE) add_dependencies(liblldb swig_wrapper) + message("Adding dependency on swig_wrapper") endif() target_link_libraries(liblldb ${cmake_2_8_12_PRIVATE} ${LLDB_SYSTEM_LIBS}) @@ -94,17 +95,6 @@ endif () # FIXME: implement svn/git revision and repository parsing solution on Windows. There is an SVN-only # revision parsing solution in tools/clang/lib/Basic/CMakelists.txt. -if ( LLDB_ENABLE_PYTHON_SCRIPTS_SWIG_API_GENERATION ) - # Add a Post-Build Event to copy over Python files and create the symlink to liblldb.so for the Python API(hardlink on Windows) - if ( NOT LLDB_DISABLE_PYTHON ) - add_custom_command( TARGET liblldb - POST_BUILD - DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/../scripts/finishSwigWrapperClasses.py - COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/../scripts/finishSwigWrapperClasses.py --buildConfig=${CMAKE_BUILD_TYPE} "--srcRoot=${LLDB_SOURCE_DIR}" "--targetDir=${CMAKE_CURRENT_BINARY_DIR}/../scripts" "--cfgBldDir=${CMAKE_CURRENT_BINARY_DIR}/../scripts" "--prefix=${CMAKE_BINARY_DIR}" "--cmakeBuildConfiguration=${CMAKE_CFG_INTDIR}" -m - COMMENT "Python script sym-linking LLDB Python API") - endif () -endif () - install(TARGETS liblldb RUNTIME DESTINATION bin LIBRARY DESTINATION lib${LLVM_LIBDIR_SUFFIX}