[CMake] Track test dependencies with add_lldb_test_dependency

I often use `ninja lldb-test-deps` to build all the test dependencies
before running a subset of the tests with `lit --filter`. This
functionality seems to break relatively often because test dependencies
are tracked in an ad-hoc way acrooss cmake files. This patch adds a
helper function `add_lldb_test_dependency` to unify test dependency
tracking by adding dependencies to lldb-test-deps.

Differential revision: https://reviews.llvm.org/D68612

llvm-svn: 373996
This commit is contained in:
Jonas Devlieghere 2019-10-08 00:21:34 +00:00
parent 6f23e5f6d5
commit 37cf39df20
6 changed files with 37 additions and 38 deletions

View File

@ -109,40 +109,50 @@ if(LLDB_INCLUDE_TESTS)
message(FATAL_ERROR "LLDB test compilers not specified. Tests will not run.")
endif()
set(LLDB_TEST_DEPS lldb)
add_custom_target(lldb-test-deps)
set_target_properties(lldb-test-deps PROPERTIES FOLDER "lldb misc")
add_lldb_test_dependency(lldb)
# lldb-test is an hard dependency for the testsuite.
add_lldb_test_dependency(lldb-test)
# darwin-debug is an hard dependency for the testsuite.
if (CMAKE_SYSTEM_NAME MATCHES "Darwin")
list(APPEND LLDB_TEST_DEPS darwin-debug)
add_lldb_test_dependency(darwin-debug)
endif()
# lldb-test is an hard dependency for the testsuite.
list(APPEND LLDB_TEST_DEPS lldb-test)
if(TARGET lldb-server)
list(APPEND LLDB_TEST_DEPS lldb-server)
add_lldb_test_dependency(lldb-server)
endif()
if(TARGET lldb-vscode)
list(APPEND LLDB_TEST_DEPS lldb-vscode)
add_lldb_test_dependency(lldb-vscode)
endif()
if(TARGET lldb-instr)
list(APPEND LLDB_TEST_DEPS lldb-instr)
add_lldb_test_dependency(lldb-instr)
endif()
if(NOT LLDB_BUILT_STANDALONE)
list(APPEND LLDB_TEST_DEPS yaml2obj)
add_lldb_test_dependency(yaml2obj)
endif()
if(TARGET dsymutil)
add_lldb_test_dependency(dsymutil)
endif()
if(TARGET liblldb)
list(APPEND LLDB_TEST_DEPS liblldb)
add_lldb_test_dependency(liblldb)
endif()
if(TARGET lldb-framework)
add_lldb_test_dependency(lldb-framework)
endif()
# Add dependencies if we test with the in-tree clang.
# This works with standalone builds as they import the clang target.
if(TARGET clang)
list(APPEND LLDB_TEST_DEPS clang)
add_lldb_test_dependency(clang)
if(APPLE)
# If we build clang, we should build libcxx.
# FIXME: Standalone builds should import the cxx target as well.
@ -171,23 +181,11 @@ if(LLDB_INCLUDE_TESTS)
"via `LLDB_INCLUDE_TESTS=OFF`.")
endif()
endif()
list(APPEND LLDB_TEST_DEPS cxx)
add_lldb_test_dependency(cxx)
endif()
endif()
endif()
if(TARGET dsymutil)
list(APPEND LLDB_TEST_DEPS dsymutil)
endif()
if(TARGET lldb-framework)
list(APPEND LLDB_TEST_DEPS lldb-framework)
endif()
add_custom_target(lldb-test-deps)
add_dependencies(lldb-test-deps ${LLDB_TEST_DEPS})
set_target_properties(lldb-test-deps PROPERTIES FOLDER "lldb misc")
add_subdirectory(test)
add_subdirectory(unittests)
add_subdirectory(lit)

View File

