Index: llvm/cmake/modules/AddLLVM.cmake =================================================================== --- llvm/cmake/modules/AddLLVM.cmake +++ llvm/cmake/modules/AddLLVM.cmake @@ -687,7 +687,7 @@ # it forces Xcode to properly link the static library. list(APPEND ALL_FILES "${LLVM_MAIN_SRC_DIR}/cmake/dummy.cpp") endif() - + if( EXCLUDE_FROM_ALL ) add_executable(${name} EXCLUDE_FROM_ALL ${ALL_FILES}) else() @@ -1112,7 +1112,13 @@ # variables needed for the 'lit.site.cfg' files. This function bundles the # common variables that any Lit instance is likely to need, and custom # variables can be passed in. -function(configure_lit_site_cfg input output) +function(configure_lit_site_cfg site_in site_out) + cmake_parse_arguments(ARG "" "" "MAIN_CONFIG" ${ARGN}) + + if ("${ARG_MAIN_CONFIG}" STREQUAL "") + set(ARG_MAIN_CONFIG "${CMAKE_CURRENT_SOURCE_DIR}/lit.cfg") + endif() + foreach(c ${LLVM_TARGETS_TO_BUILD}) set(TARGETS_BUILT "${TARGETS_BUILT} ${c}") endforeach(c) @@ -1158,7 +1164,7 @@ set(HOST_CXX "${CMAKE_CXX_COMPILER} ${CMAKE_CXX_COMPILER_ARG1}") set(HOST_LDFLAGS "${CMAKE_EXE_LINKER_FLAGS}") - set(LIT_SITE_CFG_IN_HEADER "## Autogenerated from ${input}\n## Do not edit!") + set(LIT_SITE_CFG_IN_HEADER "## Autogenerated from ${site_in}\n## Do not edit!") # Override config_target_triple (and the env) if(LLVM_TARGET_TRIPLE_ENV) @@ -1177,10 +1183,10 @@ "import lit.llvm\n" "lit.llvm.initialize(lit_config, config)\n") - configure_file(${input} ${output} @ONLY) - get_filename_component(INPUT_DIR ${input} DIRECTORY) - if (EXISTS "${INPUT_DIR}/lit.cfg") - set(PYTHON_STATEMENT "map_config('${INPUT_DIR}/lit.cfg', '${output}')") + configure_file(${site_in} ${site_out} @ONLY) + get_filename_component(INPUT_DIR ${site_in} DIRECTORY) + if (EXISTS "${ARG_MAIN_CONFIG}") + set(PYTHON_STATEMENT "map_config('${ARG_MAIN_CONFIG}', '${site_out}')") get_property(LLVM_LIT_CONFIG_MAP GLOBAL PROPERTY LLVM_LIT_CONFIG_MAP) set(LLVM_LIT_CONFIG_MAP "${LLVM_LIT_CONFIG_MAP}\n${PYTHON_STATEMENT}") set_property(GLOBAL PROPERTY LLVM_LIT_CONFIG_MAP ${LLVM_LIT_CONFIG_MAP}) @@ -1365,7 +1371,7 @@ # magic. First we grab one of the types, and a type-specific path. Then from # the type-specific path we find the last occurrence of the type in the path, # and replace it with CMAKE_CFG_INTDIR. This allows the build step to be type - # agnostic again. + # agnostic again. if(NOT ARG_OUTPUT_DIR) # If you're not overriding the OUTPUT_DIR, we can make the link relative in # the same directory. Index: llvm/test/CMakeLists.txt =================================================================== --- llvm/test/CMakeLists.txt +++ llvm/test/CMakeLists.txt @@ -11,12 +11,16 @@ BUILD_SHARED_LIBS) configure_lit_site_cfg( - ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in - ${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg + ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.py.in + ${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg.py + MAIN_CONFIG + ${CMAKE_CURRENT_SOURCE_DIR}/lit.cfg.py ) configure_lit_site_cfg( - ${CMAKE_CURRENT_SOURCE_DIR}/Unit/lit.site.cfg.in - ${CMAKE_CURRENT_BINARY_DIR}/Unit/lit.site.cfg + ${CMAKE_CURRENT_SOURCE_DIR}/Unit/lit.site.cfg.py.in + ${CMAKE_CURRENT_BINARY_DIR}/Unit/lit.site.cfg.py + MAIN_CONFIG + ${CMAKE_CURRENT_SOURCE_DIR}/Unit/lit.cfg.py ) # Don't include check-llvm into check-all without LLVM_BUILD_TOOLS. @@ -148,15 +152,11 @@ add_lit_testsuite(check-llvm "Running the LLVM regression tests" ${CMAKE_CURRENT_BINARY_DIR} - PARAMS llvm_site_config=${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg - llvm_unit_site_config=${CMAKE_CURRENT_BINARY_DIR}/Unit/lit.site.cfg DEPENDS ${LLVM_TEST_DEPENDS} ) set_target_properties(check-llvm PROPERTIES FOLDER "Tests") add_lit_testsuites(LLVM ${CMAKE_CURRENT_SOURCE_DIR} - PARAMS llvm_site_config=${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg - llvm_unit_site_config=${CMAKE_CURRENT_BINARY_DIR}/Unit/lit.site.cfg DEPENDS ${LLVM_TEST_DEPENDS} ) Index: llvm/test/Unit/lit.site.cfg.py.in =================================================================== --- llvm/test/Unit/lit.site.cfg.py.in +++ llvm/test/Unit/lit.site.cfg.py.in @@ -20,4 +20,4 @@ lit_config.fatal("unable to find %r parameter, use '--param=%s=VALUE'" % (key,key)) # Let the main config do the real work. -lit_config.load_config(config, "@LLVM_SOURCE_DIR@/test/Unit/lit.cfg") +lit_config.load_config(config, "@LLVM_SOURCE_DIR@/test/Unit/lit.cfg.py") Index: llvm/test/lit.site.cfg.py.in =================================================================== --- llvm/test/lit.site.cfg.py.in +++ llvm/test/lit.site.cfg.py.in @@ -55,4 +55,4 @@ @LIT_SITE_CFG_IN_FOOTER@ # Let the main config do the real work. -lit_config.load_config(config, "@LLVM_SOURCE_DIR@/test/lit.cfg") +lit_config.load_config(config, "@LLVM_SOURCE_DIR@/test/lit.cfg.py") Index: llvm/utils/lit/lit/LitConfig.py =================================================================== --- llvm/utils/lit/lit/LitConfig.py +++ llvm/utils/lit/lit/LitConfig.py @@ -43,9 +43,10 @@ # Configuration files to look for when discovering test suites. self.config_prefix = config_prefix or 'lit' - self.config_name = '%s.cfg' % (self.config_prefix,) - self.site_config_name = '%s.site.cfg' % (self.config_prefix,) - self.local_config_name = '%s.local.cfg' % (self.config_prefix,) + self.suffixes = ['cfg.py', 'cfg'] + self.config_names = ['%s.%s' % (self.config_prefix,x) for x in self.suffixes] + self.site_config_names = ['%s.site.%s' % (self.config_prefix,x) for x in self.suffixes] + self.local_config_names = ['%s.local.%s' % (self.config_prefix,x) for x in self.suffixes] self.numErrors = 0 self.numWarnings = 0 Index: llvm/utils/lit/lit/discovery.py =================================================================== --- llvm/utils/lit/lit/discovery.py +++ llvm/utils/lit/lit/discovery.py @@ -10,13 +10,18 @@ from lit.TestingConfig import TestingConfig from lit import LitConfig, Test +def chooseConfigFileFromDir(dir, config_names): + for name in config_names: + p = os.path.join(dir, name) + if os.path.exists(p): + return p + return None + def dirContainsTestSuite(path, lit_config): - cfgpath = os.path.join(path, lit_config.site_config_name) - if os.path.exists(cfgpath): - return cfgpath - cfgpath = os.path.join(path, lit_config.config_name) - if os.path.exists(cfgpath): - return cfgpath + cfgpath = chooseConfigFileFromDir(path, lit_config.site_config_names) + if not cfgpath: + cfgpath = chooseConfigFileFromDir(path, lit_config.config_names) + return cfgpath def getTestSuite(item, litConfig, cache): """getTestSuite(item, litConfig, cache) -> (suite, relative_path) @@ -92,10 +97,10 @@ # Check if there is a local configuration file. source_path = ts.getSourcePath(path_in_suite) - cfgpath = os.path.join(source_path, litConfig.local_config_name) + cfgpath = chooseConfigFileFromDir(source_path, litConfig.local_config_names) # If not, just reuse the parent config. - if not os.path.exists(cfgpath): + if not cfgpath: return parent # Otherwise, copy the current config and load the local configuration