1# -*- Python -*- 2 3# Configuration file for 'lit' test runner. 4# This file contains common rules for various compiler-rt testsuites. 5# It is mostly copied from lit.cfg used by Clang. 6import os 7import platform 8 9import lit.formats 10import lit.util 11 12# Setup test format 13execute_external = (platform.system() != 'Windows' 14 or lit_config.getBashPath() not in [None, ""]) 15config.test_format = lit.formats.ShTest(execute_external) 16 17# Setup clang binary. 18compiler_path = getattr(config, 'clang', None) 19if (not compiler_path) or (not os.path.exists(compiler_path)): 20 lit_config.fatal("Can't find compiler on path %r" % compiler_path) 21 22compiler_id = getattr(config, 'compiler_id', None) 23if compiler_id == "Clang": 24 if platform.system() != 'Windows': 25 config.cxx_mode_flags = ["--driver-mode=g++"] 26 else: 27 config.cxx_mode_flags = [] 28elif compiler_id == 'GNU': 29 config.cxx_mode_flags = ["-x c++"] 30else: 31 lit_config.fatal("Unsupported compiler id: %r" % compiler_id) 32# Add compiler ID to the list of available features. 33config.available_features.add(compiler_id) 34 35# Clear some environment variables that might affect Clang. 36possibly_dangerous_env_vars = ['COMPILER_PATH', 'RC_DEBUG_OPTIONS', 37 'CINDEXTEST_PREAMBLE_FILE', 'LIBRARY_PATH', 38 'CPATH', 'C_INCLUDE_PATH', 'CPLUS_INCLUDE_PATH', 39 'OBJC_INCLUDE_PATH', 'OBJCPLUS_INCLUDE_PATH', 40 'LIBCLANG_TIMING', 'LIBCLANG_OBJTRACKING', 41 'LIBCLANG_LOGGING', 'LIBCLANG_BGPRIO_INDEX', 42 'LIBCLANG_BGPRIO_EDIT', 'LIBCLANG_NOTHREADS', 43 'LIBCLANG_RESOURCE_USAGE', 44 'LIBCLANG_CODE_COMPLETION_LOGGING'] 45# Clang/Win32 may refer to %INCLUDE%. vsvarsall.bat sets it. 46if platform.system() != 'Windows': 47 possibly_dangerous_env_vars.append('INCLUDE') 48for name in possibly_dangerous_env_vars: 49 if name in config.environment: 50 del config.environment[name] 51 52# Tweak PATH to include llvm tools dir. 53llvm_tools_dir = getattr(config, 'llvm_tools_dir', None) 54if (not llvm_tools_dir) or (not os.path.exists(llvm_tools_dir)): 55 lit_config.fatal("Invalid llvm_tools_dir config attribute: %r" % llvm_tools_dir) 56path = os.path.pathsep.join((llvm_tools_dir, config.environment['PATH'])) 57config.environment['PATH'] = path 58 59# Help MSVS link.exe find the standard libraries. 60if platform.system() == 'Windows': 61 config.environment['LIB'] = os.environ['LIB'] 62 63# Use ugly construction to explicitly prohibit "clang", "clang++" etc. 64# in RUN lines. 65config.substitutions.append( 66 (' clang', """\n\n*** Do not use 'clangXXX' in tests, 67 instead define '%clangXXX' substitution in lit config. ***\n\n""") ) 68 69# Allow tests to be executed on a simulator or remotely. 70config.substitutions.append( ('%run', config.emulator) ) 71 72# Add supported compiler_rt architectures to a list of available features. 73compiler_rt_arch = getattr(config, 'compiler_rt_arch', None) 74if compiler_rt_arch: 75 for arch in compiler_rt_arch.split(";"): 76 config.available_features.add(arch + "-supported-target") 77 78compiler_rt_debug = getattr(config, 'compiler_rt_debug', False) 79if not compiler_rt_debug: 80 config.available_features.add('compiler-rt-optimized') 81 82lit.util.usePlatformSdkOnDarwin(config, lit_config) 83