Daniel Dunbar | 6c1c9cf | 2009-11-10 02:41:17 +0000 | [diff] [blame] | 1 | # -*- Python -*- |
| 2 | |
| 3 | # Configuration file for the 'lit' test runner. |
| 4 | |
| 5 | # name: The name of this test suite. |
| 6 | config.name = 'Clang' |
| 7 | |
| 8 | # testFormat: The test format to use to interpret tests. |
| 9 | # |
| 10 | # For now we require '&&' between commands, until they get globally killed and |
| 11 | # the test runner updated. |
| 12 | config.test_format = lit.formats.ShTest(execute_external = True) |
| 13 | |
| 14 | # suffixes: A list of file extensions to treat as test files. |
| 15 | config.suffixes = ['.c', '.cpp', '.m', '.mm'] |
| 16 | |
| 17 | # target_triple: Used by ShTest and TclTest formats for XFAIL checks. |
| 18 | config.target_triple = 'foo' |
| 19 | |
| 20 | ### |
| 21 | |
| 22 | # Discover the 'clang' and 'clangcc' to use. |
| 23 | |
| 24 | import os |
| 25 | |
| 26 | def inferClang(PATH): |
| 27 | # Determine which clang to use. |
| 28 | clang = os.getenv('CLANG') |
| 29 | |
| 30 | # If the user set clang in the environment, definitely use that and don't |
| 31 | # try to validate. |
| 32 | if clang: |
| 33 | return clang |
| 34 | |
| 35 | # Otherwise look in the path. |
| 36 | clang = lit.util.which('clang', PATH) |
| 37 | |
| 38 | if not clang: |
| 39 | lit.fatal("couldn't find 'clang' program, try setting " |
| 40 | "CLANG in your environment") |
| 41 | |
| 42 | return clang |
| 43 | |
| 44 | def inferClangCC(clang, PATH): |
| 45 | clangcc = os.getenv('CLANGCC') |
| 46 | |
| 47 | # If the user set clang in the environment, definitely use that and don't |
| 48 | # try to validate. |
| 49 | if clangcc: |
| 50 | return clangcc |
| 51 | |
| 52 | # Otherwise try adding -cc since we expect to be looking in a build |
| 53 | # directory. |
| 54 | if clang.endswith('.exe'): |
| 55 | clangccName = clang[:-4] + '-cc.exe' |
| 56 | else: |
| 57 | clangccName = clang + '-cc' |
| 58 | clangcc = lit.util.which(clangccName, PATH) |
| 59 | if not clangcc: |
| 60 | # Otherwise ask clang. |
| 61 | res = lit.util.capture([clang, '-print-prog-name=clang-cc']) |
| 62 | res = res.strip() |
| 63 | if res and os.path.exists(res): |
| 64 | clangcc = res |
| 65 | |
| 66 | if not clangcc: |
| 67 | lit.fatal("couldn't find 'clang-cc' program, try setting " |
| 68 | "CLANGCC in your environment") |
| 69 | |
| 70 | return clangcc |
| 71 | |
| 72 | clang = inferClang(config.environment['PATH']) |
| 73 | if not lit.quiet: |
| 74 | lit.note('using clang: %r' % clang) |
| 75 | config.substitutions.append( (' clang ', ' ' + clang + ' ') ) |
| 76 | |
| 77 | clang_cc = inferClangCC(clang, config.environment['PATH']) |
| 78 | if not lit.quiet: |
| 79 | lit.note('using clang-cc: %r' % clang_cc) |
| 80 | config.substitutions.append( (' clang-cc ', ' ' + clang_cc + ' ') ) |