Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 7 additions & 13 deletions lldb/tools/lldb-dap/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,20 +1,11 @@
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)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this move too? The .inc file is only used in lldb-dap.cpp.

tablegen(LLVM Options.inc -gen-opt-parser-defs)
add_public_tablegen_target(LLDBDAPOptionsTableGen)
add_lldb_tool(lldb-dap
lldb-dap.cpp

add_lldb_library(lldbDAP
Breakpoint.cpp
BreakpointBase.cpp
DAP.cpp
Expand Down Expand Up @@ -85,10 +76,11 @@ add_lldb_tool(lldb-dap
Support
)

target_include_directories(lldb-dap PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
target_include_directories(lldbDAP
PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_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()
Expand All @@ -105,3 +97,5 @@ if(LLDB_BUILD_FRAMEWORK)
"@loader_path/../../Library/PrivateFrameworks"
)
endif()

add_subdirectory(tool)
28 changes: 28 additions & 0 deletions lldb/tools/lldb-dap/tool/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
add_lldb_tool(lldb-dap
lldb-dap.cpp

LINK_LIBS
lldbDAP
)

if(APPLE)
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/lldb-dap-Info.plist.in
${CMAKE_CURRENT_BINARY_DIR}/lldb-dap-Info.plist
)
target_link_options(lldb-dap
PRIVATE LINKER:-sectcreate,__TEXT,__info_plist,${CMAKE_CURRENT_BINARY_DIR}/lldb-dap-Info.plist)
endif()

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()
1 change: 1 addition & 0 deletions lldb/unittests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ endif()
add_subdirectory(Breakpoint)
add_subdirectory(Callback)
add_subdirectory(Core)
add_subdirectory(DAP)
add_subdirectory(DataFormatter)
add_subdirectory(Disassembler)
add_subdirectory(Editline)
Expand Down
8 changes: 8 additions & 0 deletions lldb/unittests/DAP/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
add_lldb_unittest(DAPTests
JSONUtilsTest.cpp

LINK_LIBS
lldbDAP
LINK_COMPONENTS
Support
)
33 changes: 33 additions & 0 deletions lldb/unittests/DAP/JSONUtilsTest.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
//===-- JSONUtilsTest.cpp -------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//

#include "JSONUtils.h"
#include "lldb/API/SBModule.h"
#include "lldb/API/SBTarget.h"
#include "gtest/gtest.h"

using namespace llvm;
using namespace lldb;
using namespace lldb_dap;

TEST(JSONUtilsTest, GetAsString) {
StringRef str = "foo";
json::Value value("foo");
EXPECT_EQ(str, GetAsString(value));
}

TEST(JSONUtilsTest, CreateModule) {
SBTarget target;
SBModule module;

json::Value value = CreateModule(target, module);
json::Object *object = value.getAsObject();

ASSERT_NE(object, nullptr);
EXPECT_EQ(object->size(), 0UL);
}
Loading