[Lldb-commits] [lldb] r373996 - [CMake] Track test dependencies with add_lldb_test_dependency

Jonas Devlieghere via lldb-commits lldb-commits at lists.llvm.org
Mon Oct 7 17:21:34 PDT 2019


Author: jdevlieghere
Date: Mon Oct  7 17:21:34 2019
New Revision: 373996

URL: http://llvm.org/viewvc/llvm-project?rev=373996&view=rev
Log:
[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

Modified:
    lldb/trunk/CMakeLists.txt
    lldb/trunk/cmake/modules/AddLLDB.cmake
    lldb/trunk/lit/CMakeLists.txt
    lldb/trunk/test/CMakeLists.txt
    lldb/trunk/unittests/CMakeLists.txt
    lldb/trunk/utils/lldb-dotest/CMakeLists.txt

Modified: lldb/trunk/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/CMakeLists.txt?rev=373996&r1=373995&r2=373996&view=diff
==============================================================================
--- lldb/trunk/CMakeLists.txt (original)
+++ lldb/trunk/CMakeLists.txt Mon Oct  7 17:21:34 2019
@@ -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)

Modified: lldb/trunk/cmake/modules/AddLLDB.cmake
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/cmake/modules/AddLLDB.cmake?rev=373996&r1=373995&r2=373996&view=diff
==============================================================================
--- lldb/trunk/cmake/modules/AddLLDB.cmake (original)
+++ lldb/trunk/cmake/modules/AddLLDB.cmake Mon Oct  7 17:21:34 2019
@@ -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}

Modified: lldb/trunk/lit/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lit/CMakeLists.txt?rev=373996&r1=373995&r2=373996&view=diff
==============================================================================
--- lldb/trunk/lit/CMakeLists.txt (original)
+++ lldb/trunk/lit/CMakeLists.txt Mon Oct  7 17:21:34 2019
@@ -46,13 +46,9 @@ string(REPLACE ${CMAKE_CFG_INTDIR} ${dot
 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
   )

Modified: lldb/trunk/test/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/CMakeLists.txt?rev=373996&r1=373995&r2=373996&view=diff
==============================================================================
--- lldb/trunk/test/CMakeLists.txt (original)
+++ lldb/trunk/test/CMakeLists.txt Mon Oct  7 17:21:34 2019
@@ -10,7 +10,7 @@ function(add_python_test_target name tes
     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()

Modified: lldb/trunk/unittests/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/unittests/CMakeLists.txt?rev=373996&r1=373995&r2=373996&view=diff
==============================================================================
--- lldb/trunk/unittests/CMakeLists.txt (original)
+++ lldb/trunk/unittests/CMakeLists.txt Mon Oct  7 17:21:34 2019
@@ -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)

Modified: lldb/trunk/utils/lldb-dotest/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/utils/lldb-dotest/CMakeLists.txt?rev=373996&r1=373995&r2=373996&view=diff
==============================================================================
--- lldb/trunk/utils/lldb-dotest/CMakeLists.txt (original)
+++ lldb/trunk/utils/lldb-dotest/CMakeLists.txt Mon Oct  7 17:21:34 2019
@@ -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)




More information about the lldb-commits mailing list