[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
This commit is contained in:
Zachary Turner 2015-02-17 22:20:29 +00:00
parent 7513e82075
commit aeda626d80
2 changed files with 11 additions and 11 deletions

View File

@ -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 ()

View File

@ -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}