Skip to content
Draft
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
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "vendor/flatbuffers"]
path = vendor/flatbuffers
url = https://github.com/google/flatbuffers.git
27 changes: 27 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,32 @@ if (NOT BN_INTERNAL_BUILD)
message("CMAKE_PREFIX_PATH is: ${CMAKE_PREFIX_PATH}")
endif()

set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

# FlatBuffers is used for the x2win RPC protocol. Its C++ runtime is header-only (see
# FlatBuffers_Library_SRCS in vendor/flatbuffers/CMakeLists.txt -- every entry is a .h, no .cpp),
# so unlike Protobuf/Abseil (formerly vendored here for the same protocol, since removed) there's
# no compiled static lib whose CRT/ABI settings need to match whatever links against it -- only
# flatc (the schema compiler) is an actual build-time binary. That's what let x2winstub drop its
# MSVC-ABI-pinned toolchain requirement for MinGW-w64 once the protocol finished migrating over.
# flatbuffers_generate_headers() (used by core/CMakeLists.txt and x2winstub/CMakeLists.txt) comes
# from vendor/flatbuffers/CMake/BuildFlatBuffers.cmake, which flatbuffers' own CMakeLists.txt
# already include()s, so no separate include() is needed here the way protobuf-generate.cmake was.
set(FLATBUFFERS_BUILD_TESTS OFF CACHE BOOL "" FORCE)
set(FLATBUFFERS_INSTALL OFF CACHE BOOL "" FORCE)
set(FLATBUFFERS_BUILD_FLATC ON CACHE BOOL "" FORCE)
add_subdirectory(vendor/flatbuffers)

# Generated once here and shared via target_link_libraries(... x2win_fbs) from both
# core/CMakeLists.txt and x2winstub/CMakeLists.txt, rather than calling
# flatbuffers_generate_headers() separately from each (which would define two CMake targets
# both named "x2win_fbs" and fail to configure -- target names must be unique project-wide).
flatbuffers_generate_headers(
TARGET x2win_fbs
SCHEMAS ${CMAKE_SOURCE_DIR}/protocol/x2win.fbs
)

add_subdirectory(core)
add_subdirectory(api)

Expand Down Expand Up @@ -58,6 +84,7 @@ endif()
# WinDbg installer CLI (standalone, spawned by debuggercore API)
if(WIN32)
add_subdirectory(installer)
add_subdirectory(x2winstub)
endif()

# Documentation validation target
Expand Down
7 changes: 6 additions & 1 deletion build.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,14 @@ git checkout dev

- Build the debugger

FlatBuffers (needed for `X2WinRpcAdapter`'s wire protocol) is vendored as a git submodule
under `vendor/` and built as part of this project's own CMake configure/build -- no separate
install step needed, just make sure submodules are cloned (`--recurse-submodules` below, or
`git submodule update --init --recursive` after the fact).

```bash
# Get the source
git clone https://github.com/Vector35/debugger.git
git clone --recurse-submodules https://github.com/Vector35/debugger.git

# Do an out-of-source build
mkdir -p build
Expand Down
22 changes: 22 additions & 0 deletions core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ file(GLOB ADAPTER_SOURCES CONFIGURE_DEPENDS
adapters/esrevenadapter.h
adapters/lldbcoredumpadapter.cpp
adapters/lldbcoredumpadapter.h
adapters/x2winrpcadapter.cpp
adapters/x2winrpcadapter.h
)

if(WIN32)
Expand Down Expand Up @@ -212,6 +214,26 @@ else()
)
endif()

# FlatBuffers for the x2win RPC protocol (protocol/x2win.fbs), generated once at the top-level
# CMakeLists.txt and shared with x2winstub/CMakeLists.txt.
#
# Deliberately not target_link_libraries(debuggercore x2win_fbs): every other
# target_link_libraries() call on debuggercore in this file uses the plain (no PUBLIC/PRIVATE)
# signature, and CMake forbids mixing plain and keyword signatures for the same target anywhere
# in the project -- so a PRIVATE-only x2win_fbs link isn't an option here. Plain/public would
# instead propagate x2win_fbs's generated-header "source" to every downstream consumer of
# debuggercore (ui, cli), which fails to configure because that generated file, from their
# directory scope, isn't recognized as a build product (GENERATED doesn't propagate cross-directory
# pre-CMake 3.20 semantics). Depending on the include dir + generation step directly sidesteps
# target_link_libraries entirely, so it stays private to debuggercore without touching the
# project's existing plain-signature convention.
add_dependencies(debuggercore GENERATE_x2win_fbs)
target_include_directories(debuggercore PRIVATE
${CMAKE_BINARY_DIR}/x2win_fbs
${CMAKE_SOURCE_DIR}/vendor/flatbuffers/include
)


if (WIN32)
add_custom_command(TARGET debuggercore PRE_LINK
COMMAND ${CMAKE_COMMAND} -E echo "Copying DbgEng DLLs"
Expand Down
Loading