[Lldb-commits] [lldb] r361946 - [CMake] LLDB.framework tools handling

Stefan Granitz via lldb-commits lldb-commits at lists.llvm.org
Wed May 29 04:26:06 PDT 2019


Author: stefan.graenitz
Date: Wed May 29 04:26:06 2019
New Revision: 361946

URL: http://llvm.org/viewvc/llvm-project?rev=361946&view=rev
Log:
[CMake] LLDB.framework tools handling

Summary:
Modify the way LLDB.framework tools are collected. This allows for better fine-tuning of the install behavior downstream. Each target calls `lldb_add_to_framework()` individually. When entering the function, the target exists and we can tweak its very own post-build and install steps. This was not possible with the old `LLDB_FRAMEWORK_TOOLS` approach.

No function change otherwise.
This is a reduced follow-up from the proposal in D61952.

Reviewers: xiaobai, compnerd, JDevlieghere

Reviewed By: JDevlieghere

Subscribers: clayborg, friss, ki.stfu, mgorny, lldb-commits, labath, #lldb

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D62472

Modified:
    lldb/trunk/CMakeLists.txt
    lldb/trunk/cmake/modules/AddLLDB.cmake
    lldb/trunk/cmake/modules/LLDBConfig.cmake
    lldb/trunk/cmake/modules/LLDBFramework.cmake
    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-mi/CMakeLists.txt
    lldb/trunk/tools/lldb-server/CMakeLists.txt
    lldb/trunk/tools/lldb-vscode/CMakeLists.txt

Modified: lldb/trunk/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/CMakeLists.txt?rev=361946&r1=361945&r2=361946&view=diff
==============================================================================
--- lldb/trunk/CMakeLists.txt (original)
+++ lldb/trunk/CMakeLists.txt Wed May 29 04:26:06 2019
@@ -151,6 +151,10 @@ if(LLDB_INCLUDE_TESTS)
     list(APPEND LLDB_TEST_DEPS dsymutil)
   endif()
 
+  if(TARGET lldb-framework)
+    list(APPEND LLDB_TEST_DEPS lldb-framework)
+  endif()
+
   add_custom_target(lldb-test-deps)
   add_dependencies(lldb-test-deps ${LLDB_TEST_DEPS})
   set_target_properties(lldb-test-deps PROPERTIES FOLDER "lldb misc")

