summaryrefslogtreecommitdiff
path: root/utils/llvm-lit
diff options
context:
space:
mode:
authorZachary Turner <zturner@google.com>2017-09-15 22:10:46 +0000
committerZachary Turner <zturner@google.com>2017-09-15 22:10:46 +0000
commita0f1ea32df562bd3397047159ecad7eaea5d9bf8 (patch)
treeaec6f6681011e41a4fdd62faf8bfe3909c21f1bb /utils/llvm-lit
parent5461cbf32f0945943dab2f08a94ea42e81c78bdb (diff)
Resubmit "[lit] Force site configs to run before source-tree configs"
This is a resubmission of r313270. It broke standalone builds of compiler-rt because we were not correctly generating the llvm-lit script in the standalone build directory. The fixes incorporated here attempt to find llvm/utils/llvm-lit from the source tree returned by llvm-config. If present, it will generate llvm-lit into the output directory. Regardless, the user can specify -DLLVM_EXTERNAL_LIT to point to a specific lit.py on their file system. This supports the use case of someone installing lit via a package manager. If it cannot find a source tree, and -DLLVM_EXTERNAL_LIT is either unspecified or invalid, then we print a warning that tests will not be able to run. Differential Revision: https://reviews.llvm.org/D37756 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@313407 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'utils/llvm-lit')
-rw-r--r--utils/llvm-lit/CMakeLists.txt15
-rwxr-xr-xutils/llvm-lit/llvm-lit.in50
2 files changed, 22 insertions, 43 deletions
diff --git a/utils/llvm-lit/CMakeLists.txt b/utils/llvm-lit/CMakeLists.txt
index 4b10354cfde..670175c8185 100644
--- a/utils/llvm-lit/CMakeLists.txt
+++ b/utils/llvm-lit/CMakeLists.txt
@@ -1,12 +1,13 @@
-if (WIN32 AND NOT CYGWIN)
- # llvm-lit needs suffix.py for multiprocess to find a main module.
- set(suffix .py)
-endif ()
-set(llvm_lit_path ${LLVM_RUNTIME_OUTPUT_INTDIR}/llvm-lit${suffix})
+get_property(LLVM_LIT_CONFIG_MAP GLOBAL PROPERTY LLVM_LIT_CONFIG_MAP)
+
+get_llvm_lit_path(LIT_BASE_DIR LIT_FILE_NAME)
+
+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 ${llvm_lit_path})
+ string(REPLACE ${CMAKE_CFG_INTDIR} ${BUILD_MODE} bi ${LIT_BASE_DIR})
+ set(bi "${bi}/${LIT_FILE_NAME}")
configure_file(
llvm-lit.in
${bi}
@@ -16,6 +17,6 @@ else()
set(BUILD_MODE .)
configure_file(
llvm-lit.in
- ${llvm_lit_path}
+ ${LIT_BASE_DIR}/${LIT_FILE_NAME}
)
endif()
diff --git a/utils/llvm-lit/llvm-lit.in b/utils/llvm-lit/llvm-lit.in
index 08a2a670b21..efad97ade7e 100755
--- a/utils/llvm-lit/llvm-lit.in
+++ b/utils/llvm-lit/llvm-lit.in
@@ -3,6 +3,15 @@
import os
import sys
+config_map = {}
+
+def map_config(source_dir, site_config):
+ global config_map
+ source_dir = os.path.normpath(source_dir)
+ source_dir = os.path.normcase(source_dir)
+ site_config = os.path.normpath(site_config)
+ config_map[source_dir] = site_config
+
# Variables configured at build time.
llvm_source_root = "@LLVM_SOURCE_DIR@"
llvm_obj_root = "@LLVM_BINARY_DIR@"
@@ -12,42 +21,11 @@ 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@",
- 'llvm_site_config' : os.path.join(llvm_obj_root, 'test', 'lit.site.cfg'),
- 'llvm_unit_site_config' : os.path.join(llvm_obj_root, 'test', 'Unit',
- 'lit.site.cfg')
- }
-
-clang_obj_root = os.path.join(llvm_obj_root, 'tools', 'clang')
-
-if os.path.exists(clang_obj_root):
- builtin_parameters['clang_site_config'] = \
- os.path.join(clang_obj_root, 'test', 'lit.site.cfg')
- clang_tools_extra_obj_root = os.path.join(clang_obj_root, 'tools', 'extra')
- if os.path.exists(clang_tools_extra_obj_root):
- builtin_parameters['clang_tools_extra_site_config'] = \
- os.path.join(clang_tools_extra_obj_root, 'test', 'lit.site.cfg')
-
-lld_obj_root = os.path.join(llvm_obj_root, 'tools', 'lld')
-if os.path.exists(lld_obj_root):
- builtin_parameters['lld_site_config'] = \
- os.path.join(lld_obj_root, 'test', 'lit.site.cfg')
-
-compilerrt_obj_root = os.path.join(llvm_obj_root, 'projects', 'compiler-rt')
-if os.path.exists(compilerrt_obj_root):
- builtin_parameters['compilerrt_site_basedir'] = \
- os.path.join(compilerrt_obj_root, 'test')
-
-libcxx_obj_root = os.path.join(llvm_obj_root, 'projects', 'libcxx')
-if os.path.exists(libcxx_obj_root):
- builtin_parameters['libcxx_site_config'] = \
- os.path.join(libcxx_obj_root, 'test', 'lit.site.cfg')
-
-libcxxabi_obj_root = os.path.join(llvm_obj_root, 'projects', 'libcxxabi')
-if os.path.exists(libcxxabi_obj_root):
- builtin_parameters['libcxxabi_site_config'] = \
- os.path.join(libcxxabi_obj_root, 'test', 'lit.site.cfg')
+builtin_parameters = { 'build_mode' : "@BUILD_MODE@" }
+
+@LLVM_LIT_CONFIG_MAP@
+
+builtin_parameters['config_map'] = config_map
if __name__=='__main__':
from lit.main import main