Alexey Samsonov | 7274ff8 | 2012-07-31 15:43:11 +0000 | [diff] [blame] | 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. |
| 6 | import os |
| 7 | import platform |
| 8 | |
Daniel Dunbar | a1b15b4 | 2013-08-09 22:14:01 +0000 | [diff] [blame] | 9 | import lit.formats |
| 10 | |
Alexey Samsonov | 7274ff8 | 2012-07-31 15:43:11 +0000 | [diff] [blame] | 11 | # Setup test format |
| 12 | execute_external = (platform.system() != 'Windows' |
Daniel Dunbar | a1b15b4 | 2013-08-09 22:14:01 +0000 | [diff] [blame] | 13 | or lit_config.getBashPath() not in [None, ""]) |
Alexey Samsonov | 7274ff8 | 2012-07-31 15:43:11 +0000 | [diff] [blame] | 14 | config.test_format = lit.formats.ShTest(execute_external) |
| 15 | |
| 16 | # Setup clang binary. |
| 17 | clang_path = getattr(config, 'clang', None) |
| 18 | if (not clang_path) or (not os.path.exists(clang_path)): |
Daniel Dunbar | a1b15b4 | 2013-08-09 22:14:01 +0000 | [diff] [blame] | 19 | lit_config.fatal("Can't find Clang on path %r" % clang_path) |
Alexey Samsonov | 7274ff8 | 2012-07-31 15:43:11 +0000 | [diff] [blame] | 20 | |
| 21 | # Clear some environment variables that might affect Clang. |
| 22 | possibly_dangerous_env_vars = ['COMPILER_PATH', 'RC_DEBUG_OPTIONS', |
| 23 | 'CINDEXTEST_PREAMBLE_FILE', 'LIBRARY_PATH', |
| 24 | 'CPATH', 'C_INCLUDE_PATH', 'CPLUS_INCLUDE_PATH', |
| 25 | 'OBJC_INCLUDE_PATH', 'OBJCPLUS_INCLUDE_PATH', |
| 26 | 'LIBCLANG_TIMING', 'LIBCLANG_OBJTRACKING', |
| 27 | 'LIBCLANG_LOGGING', 'LIBCLANG_BGPRIO_INDEX', |
| 28 | 'LIBCLANG_BGPRIO_EDIT', 'LIBCLANG_NOTHREADS', |
| 29 | 'LIBCLANG_RESOURCE_USAGE', |
| 30 | 'LIBCLANG_CODE_COMPLETION_LOGGING'] |
| 31 | # Clang/Win32 may refer to %INCLUDE%. vsvarsall.bat sets it. |
| 32 | if platform.system() != 'Windows': |
| 33 | possibly_dangerous_env_vars.append('INCLUDE') |
| 34 | for name in possibly_dangerous_env_vars: |
| 35 | if name in config.environment: |
| 36 | del config.environment[name] |
| 37 | |
Alexey Samsonov | 6ffcb58 | 2012-08-07 11:00:19 +0000 | [diff] [blame] | 38 | # Tweak PATH to include llvm tools dir. |
| 39 | llvm_tools_dir = getattr(config, 'llvm_tools_dir', None) |
| 40 | if (not llvm_tools_dir) or (not os.path.exists(llvm_tools_dir)): |
Daniel Dunbar | a1b15b4 | 2013-08-09 22:14:01 +0000 | [diff] [blame] | 41 | lit_config.fatal("Invalid llvm_tools_dir config attribute: %r" % llvm_tools_dir) |
Alexey Samsonov | 6ffcb58 | 2012-08-07 11:00:19 +0000 | [diff] [blame] | 42 | path = os.path.pathsep.join((llvm_tools_dir, config.environment['PATH'])) |
| 43 | config.environment['PATH'] = path |
| 44 | |
Alexey Samsonov | fe18723 | 2013-06-30 14:47:38 +0000 | [diff] [blame] | 45 | # Define path to external llvm-symbolizer tool. |
| 46 | config.llvm_symbolizer_path = os.path.join(llvm_tools_dir, "llvm-symbolizer") |
| 47 | |
Alexey Samsonov | 7274ff8 | 2012-07-31 15:43:11 +0000 | [diff] [blame] | 48 | # Use ugly construction to explicitly prohibit "clang", "clang++" etc. |
| 49 | # in RUN lines. |
| 50 | config.substitutions.append( |
| 51 | (' clang', """\n\n*** Do not use 'clangXXX' in tests, |
| 52 | instead define '%clangXXX' substitution in lit config. ***\n\n""") ) |
Alexey Samsonov | 6b5346e | 2013-05-21 08:22:03 +0000 | [diff] [blame] | 53 | |
| 54 | # Add supported compiler_rt architectures to a list of available features. |
| 55 | compiler_rt_arch = getattr(config, 'compiler_rt_arch', None) |
| 56 | if compiler_rt_arch: |
| 57 | for arch in compiler_rt_arch.split(";"): |
| 58 | config.available_features.add(arch + "-supported-target") |
Peter Collingbourne | 7e8db74 | 2013-10-25 23:03:34 +0000 | [diff] [blame] | 59 | |
| 60 | compiler_rt_debug = getattr(config, 'compiler_rt_debug', False) |
| 61 | if not compiler_rt_debug: |
| 62 | config.available_features.add('compiler-rt-optimized') |