[PATCH] D37997: [libcxx / lit] Make libcxx work correctly with the new testing workflow

Zachary Turner via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 18 14:13:18 PDT 2017


zturner created this revision.
Herald added a subscriber: mgorny.
Herald added a reviewer: EricWF.

Some changes to lit made it so you no longer specify `--project_site_param=<path>`, and instead you run the `llvm-lit` script generated into the build directory of your project.

Not all projects had been updated accordingly, and this broke running the test suite in libcxx (among other projects).  This patch attempts to get libcxx working correctly.  Now, when you do a standalone build, `llvm-lit` is written into the `<build-dir>/bin` and contains the necessary mappings so that you can run either a check target or pointing it to a source tree.


https://reviews.llvm.org/D37997

Files:
  libcxx/CMakeLists.txt
  libcxx/cmake/Modules/HandleOutOfTreeLLVM.cmake
  libcxx/test/CMakeLists.txt
  llvm/cmake/modules/AddLLVM.cmake


Index: llvm/cmake/modules/AddLLVM.cmake
===================================================================
--- llvm/cmake/modules/AddLLVM.cmake
+++ llvm/cmake/modules/AddLLVM.cmake
@@ -1130,11 +1130,11 @@
   # They below might not be the build tree but provided binary tree.
   set(LLVM_SOURCE_DIR ${LLVM_MAIN_SRC_DIR})
   set(LLVM_BINARY_DIR ${LLVM_BINARY_DIR})
-  string(REPLACE ${CMAKE_CFG_INTDIR} ${LLVM_BUILD_MODE} LLVM_TOOLS_DIR ${LLVM_TOOLS_BINARY_DIR})
-  string(REPLACE ${CMAKE_CFG_INTDIR} ${LLVM_BUILD_MODE} LLVM_LIBS_DIR  ${LLVM_LIBRARY_DIR})
+  string(REPLACE "${CMAKE_CFG_INTDIR}" "${LLVM_BUILD_MODE}" LLVM_TOOLS_DIR "${LLVM_TOOLS_BINARY_DIR}")
+  string(REPLACE ${CMAKE_CFG_INTDIR} ${LLVM_BUILD_MODE} LLVM_LIBS_DIR  "${LLVM_LIBRARY_DIR}")
 
   # SHLIBDIR points the build tree.
-  string(REPLACE ${CMAKE_CFG_INTDIR} ${LLVM_BUILD_MODE} SHLIBDIR "${LLVM_SHLIB_OUTPUT_INTDIR}")
+  string(REPLACE "${CMAKE_CFG_INTDIR}" "${LLVM_BUILD_MODE}" SHLIBDIR "${LLVM_SHLIB_OUTPUT_INTDIR}")
 
   set(PYTHON_EXECUTABLE ${PYTHON_EXECUTABLE})
   # FIXME: "ENABLE_SHARED" doesn't make sense, since it is used just for
@@ -1187,6 +1187,13 @@
   endif()
 endfunction()
 
+function(dump_all_cmake_variables)
+  get_cmake_property(_variableNames VARIABLES)
+  foreach (_variableName ${_variableNames})
+    message(STATUS "${_variableName}=${${_variableName}}")
+  endforeach()
+endfunction()
+
 function(get_llvm_lit_path base_dir file_name)
   cmake_parse_arguments(ARG "ALLOW_EXTERNAL" "" "" ${ARGN})
 
Index: libcxx/test/CMakeLists.txt
===================================================================
--- libcxx/test/CMakeLists.txt
+++ libcxx/test/CMakeLists.txt
@@ -49,10 +49,9 @@
 
 set(AUTO_GEN_COMMENT "## Autogenerated by libcxx configuration.\n# Do not edit!")
 
-configure_file(
+configure_lit_site_cfg(
   ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in
-  ${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg
-  @ONLY)
+  ${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg)
 
 set(LIBCXX_TEST_DEPS "")
 
Index: libcxx/cmake/Modules/HandleOutOfTreeLLVM.cmake
===================================================================
--- libcxx/cmake/Modules/HandleOutOfTreeLLVM.cmake
+++ libcxx/cmake/Modules/HandleOutOfTreeLLVM.cmake
@@ -106,6 +106,11 @@
     set(LLVM_ENABLE_SPHINX OFF)
   endif()
 
+  # In a standalone build, we don't have llvm to automatically generate the
+  # llvm-lit script for us.  So we need to provide an explicit directory that
+  # the configurator should write the script into.
+  set(LLVM_LIT_OUTPUT_DIR "${libcxx_BINARY_DIR}/bin")
+
   # Required LIT Configuration ------------------------------------------------
   # Define the default arguments to use with 'lit', and an option for the user
   # to override.
Index: libcxx/CMakeLists.txt
===================================================================
--- libcxx/CMakeLists.txt
+++ libcxx/CMakeLists.txt
@@ -653,13 +653,23 @@
 #
 # However, since some submission systems strip test/ subdirectories, check for
 # it before adding it.
+
 if(IS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/test")
   add_subdirectory(test)
 endif()
 if (LIBCXX_INCLUDE_TESTS)
   add_subdirectory(lib/abi)
 endif()
 
+if (LIBCXX_STANDALONE_BUILD AND EXISTS "${LLVM_MAIN_SRC_DIR}/utils/llvm-lit")
+  # Make sure the llvm-lit script is generated into the bin directory, and do
+  # it after adding all tests, since the generated script will only work
+  # correctly discovered tests against test locations from the source tree that
+  # have already been discovered.
+  add_subdirectory(${LLVM_MAIN_SRC_DIR}/utils/llvm-lit
+                   ${CMAKE_CURRENT_BINARY_DIR}/llvm-lit)
+endif()
+
 if (LIBCXX_INCLUDE_DOCS)
   add_subdirectory(docs)
 endif()


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D37997.115717.patch
Type: text/x-patch
Size: 3690 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170918/5582af54/attachment.bin>


More information about the llvm-commits mailing list