Modified: lldb/trunk/cmake/modules/AddLLDB.cmake
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/cmake/modules/AddLLDB.cmake?rev=361946&r1=361945&r2=361946&view=diff
==============================================================================
--- lldb/trunk/cmake/modules/AddLLDB.cmake (original)
+++ lldb/trunk/cmake/modules/AddLLDB.cmake Wed May 29 04:26:06 2019
@@ -208,3 +208,32 @@ function(lldb_setup_framework_rpaths_in_
 
   add_dependencies(${name} lldb-framework)
 endfunction()
+
+# Unified handling for executable LLDB.framework resources. Given the name of an
+# executable target, this function adds a post-build step to copy it to the
+# framework bundle in the build-tree.
+function(lldb_add_to_framework name)
+  set(subdir "LLDB.framework/Versions/${LLDB_FRAMEWORK_VERSION}/Resources")
+
+  # Destination for the copy in the build-tree. While the framework target may
+  # not exist yet, it will exist when the generator expression gets expanded.
+  set(copy_dest "$<TARGET_FILE_DIR:liblldb>/../../../${subdir}")
+
+  # Copy into the framework's Resources directory for testing.
+  add_custom_command(TARGET ${name} POST_BUILD
+    COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:${name}> ${copy_dest}
+    COMMENT "Copy ${name} to ${copy_dest}"
+  )
+endfunction()
+
+# CMake's set_target_properties() doesn't allow to pass lists for RPATH
+# properties directly (error: "called with incorrect number of arguments").
+# Instead of defining two list variables each time, use this helper function.
+function(lldb_setup_rpaths name)
+  cmake_parse_arguments(LIST "" "" "BUILD_RPATH;INSTALL_RPATH" ${ARGN})
+  set_target_properties(${name} PROPERTIES
+    BUILD_WITH_INSTALL_RPATH OFF
+    BUILD_RPATH "${LIST_BUILD_RPATH}"
+    INSTALL_RPATH "${LIST_INSTALL_RPATH}"
+  )
+endfunction()
\ No newline at end of file

Modified: lldb/trunk/cmake/modules/LLDBConfig.cmake
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/cmake/modules/LLDBConfig.cmake?rev=361946&r1=361945&r2=361946&view=diff
==============================================================================
--- lldb/trunk/cmake/modules/LLDBConfig.cmake (original)
+++ lldb/trunk/cmake/modules/LLDBConfig.cmake Wed May 29 04:26:06 2019
@@ -64,8 +64,6 @@ if(LLDB_BUILD_FRAMEWORK)
   set(LLDB_FRAMEWORK_VERSION A CACHE STRING "LLDB.framework version (default is A)")
   set(LLDB_FRAMEWORK_BUILD_DIR bin CACHE STRING "Output directory for LLDB.framework")
   set(LLDB_FRAMEWORK_INSTALL_DIR Library/Frameworks CACHE STRING "Install directory for LLDB.framework")
-  set(LLDB_FRAMEWORK_TOOLS darwin-debug;debugserver;lldb-argdumper;lldb-server CACHE STRING
-      "List of tools to include in LLDB.framework/Resources")
 
   # Set designated directory for all dSYMs. Essentially, this emits the
   # framework's dSYM outside of the framework directory.

Modified: lldb/trunk/cmake/modules/LLDBFramework.cmake
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/cmake/modules/LLDBFramework.cmake?rev=361946&r1=361945&r2=361946&view=diff
==============================================================================
--- lldb/trunk/cmake/modules/LLDBFramework.cmake (original)
+++ lldb/trunk/cmake/modules/LLDBFramework.cmake Wed May 29 04:26:06 2019
@@ -36,22 +36,9 @@ else()
 endif()
 
 # Target to capture extra steps for a fully functional framework bundle.
-add_custom_target(lldb-framework)
+add_custom_target(lldb-framework ALL)
 add_dependencies(lldb-framework liblldb)
 
-# Dependencies are defined once tools are added (see AddLLDB.cmake)
-if(LLDB_FRAMEWORK_TOOLS)
-  message(STATUS "LLDB.framework: adding tools ${LLDB_FRAMEWORK_TOOLS}")
-  foreach(tool ${LLDB_FRAMEWORK_TOOLS})
-    add_custom_command(TARGET lldb-framework POST_BUILD
-      COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:${tool}> $<TARGET_FILE_DIR:liblldb>/Resources
-      COMMENT "LLDB.framework: copy additional tool ${tool}"
-    )
-  endforeach()
-else()
-  message(WARNING "LLDB.framework: no additional tools configured (set via LLDB_FRAMEWORK_TOOLS)")
-endif()
-
 # Apart from this one, CMake creates all required symlinks in the framework bundle.
 add_custom_command(TARGET lldb-framework POST_BUILD
   COMMAND ${CMAKE_COMMAND} -E create_symlink

Modified: lldb/trunk/tools/argdumper/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/argdumper/CMakeLists.txt?rev=361946&r1=361945&r2=361946&view=diff
==============================================================================
--- lldb/trunk/tools/argdumper/CMakeLists.txt (original)
+++ lldb/trunk/tools/argdumper/CMakeLists.txt Wed May 29 04:26:06 2019
@@ -4,3 +4,7 @@ add_lldb_tool(lldb-argdumper
   LINK_LIBS
     lldbUtility
   )
+
+if(LLDB_BUILD_FRAMEWORK)
+  lldb_add_to_framework(lldb-argdumper)
+endif()

Modified: lldb/trunk/tools/darwin-debug/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/darwin-debug/CMakeLists.txt?rev=361946&r1=361945&r2=361946&view=diff
==============================================================================
--- lldb/trunk/tools/darwin-debug/CMakeLists.txt (original)
+++ lldb/trunk/tools/darwin-debug/CMakeLists.txt Wed May 29 04:26:06 2019
@@ -1,3 +1,7 @@
 add_lldb_tool(darwin-debug
   darwin-debug.cpp
   )
+
+if(LLDB_BUILD_FRAMEWORK)
+  lldb_add_to_framework(darwin-debug)
+endif()

Modified: lldb/trunk/tools/debugserver/source/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/CMakeLists.txt?rev=361946&r1=361945&r2=361946&view=diff
==============================================================================
--- lldb/trunk/tools/debugserver/source/CMakeLists.txt (original)
+++ lldb/trunk/tools/debugserver/source/CMakeLists.txt Wed May 29 04:26:06 2019
@@ -265,6 +265,10 @@ if(build_and_sign_debugserver)
       ${entitlements}
     )
 
+  if(LLDB_BUILD_FRAMEWORK)
+    lldb_add_to_framework(debugserver)
+  endif()
+
   if(IOS)
     set_property(TARGET lldbDebugserverCommon APPEND PROPERTY COMPILE_DEFINITIONS
       WITH_LOCKDOWN

Modified: lldb/trunk/tools/driver/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/driver/CMakeLists.txt?rev=361946&r1=361945&r2=361946&view=diff
==============================================================================
--- lldb/trunk/tools/driver/CMakeLists.txt (original)
+++ lldb/trunk/tools/driver/CMakeLists.txt Wed May 29 04:26:06 2019
@@ -31,5 +31,15 @@ add_dependencies(lldb
 set_target_properties(LLDBOptionsTableGen PROPERTIES FOLDER "lldb misc")
 
 if(LLDB_BUILD_FRAMEWORK)
-  lldb_setup_framework_rpaths_in_tool(lldb)
+  # In the build-tree, we know the exact path to the framework directory.
+  # The installed framework can be in different locations.
+  get_target_property(framework_build_dir liblldb LIBRARY_OUTPUT_DIRECTORY)
+  lldb_setup_rpaths(lldb
+    BUILD_RPATH
+      "${framework_build_dir}"
+    INSTALL_RPATH
+      "@loader_path/../../../SharedFrameworks"
+      "@loader_path/../../System/Library/PrivateFrameworks"
+      "@loader_path/../../Library/PrivateFrameworks"
+  )
 endif()

Modified: lldb/trunk/tools/lldb-mi/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/lldb-mi/CMakeLists.txt?rev=361946&r1=361945&r2=361946&view=diff
==============================================================================
--- lldb/trunk/tools/lldb-mi/CMakeLists.txt (original)
+++ lldb/trunk/tools/lldb-mi/CMakeLists.txt Wed May 29 04:26:06 2019
@@ -95,5 +95,15 @@ add_lldb_tool(lldb-mi
   )
 
 if(LLDB_BUILD_FRAMEWORK)
-  lldb_setup_framework_rpaths_in_tool(lldb-mi)
+  # In the build-tree, we know the exact path to the framework directory.
+  # The installed framework can be in different locations.
+  get_target_property(framework_build_dir liblldb LIBRARY_OUTPUT_DIRECTORY)
+  lldb_setup_rpaths(lldb-mi
+    BUILD_RPATH
+      "${framework_build_dir}"
+    INSTALL_RPATH
+      "@loader_path/../../../SharedFrameworks"
+      "@loader_path/../../System/Library/PrivateFrameworks"
+      "@loader_path/../../Library/PrivateFrameworks"
+  )
 endif()

Modified: lldb/trunk/tools/lldb-server/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/lldb-server/CMakeLists.txt?rev=361946&r1=361945&r2=361946&view=diff
==============================================================================
--- lldb/trunk/tools/lldb-server/CMakeLists.txt (original)
+++ lldb/trunk/tools/lldb-server/CMakeLists.txt Wed May 29 04:26:06 2019
@@ -77,3 +77,7 @@ add_lldb_tool(lldb-server
 )
 
 target_link_libraries(lldb-server PRIVATE ${LLDB_SYSTEM_LIBS})
+
+if(LLDB_BUILD_FRAMEWORK)
+  lldb_add_to_framework(lldb-server)
+endif()

Modified: lldb/trunk/tools/lldb-vscode/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/lldb-vscode/CMakeLists.txt?rev=361946&r1=361945&r2=361946&view=diff
==============================================================================
--- lldb/trunk/tools/lldb-vscode/CMakeLists.txt (original)
+++ lldb/trunk/tools/lldb-vscode/CMakeLists.txt Wed May 29 04:26:06 2019
@@ -31,5 +31,15 @@ add_lldb_tool(lldb-vscode
   )
 
 if(LLDB_BUILD_FRAMEWORK)
-  lldb_setup_framework_rpaths_in_tool(lldb-vscode)
+  # In the build-tree, we know the exact path to the framework directory.
+  # The installed framework can be in different locations.
+  get_target_property(framework_build_dir liblldb LIBRARY_OUTPUT_DIRECTORY)
+  lldb_setup_rpaths(lldb-vscode
+    BUILD_RPATH
+      "${framework_build_dir}"
+    INSTALL_RPATH
+      "@loader_path/../../../SharedFrameworks"
+      "@loader_path/../../System/Library/PrivateFrameworks"
+      "@loader_path/../../Library/PrivateFrameworks"
+  )
 endif()




More information about the lldb-commits mailing list