[lldb] Record framework build path and use it everywhere

This avoids config time dependencies on liblldb. And enables other refactoring.
This commit is contained in:
Haibo Huang 2019-10-30 10:33:05 -07:00
parent 9bfa5ab3d1
commit 77a60f0df6
8 changed files with 15 additions and 24 deletions

View File

@ -93,10 +93,9 @@ endif()
if (NOT LLDB_DISABLE_PYTHON)
get_target_property(lldb_scripts_dir swig_wrapper BINARY_DIR)
get_target_property(liblldb_build_dir liblldb LIBRARY_OUTPUT_DIRECTORY)
if(LLDB_BUILD_FRAMEWORK)
set(lldb_python_build_path "${liblldb_build_dir}/LLDB.framework/Resources/Python/lldb")
set(lldb_python_build_path "${LLDB_FRAMEWORK_ABSOLUTE_BUILD_DIR}/LLDB.framework/Resources/Python/lldb")
else()
set(lldb_python_build_path "${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/${LLDB_PYTHON_RELATIVE_PATH}/lldb")
endif()
@ -188,7 +187,7 @@ if (NOT LLDB_DISABLE_PYTHON)
endfunction()
if(LLDB_BUILD_FRAMEWORK)
set(LIBLLDB_SYMLINK_DEST "${liblldb_build_dir}/LLDB.framework/LLDB")
set(LIBLLDB_SYMLINK_DEST "${LLDB_FRAMEWORK_ABSOLUTE_BUILD_DIR}/LLDB.framework/LLDB")
else()
set(LIBLLDB_SYMLINK_DEST "${LLVM_SHLIB_OUTPUT_INTDIR}/liblldb${CMAKE_SHARED_LIBRARY_SUFFIX}")
endif()

View File

