[Lldb-commits] [lldb] r334968 - Introduce lldb-framework CMake target and centralize its logic
Alex Langford via lldb-commits
lldb-commits at lists.llvm.org
Mon Jun 18 11:27:16 PDT 2018
Author: xiaobai
Date: Mon Jun 18 11:27:16 2018
New Revision: 334968
URL: http://llvm.org/viewvc/llvm-project?rev=334968&view=rev
Log:
Introduce lldb-framework CMake target and centralize its logic
Summary:
In this patch I aim to do the following:
1) Create an lldb-framework target that acts as the target that handles generating LLDB.framework. Previously, liblldb acted as the target for generating the framework in addition to generating the actual lldb library. This made the target feel overloaded.
2) Centralize framework generation as much as it makes sense to do so.
3) Create a target lldb-suite, which depends on every tool and library that makes liblldb fully functional. One result of having this target is it makes tracking dependencies much clearer.
Differential Revision: https://reviews.llvm.org/D48060
Added:
lldb/trunk/cmake/modules/LLDBFramework.cmake
Modified:
lldb/trunk/CMakeLists.txt
lldb/trunk/cmake/modules/AddLLDB.cmake
lldb/trunk/source/API/CMakeLists.txt
lldb/trunk/tools/argdumper/CMakeLists.txt
lldb/trunk/tools/darwin-debug/CMakeLists.txt
lldb/trunk/tools/debugserver/source/CMakeLists.txt
lldb/trunk/tools/driver/CMakeLists.txt
lldb/trunk/tools/lldb-server/CMakeLists.txt
Modified: lldb/trunk/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/CMakeLists.txt?rev=334968&r1=334967&r2=334968&view=diff
==============================================================================
--- lldb/trunk/CMakeLists.txt (original)
+++ lldb/trunk/CMakeLists.txt Mon Jun 18 11:27:16 2018
@@ -37,7 +37,18 @@ if(APPLE)
add_definitions(-DLLDB_USE_OS_LOG)
endif()
+# lldb-suite is a dummy target that encompasses all the necessary tools and
+# libraries for building a fully-functioning liblldb.
+add_custom_target(lldb-suite)
+
+option(LLDB_BUILD_FRAMEWORK "Build the Darwin LLDB.framework" Off)
if(LLDB_BUILD_FRAMEWORK)
+ if (CMAKE_VERSION VERSION_LESS 3.7)
+ message(FATAL_ERROR "LLDB_BUILD_FRAMEWORK is not supported on CMake < 3.7")
+ endif()
+ if (NOT APPLE)
+ message(FATAL_ERROR "LLDB.framework can only be generated when targeting Apple platforms")
+ endif()
set(LLDB_FRAMEWORK_DIR
${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/${LLDB_FRAMEWORK_INSTALL_DIR})
endif()
@@ -129,6 +140,12 @@ if(LLDB_INCLUDE_TESTS)
add_subdirectory(utils/lldb-dotest)
endif()
+if (LLDB_BUILD_FRAMEWORK)
+ add_custom_target(lldb-framework)
+ include(LLDBFramework)
+ add_dependencies(lldb-suite lldb-framework)
+endif()
+
if (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)
@@ -147,8 +164,9 @@ if (NOT LLDB_DISABLE_PYTHON)
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/scripts/finishSwigWrapperClasses.py
DEPENDS ${LLDB_PYTHON_TARGET_DIR}/lldb.py
COMMENT "Python script sym-linking LLDB Python API")
- # We depend on liblldb being built before we can do this step.
- add_dependencies(finish_swig liblldb lldb-argdumper)
+
+ # We depend on liblldb and lldb-argdumper being built before we can do this step.
+ add_dependencies(finish_swig lldb-suite)
# If we build the readline module, we depend on that happening
# first.
@@ -159,8 +177,8 @@ if (NOT LLDB_DISABLE_PYTHON)
# Ensure we do the python post-build step when building lldb.
add_dependencies(lldb finish_swig)
- if(LLDB_BUILD_FRAMEWORK)
- # The target to install libLLDB needs to depend on finish swig so that the
+ if (LLDB_BUILD_FRAMEWORK)
+ # The target to install libLLDB needs to depend on finish_swig so that the
# framework build properly copies over the Python files.
add_dependencies(install-liblldb finish_swig)
endif()
Modified: lldb/trunk/cmake/modules/AddLLDB.cmake
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/cmake/modules/AddLLDB.cmake?rev=334968&r1=334967&r2=334968&view=diff
==============================================================================
--- lldb/trunk/cmake/modules/AddLLDB.cmake (original)
+++ lldb/trunk/cmake/modules/AddLLDB.cmake Mon Jun 18 11:27:16 2018
@@ -86,7 +86,7 @@ endfunction(add_lldb_library)
function(add_lldb_executable name)
cmake_parse_arguments(ARG
- "INCLUDE_IN_FRAMEWORK;GENERATE_INSTALL"
+ "INCLUDE_IN_SUITE;GENERATE_INSTALL"
""
"LINK_LIBS;LINK_COMPONENTS"
${ARGN}
@@ -99,8 +99,9 @@ function(add_lldb_executable name)
set_target_properties(${name} PROPERTIES
FOLDER "lldb executables")
- if(LLDB_BUILD_FRAMEWORK)
- if(ARG_INCLUDE_IN_FRAMEWORK)
+ if(ARG_INCLUDE_IN_SUITE)
+ add_dependencies(lldb-suite ${name})
+ if(LLDB_BUILD_FRAMEWORK)
if(NOT IOS)
set(resource_dir "/Resources")
set(resource_dots "../")
@@ -122,14 +123,16 @@ function(add_lldb_executable name)
add_custom_target(install-${name}-stripped DEPENDS ${name})
add_dependencies(install-liblldb-stripped ${name})
endif()
- else()
- set_target_properties(${name} PROPERTIES
- BUILD_WITH_INSTALL_RPATH On
- INSTALL_RPATH "@loader_path/../${LLDB_FRAMEWORK_INSTALL_DIR}")
endif()
endif()
- if(ARG_GENERATE_INSTALL AND NOT (ARG_INCLUDE_IN_FRAMEWORK AND LLDB_BUILD_FRAMEWORK ))
+ if(LLDB_BUILD_FRAMEWORK AND NOT ARG_INCLUDE_IN_SUITE)
+ set_target_properties(${name} PROPERTIES
+ BUILD_WITH_INSTALL_RPATH On
+ INSTALL_RPATH "@loader_path/../${LLDB_FRAMEWORK_INSTALL_DIR}")
+ endif()
+
+ if(ARG_GENERATE_INSTALL AND NOT (ARG_INCLUDE_IN_SUITE AND LLDB_BUILD_FRAMEWORK ))
install(TARGETS ${name}
COMPONENT ${name}
RUNTIME DESTINATION bin)
@@ -140,7 +143,7 @@ function(add_lldb_executable name)
endif()
endif()
- if(ARG_INCLUDE_IN_FRAMEWORK AND LLDB_BUILD_FRAMEWORK)
+ if(ARG_INCLUDE_IN_SUITE AND LLDB_BUILD_FRAMEWORK)
add_llvm_tool_symlink(${name} ${name} ALWAYS_GENERATE SKIP_INSTALL
OUTPUT_DIR ${LLVM_RUNTIME_OUTPUT_INTDIR})
endif()
Added: lldb/trunk/cmake/modules/LLDBFramework.cmake
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/cmake/modules/LLDBFramework.cmake?rev=334968&view=auto
==============================================================================
--- lldb/trunk/cmake/modules/LLDBFramework.cmake (added)
+++ lldb/trunk/cmake/modules/LLDBFramework.cmake Mon Jun 18 11:27:16 2018
@@ -0,0 +1,44 @@
+file(GLOB public_headers ${LLDB_SOURCE_DIR}/include/lldb/API/*.h)
+file(GLOB root_public_headers ${LLDB_SOURCE_DIR}/include/lldb/lldb-*.h)
+file(GLOB root_private_headers ${LLDB_SOURCE_DIR}/include/lldb/lldb-private*.h)
+list(REMOVE_ITEM root_public_headers ${root_private_headers})
+foreach(header
+ ${public_headers}
+ ${root_public_headers}
+ ${LLDB_SOURCE_DIR}/include/lldb/Utility/SharingPtr.h)
+ get_filename_component(basename ${header} NAME)
+ add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/FrameworkHeaders/${basename}
+ DEPENDS ${header}
+ COMMAND ${CMAKE_COMMAND} -E copy ${header} ${CMAKE_CURRENT_BINARY_DIR}/FrameworkHeaders/${basename})
+ list(APPEND framework_headers ${CMAKE_CURRENT_BINARY_DIR}/FrameworkHeaders/${basename})
+endforeach()
+add_custom_target(lldb-framework-headers
+ DEPENDS ${framework_headers}
+ COMMAND ${LLDB_SOURCE_DIR}/scripts/framework-header-fix.sh ${CMAKE_CURRENT_BINARY_DIR} ${LLDB_VERSION})
+
+if (NOT IOS)
+ if (NOT LLDB_BUILT_STANDALONE)
+ add_dependencies(lldb-framework clang-headers)
+ endif()
+ add_custom_command(TARGET lldb-framework POST_BUILD
+ COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_BINARY_DIR}/FrameworkHeaders $<TARGET_FILE_DIR:liblldb>/Headers
+ COMMAND ${CMAKE_COMMAND} -E create_symlink Versions/Current/Headers ${CMAKE_BINARY_DIR}/${LLDB_FRAMEWORK_INSTALL_DIR}/LLDB.framework/Headers
+ COMMAND ${CMAKE_COMMAND} -E create_symlink ${LLDB_FRAMEWORK_VERSION} ${CMAKE_BINARY_DIR}/${LLDB_FRAMEWORK_INSTALL_DIR}/LLDB.framework/Versions/Current
+ COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX}/clang/${LLDB_VERSION} $<TARGET_FILE_DIR:liblldb>/Resources/Clang
+ )
+else()
+ add_custom_command(TARGET lldb-framework POST_BUILD
+ COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_BINARY_DIR}/FrameworkHeaders $<TARGET_FILE_DIR:liblldb>/Headers
+ )
+endif()
+
+set_target_properties(liblldb PROPERTIES
+ OUTPUT_NAME LLDB
+ FRAMEWORK On
+ FRAMEWORK_VERSION ${LLDB_FRAMEWORK_VERSION}
+ LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${LLDB_FRAMEWORK_INSTALL_DIR}
+ PUBLIC_HEADER "${framework_headers}")
+
+add_dependencies(lldb-framework
+ liblldb
+ lldb-framework-headers)
Modified: lldb/trunk/source/API/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/CMakeLists.txt?rev=334968&r1=334967&r2=334968&view=diff
==============================================================================
--- lldb/trunk/source/API/CMakeLists.txt (original)
+++ lldb/trunk/source/API/CMakeLists.txt Mon Jun 18 11:27:16 2018
@@ -2,16 +2,6 @@ if ( CMAKE_SYSTEM_NAME MATCHES "Windows"
add_definitions( -DEXPORT_LIBLLDB )
endif()
-option(LLDB_BUILD_FRAMEWORK "Build the Darwin LLDB.framework" Off)
-
-if(LLDB_BUILD_FRAMEWORK AND CMAKE_VERSION VERSION_LESS 3.7)
- message(FATAL_ERROR "LLDB_BUILD_FRAMEWORK is not supported on CMake < 3.7")
-endif()
-
-if (LLDB_BUILD_FRAMEWORK AND NOT APPLE)
- message(FATAL_ERROR "LLDB.framework cannot be generated unless targeting Apple platforms.")
-endif()
-
get_property(LLDB_ALL_PLUGINS GLOBAL PROPERTY LLDB_PLUGINS)
add_lldb_library(liblldb SHARED
@@ -159,47 +149,3 @@ endif()
if (LLDB_WRAP_PYTHON)
add_dependencies(liblldb swig_wrapper)
endif()
-
-if(LLDB_BUILD_FRAMEWORK)
- file(GLOB public_headers ${LLDB_SOURCE_DIR}/include/lldb/API/*.h)
- file(GLOB root_public_headers ${LLDB_SOURCE_DIR}/include/lldb/lldb-*.h)
- file(GLOB root_private_headers ${LLDB_SOURCE_DIR}/include/lldb/lldb-private*.h)
- list(REMOVE_ITEM root_public_headers ${root_private_headers})
-
- foreach(header ${public_headers} ${root_public_headers} ${LLDB_SOURCE_DIR}/include/lldb/Utility/SharingPtr.h)
- get_filename_component(basename ${header} NAME)
- add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/FrameworkHeaders/${basename}
- DEPENDS ${header}
- COMMAND ${CMAKE_COMMAND} -E copy ${header} ${CMAKE_CURRENT_BINARY_DIR}/FrameworkHeaders/${basename})
- list(APPEND framework_headers ${CMAKE_CURRENT_BINARY_DIR}/FrameworkHeaders/${basename})
- endforeach()
-
- add_custom_target(lldb-framework-headers DEPENDS ${framework_headers}
- COMMAND ${LLDB_SOURCE_DIR}/scripts/framework-header-fix.sh ${CMAKE_CURRENT_BINARY_DIR}/FrameworkHeaders ${LLDB_VERSION})
- add_dependencies(liblldb lldb-framework-headers)
-
- set_target_properties(liblldb PROPERTIES
- OUTPUT_NAME LLDB
- FRAMEWORK On
- FRAMEWORK_VERSION ${LLDB_FRAMEWORK_VERSION}
- LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${LLDB_FRAMEWORK_INSTALL_DIR}
- PUBLIC_HEADER "${framework_headers}")
-
- if(NOT IOS)
- if (NOT LLDB_BUILT_STANDALONE)
- add_dependencies(liblldb clang-headers)
- endif()
- add_custom_command(TARGET liblldb POST_BUILD
- COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_BINARY_DIR}/FrameworkHeaders $<TARGET_FILE_DIR:liblldb>/Headers
- COMMAND ${CMAKE_COMMAND} -E create_symlink Versions/Current/Headers ${CMAKE_BINARY_DIR}/${LLDB_FRAMEWORK_INSTALL_DIR}/LLDB.framework/Headers
- COMMAND ${CMAKE_COMMAND} -E create_symlink ${LLDB_FRAMEWORK_VERSION} ${CMAKE_BINARY_DIR}/${LLDB_FRAMEWORK_INSTALL_DIR}/LLDB.framework/Versions/Current
- COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX}/clang/${LLDB_VERSION} $<TARGET_FILE_DIR:liblldb>/Resources/Clang
- )
- else()
- add_custom_command(TARGET liblldb POST_BUILD
- COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_BINARY_DIR}/FrameworkHeaders $<TARGET_FILE_DIR:liblldb>/Headers
- )
- endif()
-
-endif()
-
Modified: lldb/trunk/tools/argdumper/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/argdumper/CMakeLists.txt?rev=334968&r1=334967&r2=334968&view=diff
==============================================================================
--- lldb/trunk/tools/argdumper/CMakeLists.txt (original)
+++ lldb/trunk/tools/argdumper/CMakeLists.txt Mon Jun 18 11:27:16 2018
@@ -1,4 +1,4 @@
-add_lldb_tool(lldb-argdumper INCLUDE_IN_FRAMEWORK
+add_lldb_tool(lldb-argdumper INCLUDE_IN_SUITE
argdumper.cpp
LINK_LIBS
Modified: lldb/trunk/tools/darwin-debug/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/darwin-debug/CMakeLists.txt?rev=334968&r1=334967&r2=334968&view=diff
==============================================================================
--- lldb/trunk/tools/darwin-debug/CMakeLists.txt (original)
+++ lldb/trunk/tools/darwin-debug/CMakeLists.txt Mon Jun 18 11:27:16 2018
@@ -1,3 +1,3 @@
-add_lldb_tool(darwin-debug INCLUDE_IN_FRAMEWORK
+add_lldb_tool(darwin-debug INCLUDE_IN_SUITE
darwin-debug.cpp
)
Modified: lldb/trunk/tools/debugserver/source/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/CMakeLists.txt?rev=334968&r1=334967&r2=334968&view=diff
==============================================================================
--- lldb/trunk/tools/debugserver/source/CMakeLists.txt (original)
+++ lldb/trunk/tools/debugserver/source/CMakeLists.txt Mon Jun 18 11:27:16 2018
@@ -161,7 +161,7 @@ if(NOT SKIP_DEBUGSERVER)
COMPILE_DEFINITIONS HAVE_LIBCOMPRESSION)
endif()
set(LLVM_OPTIONAL_SOURCES ${lldbDebugserverCommonSources})
- add_lldb_tool(debugserver INCLUDE_IN_FRAMEWORK
+ add_lldb_tool(debugserver INCLUDE_IN_SUITE
debugserver.cpp
LINK_LIBS
Modified: lldb/trunk/tools/driver/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/driver/CMakeLists.txt?rev=334968&r1=334967&r2=334968&view=diff
==============================================================================
--- lldb/trunk/tools/driver/CMakeLists.txt (original)
+++ lldb/trunk/tools/driver/CMakeLists.txt Mon Jun 18 11:27:16 2018
@@ -24,12 +24,4 @@ if ( CMAKE_SYSTEM_NAME MATCHES "Windows"
add_definitions( -DIMPORT_LIBLLDB )
endif()
-# Add lldb dependency on lldb-server if we can use it.
-if ( LLDB_CAN_USE_LLDB_SERVER )
- add_dependencies(lldb lldb-server)
-endif()
-
-# Add lldb dependency on debugserver if we can use it.
-if ( LLDB_CAN_USE_DEBUGSERVER )
- add_dependencies(lldb debugserver)
-endif()
+add_dependencies(lldb lldb-suite)
Modified: lldb/trunk/tools/lldb-server/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/lldb-server/CMakeLists.txt?rev=334968&r1=334967&r2=334968&view=diff
==============================================================================
--- lldb/trunk/tools/lldb-server/CMakeLists.txt (original)
+++ lldb/trunk/tools/lldb-server/CMakeLists.txt Mon Jun 18 11:27:16 2018
@@ -42,7 +42,7 @@ else()
list(APPEND LLDB_PLUGINS lldbPluginObjectFileELF)
endif()
-add_lldb_tool(lldb-server INCLUDE_IN_FRAMEWORK
+add_lldb_tool(lldb-server INCLUDE_IN_SUITE
Acceptor.cpp
lldb-gdbserver.cpp
lldb-platform.cpp
More information about the lldb-commits
mailing list