sgraenitz updated this revision to Diff 201479.
sgraenitz added a comment.

lldb-vscode is no fremwork tool, but instead it needs the RPATHs


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D62472/new/

https://reviews.llvm.org/D62472

Files:
  lldb/CMakeLists.txt
  lldb/cmake/modules/AddLLDB.cmake
  lldb/cmake/modules/LLDBConfig.cmake
  lldb/cmake/modules/LLDBFramework.cmake
  lldb/tools/argdumper/CMakeLists.txt
  lldb/tools/darwin-debug/CMakeLists.txt
  lldb/tools/debugserver/source/CMakeLists.txt
  lldb/tools/driver/CMakeLists.txt
  lldb/tools/lldb-mi/CMakeLists.txt
  lldb/tools/lldb-server/CMakeLists.txt
  lldb/tools/lldb-vscode/CMakeLists.txt

Index: lldb/tools/lldb-vscode/CMakeLists.txt
===================================================================
--- lldb/tools/lldb-vscode/CMakeLists.txt
+++ lldb/tools/lldb-vscode/CMakeLists.txt
@@ -31,5 +31,15 @@
   )
 
 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()
Index: lldb/tools/lldb-server/CMakeLists.txt
===================================================================
--- lldb/tools/lldb-server/CMakeLists.txt
+++ lldb/tools/lldb-server/CMakeLists.txt
@@ -77,3 +77,7 @@
 )
 
 target_link_libraries(lldb-server PRIVATE ${LLDB_SYSTEM_LIBS})
+
+if(LLDB_BUILD_FRAMEWORK)
+  lldb_add_to_framework(lldb-server)
+endif()
Index: lldb/tools/lldb-mi/CMakeLists.txt
===================================================================
--- lldb/tools/lldb-mi/CMakeLists.txt
+++ lldb/tools/lldb-mi/CMakeLists.txt
@@ -95,5 +95,15 @@
   )
 
 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()
Index: lldb/tools/driver/CMakeLists.txt
===================================================================
--- lldb/tools/driver/CMakeLists.txt
+++ lldb/tools/driver/CMakeLists.txt
@@ -29,5 +29,15 @@
 )
 
 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()
Index: lldb/tools/debugserver/source/CMakeLists.txt
===================================================================
--- lldb/tools/debugserver/source/CMakeLists.txt
+++ lldb/tools/debugserver/source/CMakeLists.txt
@@ -264,6 +264,10 @@
       ${entitlements}
     )
 
+  if(LLDB_BUILD_FRAMEWORK)
+    lldb_add_to_framework(lldb-argdumper)
+  endif()
+
   if(IOS)
     set_property(TARGET lldbDebugserverCommon APPEND PROPERTY COMPILE_DEFINITIONS
       WITH_LOCKDOWN
Index: lldb/tools/darwin-debug/CMakeLists.txt
===================================================================
--- lldb/tools/darwin-debug/CMakeLists.txt
+++ lldb/tools/darwin-debug/CMakeLists.txt
@@ -1,3 +1,7 @@
 add_lldb_tool(darwin-debug
   darwin-debug.cpp
   )
+
+if(LLDB_BUILD_FRAMEWORK)
+  lldb_add_to_framework(lldb-argdumper)
+endif()
Index: lldb/tools/argdumper/CMakeLists.txt
===================================================================
--- lldb/tools/argdumper/CMakeLists.txt
+++ lldb/tools/argdumper/CMakeLists.txt
@@ -4,3 +4,7 @@
   LINK_LIBS
     lldbUtility
   )
+
+if(LLDB_BUILD_FRAMEWORK)
+  lldb_add_to_framework(lldb-argdumper)
+endif()
Index: lldb/cmake/modules/LLDBFramework.cmake
===================================================================
--- lldb/cmake/modules/LLDBFramework.cmake
+++ lldb/cmake/modules/LLDBFramework.cmake
@@ -36,22 +36,9 @@
 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
Index: lldb/cmake/modules/LLDBConfig.cmake
===================================================================
--- lldb/cmake/modules/LLDBConfig.cmake
+++ lldb/cmake/modules/LLDBConfig.cmake
@@ -64,8 +64,6 @@
   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.
Index: lldb/cmake/modules/AddLLDB.cmake
===================================================================
--- lldb/cmake/modules/AddLLDB.cmake
+++ lldb/cmake/modules/AddLLDB.cmake
@@ -59,17 +59,9 @@
       ${pass_NO_INSTALL_RPATH}
     )
 
-    if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY OR ${name} STREQUAL "liblldb")
+    if (NOT LLDB_BUILD_FRAMEWORK AND (NOT LLVM_INSTALL_TOOLCHAIN_ONLY OR ${name} STREQUAL "liblldb"))
       if (PARAM_SHARED)
-        if(${name} STREQUAL "liblldb" AND LLDB_BUILD_FRAMEWORK)
-          if(LLDB_FRAMEWORK_INSTALL_DIR)
-            set(install_dir ${LLDB_FRAMEWORK_INSTALL_DIR})
-          else()
-            set(install_dir ".")
-          endif()
-        else()
-          set(install_dir lib${LLVM_LIBDIR_SUFFIX})
-        endif()
+        set(install_dir lib${LLVM_LIBDIR_SUFFIX})
         install(TARGETS ${name}
           COMPONENT ${name}
           RUNTIME DESTINATION bin
@@ -204,3 +196,32 @@
 
   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
Index: lldb/CMakeLists.txt
===================================================================
--- lldb/CMakeLists.txt
+++ lldb/CMakeLists.txt
@@ -151,6 +151,10 @@
     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})
 
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to