@ -227,8 +227,7 @@ endfunction()
function(lldb_add_to_buildtree_lldb_framework name subdir)
# 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.
get_target_property(framework_build_dir liblldb LIBRARY_OUTPUT_DIRECTORY)
set(copy_dest "${framework_build_dir}/${subdir}/$<TARGET_FILE_NAME:${name}>")
set(copy_dest "${LLDB_FRAMEWORK_ABSOLUTE_BUILD_DIR}/${subdir}/$<TARGET_FILE_NAME:${name}>")
# Copy into the given subdirectory for testing.
add_custom_command(TARGET ${name} POST_BUILD

View File

@ -68,6 +68,9 @@ if(LLDB_BUILD_FRAMEWORK)
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")
get_filename_component(LLDB_FRAMEWORK_ABSOLUTE_BUILD_DIR ${LLDB_FRAMEWORK_BUILD_DIR} ABSOLUTE
BASE_DIR ${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR})
# Essentially, emit the framework's dSYM outside of the framework directory.
set(LLDB_DEBUGINFO_INSTALL_PREFIX ${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/bin CACHE STRING
"Directory to emit dSYM files stripped from executables and libraries (Darwin Only)")

View File

@ -1,10 +1,4 @@
# Path relative to the root binary directory
get_filename_component(
framework_target_dir ${LLDB_FRAMEWORK_BUILD_DIR} ABSOLUTE
BASE_DIR ${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}
)
message(STATUS "LLDB.framework: build path is '${framework_target_dir}'")
message(STATUS "LLDB.framework: build path is '${LLDB_FRAMEWORK_ABSOLUTE_BUILD_DIR}'")
message(STATUS "LLDB.framework: install path is '${LLDB_FRAMEWORK_INSTALL_DIR}'")
message(STATUS "LLDB.framework: resources subdirectory is 'Versions/${LLDB_FRAMEWORK_VERSION}/Resources'")
@ -15,7 +9,7 @@ set_target_properties(liblldb PROPERTIES
OUTPUT_NAME LLDB
VERSION ${LLDB_VERSION}
LIBRARY_OUTPUT_DIRECTORY ${framework_target_dir}
LIBRARY_OUTPUT_DIRECTORY ${LLDB_FRAMEWORK_ABSOLUTE_BUILD_DIR}
# Compatibility version
SOVERSION "1.0.0"
@ -29,8 +23,8 @@ set_target_properties(liblldb PROPERTIES
# Used in llvm_add_library() to set default output directories for multi-config
# generators. Overwrite to account for special framework output directory.
set_output_directory(liblldb
BINARY_DIR ${framework_target_dir}
LIBRARY_DIR ${framework_target_dir}
BINARY_DIR ${LLDB_FRAMEWORK_ABSOLUTE_BUILD_DIR}
LIBRARY_DIR ${LLDB_FRAMEWORK_ABSOLUTE_BUILD_DIR}
)
lldb_add_post_install_steps_darwin(liblldb ${LLDB_FRAMEWORK_INSTALL_DIR})
@ -51,7 +45,7 @@ set(CMAKE_XCODE_ATTRIBUTE_CLANG_WARN_DOCUMENTATION_COMMENTS "YES")
add_custom_command(TARGET liblldb POST_BUILD
COMMAND ${CMAKE_COMMAND} -E create_symlink
Versions/Current/Headers
${framework_target_dir}/LLDB.framework/Headers
${LLDB_FRAMEWORK_ABSOLUTE_BUILD_DIR}/LLDB.framework/Headers
COMMENT "LLDB.framework: create Headers symlink"
)

View File

@ -107,8 +107,7 @@ endif()
if(CMAKE_HOST_APPLE)
if(LLDB_BUILD_FRAMEWORK)
get_target_property(framework_build_dir liblldb LIBRARY_OUTPUT_DIRECTORY)
list(APPEND LLDB_TEST_COMMON_ARGS --framework ${framework_build_dir}/LLDB.framework)
list(APPEND LLDB_TEST_COMMON_ARGS --framework ${LLDB_FRAMEWORK_ABSOLUTE_BUILD_DIR}/LLDB.framework)
endif()
# Use the same identity for testing

View File

@ -219,8 +219,7 @@ if (debugserver_codesign_identity AND LLDB_BUILD_FRAMEWORK AND
set(pass_entitlements --entitlements ${entitlements})
endif()
get_target_property(framework_build_dir liblldb LIBRARY_OUTPUT_DIRECTORY)
set(copy_location ${framework_build_dir}/LLDB.framework/Versions/${LLDB_FRAMEWORK_VERSION}/Resources/debugserver)
set(copy_location ${LLDB_FRAMEWORK_ABSOLUTE_BUILD_DIR}/LLDB.framework/Versions/${LLDB_FRAMEWORK_VERSION}/Resources/debugserver)
add_custom_command(TARGET debugserver POST_BUILD
COMMAND ${CMAKE_COMMAND} -E

View File

@ -33,10 +33,9 @@ set_target_properties(LLDBOptionsTableGen PROPERTIES FOLDER "lldb misc")
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.
get_target_property(framework_build_dir liblldb LIBRARY_OUTPUT_DIRECTORY)
lldb_setup_rpaths(lldb
BUILD_RPATH
"${framework_build_dir}"
"${LLDB_FRAMEWORK_ABSOLUTE_BUILD_DIR}"
INSTALL_RPATH
"@loader_path/../../../SharedFrameworks"
"@loader_path/../../System/Library/PrivateFrameworks"

View File

@ -33,10 +33,9 @@ add_lldb_tool(lldb-vscode
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.
get_target_property(framework_build_dir liblldb LIBRARY_OUTPUT_DIRECTORY)
lldb_setup_rpaths(lldb-vscode
BUILD_RPATH
"${framework_build_dir}"
"${LLDB_FRAMEWORK_ABSOLUTE_BUILD_DIR}"
INSTALL_RPATH
"@loader_path/../../../SharedFrameworks"
"@loader_path/../../System/Library/PrivateFrameworks"