From 37cf39df20825980adf55143005b553bb7e12047 Mon Sep 17 00:00:00 2001 From: Jonas Devlieghere Date: Tue, 8 Oct 2019 00:21:34 +0000 Subject: [PATCH] [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 --- lldb/CMakeLists.txt | 46 +++++++++++++-------------- lldb/cmake/modules/AddLLDB.cmake | 4 +++ lldb/lit/CMakeLists.txt | 14 +++----- lldb/test/CMakeLists.txt | 8 ++--- lldb/unittests/CMakeLists.txt | 1 + lldb/utils/lldb-dotest/CMakeLists.txt | 2 +- 6 files changed, 37 insertions(+), 38 deletions(-) diff --git a/lldb/CMakeLists.txt b/lldb/CMakeLists.txt index 90732cf9547a..48b6f694460d 100644 --- a/lldb/CMakeLists.txt +++ b/lldb/CMakeLists.txt @@ -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) diff --git a/lldb/cmake/modules/AddLLDB.cmake b/lldb/cmake/modules/AddLLDB.cmake index c6a7979279a0..f6402f94385c 100644 --- a/lldb/cmake/modules/AddLLDB.cmake +++ b/lldb/cmake/modules/AddLLDB.cmake @@ -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} diff --git a/lldb/lit/CMakeLists.txt b/lldb/lit/CMakeLists.txt index fbd64afbb1c9..b7ba6789842a 100644 --- a/lldb/lit/CMakeLists.txt +++ b/lldb/lit/CMakeLists.txt @@ -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 ) diff --git a/lldb/test/CMakeLists.txt b/lldb/test/CMakeLists.txt index 985592f2b20b..f4bf7df92ae5 100644 --- a/lldb/test/CMakeLists.txt +++ b/lldb/test/CMakeLists.txt @@ -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() diff --git a/lldb/unittests/CMakeLists.txt b/lldb/unittests/CMakeLists.txt index 084b8bf23eaf..22c684f4fce3 100644 --- a/lldb/unittests/CMakeLists.txt +++ b/lldb/unittests/CMakeLists.txt @@ -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) diff --git a/lldb/utils/lldb-dotest/CMakeLists.txt b/lldb/utils/lldb-dotest/CMakeLists.txt index 0c61b2bf26a6..4f1bd7304abf 100644 --- a/lldb/utils/lldb-dotest/CMakeLists.txt +++ b/lldb/utils/lldb-dotest/CMakeLists.txt @@ -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)