@ -27,6 +27,10 @@ function(lldb_tablegen)
endif()
endfunction(lldb_tablegen)
function(add_lldb_test_dependency name)
add_dependencies(lldb-test-deps ${name})
endfunction(add_lldb_test_dependency)
function(add_lldb_library name)
include_directories(BEFORE
${CMAKE_CURRENT_BINARY_DIR}

View File

@ -46,13 +46,9 @@ string(REPLACE ${CMAKE_CFG_INTDIR} ${dotest_args_replacement} LLDB_DOTEST_ARGS "
string(REPLACE ${CMAKE_CFG_INTDIR} ${LLVM_BUILD_MODE} LLDB_LIBS_DIR ${LLVM_LIBRARY_OUTPUT_INTDIR})
string(REPLACE ${CMAKE_CFG_INTDIR} ${LLVM_BUILD_MODE} LLDB_TOOLS_DIR ${LLVM_RUNTIME_OUTPUT_INTDIR})
list(APPEND LLDB_TEST_DEPS
LLDBUnitTests
dsymutil
add_lldb_test_dependency(
lit-cpuid
llc
lldb
lldb-test
lli
llvm-config
llvm-dwarfdump
@ -64,7 +60,7 @@ list(APPEND LLDB_TEST_DEPS
)
if(TARGET lld)
list(APPEND LLDB_TEST_DEPS lld)
add_lldb_test_dependency(lld)
endif()
# the value is not canonicalized within LLVM
@ -93,7 +89,7 @@ configure_file(
${CMAKE_CURRENT_BINARY_DIR}/lit-lldb-init)
if(NOT LLDB_BUILT_STANDALONE)
list(APPEND LLDB_TEST_DEPS
add_dependencies(lldb-test-deps
FileCheck
count
not
@ -102,7 +98,7 @@ endif()
add_lit_testsuite(check-lldb-lit "Running lldb lit test suite"
${CMAKE_CURRENT_BINARY_DIR}
DEPENDS ${LLDB_TEST_DEPS}
DEPENDS lldb-test-deps
)
set_target_properties(check-lldb-lit PROPERTIES FOLDER "lldb tests")
@ -115,5 +111,5 @@ endif()
add_lit_testsuites(LLDB
${CMAKE_CURRENT_SOURCE_DIR}
DEPENDS ${LLDB_TEST_DEPS}
DEPENDS lldb-test-deps
)

View File

@ -10,7 +10,7 @@ function(add_python_test_target name test_script args comment)
COMMENT "${comment}"
USES_TERMINAL
)
add_dependencies(${name} ${LLDB_TEST_DEPS})
add_dependencies(${name} lldb-test-deps)
endfunction()
# The default architecture with which to compile test executables is the default LLVM target
@ -109,17 +109,17 @@ if(CMAKE_HOST_APPLE)
endif()
message(STATUS "LLDB tests use out-of-tree debugserver: ${system_debugserver_path}")
list(APPEND LLDB_TEST_COMMON_ARGS --out-of-tree-debugserver)
add_dependencies(lldb-test-deps debugserver)
add_lldb_test_dependency(debugserver)
elseif(TARGET debugserver)
set(debugserver_path ${LLVM_RUNTIME_OUTPUT_INTDIR}/debugserver)
message(STATUS "LLDB Tests use just-built debugserver: ${debugserver_path}")
list(APPEND LLDB_TEST_COMMON_ARGS --server ${debugserver_path})
add_dependencies(lldb-test-deps debugserver)
add_lldb_test_dependency(debugserver)
elseif(TARGET lldb-server)
set(lldb_server_path ${LLVM_RUNTIME_OUTPUT_INTDIR}/lldb-server)
message(STATUS "LLDB Tests use just-built lldb-server: ${lldb_server_path}")
list(APPEND LLDB_TEST_COMMON_ARGS --server ${lldb_server_path})
add_dependencies(lldb-test-deps lldb-server)
add_lldb_test_dependency(lldb-server)
else()
message(WARNING "LLDB Tests enabled, but no server available")
endif()

View File

@ -1,5 +1,6 @@
add_custom_target(LLDBUnitTests)
set_target_properties(LLDBUnitTests PROPERTIES FOLDER "lldb tests")
add_dependencies(lldb-test-deps LLDBUnitTests)
include_directories(${LLDB_SOURCE_ROOT})
include_directories(${LLDB_PROJECT_ROOT}/unittests)

View File

@ -1,6 +1,6 @@
# Make lldb-dotest a custom target.
add_custom_target(lldb-dotest)
add_dependencies(lldb-dotest ${LLDB_TEST_DEPS})
add_dependencies(lldb-dotest lldb-test-deps)
set_target_properties(lldb-dotest PROPERTIES FOLDER "lldb utils")
get_property(LLDB_DOTEST_ARGS GLOBAL PROPERTY LLDB_DOTEST_ARGS_PROPERTY)