[cmake] Darwin: Copy in the system debugserver if needed

This makes the built debugger functional on Darwin when compiling
without code signing (as documented in docs/code-signing.txt).

llvm-svn: 325068
This commit is contained in:
Vedant Kumar 2018-02-13 23:05:46 +00:00
parent 7fc87360e9
commit 361b5e1169
4 changed files with 26 additions and 13 deletions

View File

@ -56,6 +56,22 @@ if (NOT LLDB_DISABLE_PYTHON)
add_subdirectory(scripts)
endif ()
if(CMAKE_HOST_APPLE)
if(LLDB_CODESIGN_IDENTITY)
set(DEBUGSERVER_PATH $<TARGET_FILE:debugserver>)
else()
execute_process(
COMMAND xcode-select -p
OUTPUT_VARIABLE XCODE_DEV_DIR)
string(STRIP ${XCODE_DEV_DIR} XCODE_DEV_DIR)
set(DEBUGSERVER_PATH
"${XCODE_DEV_DIR}/../SharedFrameworks/LLDB.framework/Resources/debugserver")
set(SKIP_DEBUGSERVER True)
endif()
message(STATUS "Path to the lldb debugserver: ${DEBUGSERVER_PATH}")
endif()
add_subdirectory(source)
add_subdirectory(tools)

View File

@ -110,17 +110,6 @@ if (NOT ${CMAKE_SYSTEM_NAME} MATCHES "Windows|Darwin")
endif()
if(CMAKE_HOST_APPLE)
if(LLDB_CODESIGN_IDENTITY)
set(DEBUGSERVER_PATH $<TARGET_FILE:debugserver>)
else()
execute_process(
COMMAND xcode-select -p
OUTPUT_VARIABLE XCODE_DEV_DIR)
string(STRIP ${XCODE_DEV_DIR} XCODE_DEV_DIR)
set(DEBUGSERVER_PATH
"${XCODE_DEV_DIR}/../SharedFrameworks/LLDB.framework/Resources/debugserver")
endif()
message(STATUS "Path to the lldb debugserver: ${DEBUGSERVER_PATH}")
list(APPEND LLDB_TEST_COMMON_ARGS --server ${DEBUGSERVER_PATH})
endif()

View File

@ -195,7 +195,15 @@ if("${LLDB_CODESIGN_IDENTITY}" STREQUAL "lldb_codesign")
endif()
option(LLDB_USE_ENTITLEMENTS "Use entitlements when codesigning (Defaults Off when using lldb_codesign identity, otherwise On)" ${LLDB_USE_ENTITLEMENTS_Default})
if (NOT ("${LLDB_CODESIGN_IDENTITY}" STREQUAL ""))
if ("${LLDB_CODESIGN_IDENTITY}" STREQUAL "")
if (CMAKE_HOST_APPLE)
# If we haven't built a signed debugserver, copy the one from the system.
add_custom_target(debugserver
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${DEBUGSERVER_PATH} ${CMAKE_BINARY_DIR}/bin
VERBATIM
COMMENT "Copying the system debugserver to LLDB's binaries directory.")
endif()
else()
if(LLDB_USE_ENTITLEMENTS)
set(entitlements_flags --entitlements ${entitlements_xml})
endif()

View File

@ -13,7 +13,7 @@ add_lldb_test_executable(thread_inferior inferior/thread_inferior.cpp)
add_lldb_test_executable(environment_check inferior/environment_check.cpp)
if (CMAKE_SYSTEM_NAME MATCHES "Darwin")
add_definitions(-DLLDB_SERVER="$<TARGET_FILE:debugserver>" -DLLDB_SERVER_IS_DEBUGSERVER=1)
add_definitions(-DLLDB_SERVER="${DEBUGSERVER_PATH}" -DLLDB_SERVER_IS_DEBUGSERVER=1)
else()
add_definitions(-DLLDB_SERVER="$<TARGET_FILE:lldb-server>" -DLLDB_SERVER_IS_DEBUGSERVER=0)
endif()