[llvm] e613f0e - Reland "Make llvm_source_root in llvm-lit relative too."

Nico Weber via llvm-commits llvm-commits at lists.llvm.org
Mon Apr 6 17:49:46 PDT 2020


Author: Nico Weber
Date: 2020-04-06T20:49:10-04:00
New Revision: e613f0ee8dfc0549f64882fdf9e221eb23e5bba6

URL: https://github.com/llvm/llvm-project/commit/e613f0ee8dfc0549f64882fdf9e221eb23e5bba6
DIFF: https://github.com/llvm/llvm-project/commit/e613f0ee8dfc0549f64882fdf9e221eb23e5bba6.diff

LOG: Reland "Make llvm_source_root in llvm-lit relative too."

This reverts commit 3185881d69022e03b300e189838b0599ed417be5
and adds a missing "include(AddLLVM)" (similar lines already
exist elsewhere in compiler-rt).

Added: 
    

Modified: 
    compiler-rt/CMakeLists.txt
    llvm/utils/llvm-lit/CMakeLists.txt
    llvm/utils/llvm-lit/llvm-lit.in

Removed: 
    


################################################################################
diff  --git a/compiler-rt/CMakeLists.txt b/compiler-rt/CMakeLists.txt
index 0ada717d7c77..fffaabe97ef0 100644
--- a/compiler-rt/CMakeLists.txt
+++ b/compiler-rt/CMakeLists.txt
@@ -529,6 +529,8 @@ if(COMPILER_RT_INCLUDE_TESTS)
     # The user can still choose to have the check targets *use* a 
diff erent lit
     # by specifying -DLLVM_EXTERNAL_LIT, but we generate it regardless.
     if (EXISTS ${LLVM_MAIN_SRC_DIR}/utils/llvm-lit)
+      # Needed for lit support in standalone builds.
+      include(AddLLVM)
       add_subdirectory(${LLVM_MAIN_SRC_DIR}/utils/llvm-lit ${CMAKE_CURRENT_BINARY_DIR}/llvm-lit)
     elseif(NOT EXISTS ${LLVM_EXTERNAL_LIT})
       message(WARNING "Could not find LLVM source directory and LLVM_EXTERNAL_LIT does not"

diff  --git a/llvm/utils/llvm-lit/CMakeLists.txt b/llvm/utils/llvm-lit/CMakeLists.txt
index 5c00f39ab4a5..1d4cbe43fede 100644
--- a/llvm/utils/llvm-lit/CMakeLists.txt
+++ b/llvm/utils/llvm-lit/CMakeLists.txt
@@ -4,12 +4,16 @@ math(EXPR file_last "${file_len} - 1")
 
 get_llvm_lit_path(LIT_BASE_DIR LIT_FILE_NAME)
 
+set(LLVM_SOURCE_DIR ${LLVM_MAIN_SRC_DIR})
+
 # LLVM_LIT_CONFIG_FILES contains interleaved main config (in the source tree)
 # and site config (in the build tree) pairs. Make them relative to
 # llvm-lit and then convert them to map_config() calls.
 if("${CMAKE_CFG_INTDIR}" STREQUAL ".")
   make_paths_relative(
-      LLVM_LIT_CONFIG_FILES "${LIT_BASE_DIR}" "${LLVM_LIT_CONFIG_FILES}")
+    LLVM_LIT_CONFIG_FILES "${LIT_BASE_DIR}" "${LLVM_LIT_CONFIG_FILES}")
+  make_paths_relative(
+    LLVM_SOURCE_DIR "${LIT_BASE_DIR}" "${LLVM_SOURCE_DIR}")
 endif()
 
 set(LLVM_LIT_CONFIG_MAP "${LLVM_LIT_PATH_FUNCTION}\n")
@@ -23,8 +27,6 @@ if (${file_last} GREATER -1)
   endforeach()
 endif()
 
-set(LLVM_SOURCE_DIR ${LLVM_MAIN_SRC_DIR})
-
 if(NOT "${CMAKE_CFG_INTDIR}" STREQUAL ".")
   foreach(BUILD_MODE ${CMAKE_CONFIGURATION_TYPES})
     string(REPLACE ${CMAKE_CFG_INTDIR} ${BUILD_MODE} bi ${LIT_BASE_DIR})

diff  --git a/llvm/utils/llvm-lit/llvm-lit.in b/llvm/utils/llvm-lit/llvm-lit.in
index 805e590814fb..bb510b4bc400 100755
--- a/llvm/utils/llvm-lit/llvm-lit.in
+++ b/llvm/utils/llvm-lit/llvm-lit.in
@@ -13,12 +13,6 @@ def map_config(source_dir, site_config):
     site_config = os.path.normpath(site_config)
     config_map[source_dir] = site_config
 
-# Variables configured at build time.
-llvm_source_root = "@LLVM_SOURCE_DIR@"
-
-# Make sure we can find the lit package.
-sys.path.insert(0, os.path.join(llvm_source_root, 'utils', 'lit'))
-
 # Set up some builtin parameters, so that by default the LLVM test suite
 # configuration file knows how to find the object tree.
 builtin_parameters = { 'build_mode' : "@BUILD_MODE@" }
@@ -27,6 +21,10 @@ builtin_parameters = { 'build_mode' : "@BUILD_MODE@" }
 
 builtin_parameters['config_map'] = config_map
 
+# Make sure we can find the lit package.
+llvm_source_root = path("@LLVM_SOURCE_DIR@")
+sys.path.insert(0, os.path.join(llvm_source_root, 'utils', 'lit'))
+
 if __name__=='__main__':
     from lit.main import main
     main(builtin_parameters)


        


More information about the llvm-commits mailing list