https://github.com/JDevlieghere created 
https://github.com/llvm/llvm-project/pull/139402

Split lldb-dap into a library (lldbDAP) and a tool (lldb-dap). The motivation 
is being able to link parts of lldb-dap separately, for example to support unit 
testing and fizzing.

>From b0996a236d9eaf70de562ae2cf0e1900417cae93 Mon Sep 17 00:00:00 2001
From: Jonas Devlieghere <jo...@devlieghere.com>
Date: Sat, 10 May 2025 12:08:29 -0700
Subject: [PATCH] [lldb-dap] Split lldb-dap into library and tool (NFC)

Split lldb-dap into a library (lldbDAP) and a tool (lldb-dap). The
motivation is being able to link parts of lldb-dap separately, for
example to support unit testing and fizzing.
---
 lldb/tools/lldb-dap/CMakeLists.txt            | 22 ++++++---------
 lldb/tools/lldb-dap/tool/CMakeLists.txt       | 28 +++++++++++++++++++
 .../{ => tool}/lldb-dap-Info.plist.in         |  0
 lldb/tools/lldb-dap/{ => tool}/lldb-dap.cpp   |  0
 4 files changed, 36 insertions(+), 14 deletions(-)
 create mode 100644 lldb/tools/lldb-dap/tool/CMakeLists.txt
 rename lldb/tools/lldb-dap/{ => tool}/lldb-dap-Info.plist.in (100%)
 rename lldb/tools/lldb-dap/{ => tool}/lldb-dap.cpp (100%)

diff --git a/lldb/tools/lldb-dap/CMakeLists.txt 
b/lldb/tools/lldb-dap/CMakeLists.txt
index a9dc19006293b..25bacd91fe581 100644
--- a/lldb/tools/lldb-dap/CMakeLists.txt
+++ b/lldb/tools/lldb-dap/CMakeLists.txt
@@ -1,20 +1,14 @@
-if(APPLE)
-  configure_file(
-    ${CMAKE_CURRENT_SOURCE_DIR}/lldb-dap-Info.plist.in
-    ${CMAKE_CURRENT_BINARY_DIR}/lldb-dap-Info.plist
-    )
-  # Inline info plist in binary (use target_link_options for this as soon as 
CMake 3.13 is available)
-  set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} 
-Wl,-sectcreate,__TEXT,__info_plist,${CMAKE_CURRENT_BINARY_DIR}/lldb-dap-Info.plist")
-endif()
-
 # We need to include the llvm components we depend on manually, as liblldb does
 # not re-export those.
 set(LLVM_LINK_COMPONENTS Support)
 set(LLVM_TARGET_DEFINITIONS Options.td)
 tablegen(LLVM Options.inc -gen-opt-parser-defs)
 add_public_tablegen_target(LLDBDAPOptionsTableGen)
-add_lldb_tool(lldb-dap
-  lldb-dap.cpp
+
+include_directories(${CMAKE_CURRENT_SOURCE_DIR})
+include_directories(${CMAKE_CURRENT_BINARY_DIR})
+
+add_lldb_library(lldbDAP
   Breakpoint.cpp
   BreakpointBase.cpp
   DAP.cpp
@@ -85,10 +79,8 @@ add_lldb_tool(lldb-dap
     Support
   )
 
-target_include_directories(lldb-dap PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
-
 if(LLDB_DAP_WELCOME_MESSAGE)
-  target_compile_definitions(lldb-dap
+  target_compile_definitions(lldbDAP
     PRIVATE
     -DLLDB_DAP_WELCOME_MESSAGE=\"${LLDB_DAP_WELCOME_MESSAGE}\")
 endif()
@@ -105,3 +97,5 @@ if(LLDB_BUILD_FRAMEWORK)
       "@loader_path/../../Library/PrivateFrameworks"
   )
 endif()
+
+add_subdirectory(tool)
diff --git a/lldb/tools/lldb-dap/tool/CMakeLists.txt 
b/lldb/tools/lldb-dap/tool/CMakeLists.txt
new file mode 100644
index 0000000000000..e418737bc05b1
--- /dev/null
+++ b/lldb/tools/lldb-dap/tool/CMakeLists.txt
@@ -0,0 +1,28 @@
+if(APPLE)
+  configure_file(
+    ${CMAKE_CURRENT_SOURCE_DIR}/lldb-dap-Info.plist.in
+    ${CMAKE_CURRENT_BINARY_DIR}/lldb-dap-Info.plist
+    )
+  # Inline info plist in binary (use target_link_options for this as soon as 
CMake 3.13 is available)
+  set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} 
-Wl,-sectcreate,__TEXT,__info_plist,${CMAKE_CURRENT_BINARY_DIR}/lldb-dap-Info.plist")
+endif()
+
+add_lldb_tool(lldb-dap
+  lldb-dap.cpp
+
+  LINK_LIBS
+    lldbDAP
+  )
+
+if(LLDB_BUILD_FRAMEWORK)
+  # In the build-tree, we know the exact path to the framework directory.
+  # The installed framework can be in different locations.
+  lldb_setup_rpaths(lldb-dap
+    BUILD_RPATH
+      "${LLDB_FRAMEWORK_ABSOLUTE_BUILD_DIR}"
+    INSTALL_RPATH
+      "@loader_path/../../../SharedFrameworks"
+      "@loader_path/../../System/Library/PrivateFrameworks"
+      "@loader_path/../../Library/PrivateFrameworks"
+  )
+endif()
diff --git a/lldb/tools/lldb-dap/lldb-dap-Info.plist.in 
b/lldb/tools/lldb-dap/tool/lldb-dap-Info.plist.in
similarity index 100%
rename from lldb/tools/lldb-dap/lldb-dap-Info.plist.in
rename to lldb/tools/lldb-dap/tool/lldb-dap-Info.plist.in
diff --git a/lldb/tools/lldb-dap/lldb-dap.cpp 
b/lldb/tools/lldb-dap/tool/lldb-dap.cpp
similarity index 100%
rename from lldb/tools/lldb-dap/lldb-dap.cpp
rename to lldb/tools/lldb-dap/tool/lldb-dap.cpp

_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to