diff options
author | Zachary Turner <zturner@google.com> | 2017-09-15 22:10:46 +0000 |
---|---|---|
committer | Zachary Turner <zturner@google.com> | 2017-09-15 22:10:46 +0000 |
commit | ce92db13ead9a24c767d60375545fa6ad6cb8ce0 (patch) | |
tree | fb503ae2b3c9ce191091cdfd88ceb73ac4c9ff72 /llvm/utils | |
parent | bcd78491ef22754d15ea4dddea2425e0e673baf9 (diff) | |
download | bcm5719-llvm-ce92db13ead9a24c767d60375545fa6ad6cb8ce0.tar.gz bcm5719-llvm-ce92db13ead9a24c767d60375545fa6ad6cb8ce0.zip |
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
llvm-svn: 313407
Diffstat (limited to 'llvm/utils')
-rw-r--r-- | llvm/utils/lit/lit/discovery.py | 16 | ||||
-rw-r--r-- | llvm/utils/lit/tests/lit.cfg | 5 | ||||
-rw-r--r-- | llvm/utils/llvm-lit/CMakeLists.txt | 15 | ||||
-rwxr-xr-x | llvm/utils/llvm-lit/llvm-lit.in | 50 |
4 files changed, 39 insertions, 47 deletions
diff --git a/llvm/utils/lit/lit/discovery.py b/llvm/utils/lit/lit/discovery.py index 8876dcba8f2..3b5d0517cff 100644 --- a/llvm/utils/lit/lit/discovery.py +++ b/llvm/utils/lit/lit/discovery.py @@ -40,6 +40,20 @@ def getTestSuite(item, litConfig, cache): ts, relative = search(parent) return (ts, relative + (base,)) + # This is a private builtin parameter which can be used to perform + # translation of configuration paths. Specifically, this parameter + # can be set to a dictionary that the discovery process will consult + # when it finds a configuration it is about to load. If the given + # path is in the map, the value of that key is a path to the + # configuration to load instead. + config_map = litConfig.params.get('config_map') + if config_map: + cfgpath = os.path.normpath(cfgpath) + cfgpath = os.path.normcase(cfgpath) + target = config_map.get(cfgpath) + if target: + cfgpath = target + # We found a test suite, create a new config for it and load it. if litConfig.debug: litConfig.note('loading suite config %r' % cfgpath) @@ -212,7 +226,7 @@ def find_tests_for_inputs(lit_config, inputs): f.close() else: actual_inputs.append(input) - + # Load the tests from the inputs. tests = [] test_suite_cache = {} diff --git a/llvm/utils/lit/tests/lit.cfg b/llvm/utils/lit/tests/lit.cfg index 0c98299285a..f2ecaa6d417 100644 --- a/llvm/utils/lit/tests/lit.cfg +++ b/llvm/utils/lit/tests/lit.cfg @@ -65,7 +65,6 @@ if sys.platform.startswith('win') or sys.platform.startswith('cygwin'): config.available_features.add('windows') # Add llvm tools directory if this config is being loaded indirectly -llvm_tools_dir = getattr(config, 'llvm_tools_dir', None) -if llvm_tools_dir != None: - path = os.path.pathsep.join((llvm_tools_dir, config.environment['PATH'])) +if config.llvm_tools_dir is not None: + path = os.path.pathsep.join((config.llvm_tools_dir, config.environment['PATH'])) config.environment['PATH'] = path diff --git a/llvm/utils/llvm-lit/CMakeLists.txt b/llvm/utils/llvm-lit/CMakeLists.txt index 4b10354cfde..670175c8185 100644 --- a/llvm/utils/llvm-lit/CMakeLists.txt +++ b/llvm/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/llvm/utils/llvm-lit/llvm-lit.in b/llvm/utils/llvm-lit/llvm-lit.in index 08a2a670b21..efad97ade7e 100755 --- a/llvm/utils/llvm-lit/llvm-lit.in +++ b/llvm/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 |