1 | # -*- Python -*- |
2 | |
3 | from lit import Test |
4 | import lit.formats |
5 | import lit.util |
6 | import os |
7 | import subprocess |
8 | |
9 | def getSysrootFlagsOnDarwin(config, lit_config): |
10 | # On Darwin, support relocatable SDKs by providing Clang with a |
11 | # default system root path. |
12 | if 'darwin' in config.target_triple: |
13 | try: |
14 | out = subprocess.check_output(['xcrun', '--show-sdk-path']).strip() |
15 | res = 0 |
16 | except OSError: |
17 | res = -1 |
18 | if res == 0 and out: |
19 | sdk_path = out |
20 | lit_config.note('using SDKROOT: %r' % sdk_path) |
21 | return '-isysroot %s' % sdk_path |
22 | return '' |
23 | |
24 | sysroot_flags = getSysrootFlagsOnDarwin(config, lit_config) |
25 | |
26 | config.clang = os.path.realpath(lit.util.which('clang', config.clang_tools_dir)).replace('\\', '/') |
27 | |
28 | config.name = 'Clang Perf Training' |
29 | config.suffixes = ['.c', '.cpp', '.m', '.mm', '.cu', '.ll', '.cl', '.s', '.S', '.modulemap'] |
30 | |
31 | dtrace_wrapper = '%s %s/perf-helper.py dtrace' % (config.python_exe, config.test_source_root) |
32 | dtrace_wrapper_cc1 = '%s %s/perf-helper.py dtrace --cc1' % (config.python_exe, config.test_source_root) |
33 | |
34 | if 'darwin' in config.target_triple: |
35 | lit_config.note('using DTrace oneshot probe') |
36 | dtrace_wrapper = '%s --use-oneshot' % dtrace_wrapper |
37 | dtrace_wrapper_cc1 = '%s --use-oneshot' % dtrace_wrapper_cc1 |
38 | |
39 | use_lit_shell = os.environ.get("LIT_USE_INTERNAL_SHELL") |
40 | config.test_format = lit.formats.ShTest(use_lit_shell == "0") |
41 | config.substitutions.append( ('%clang_cpp_skip_driver', ' %s %s --driver-mode=g++ %s ' % (dtrace_wrapper_cc1, config.clang, sysroot_flags))) |
42 | config.substitutions.append( ('%clang_cpp', ' %s %s --driver-mode=g++ %s ' % (dtrace_wrapper, config.clang, sysroot_flags))) |
43 | config.substitutions.append( ('%clang_skip_driver', ' %s %s %s ' % (dtrace_wrapper_cc1, config.clang, sysroot_flags))) |
44 | config.substitutions.append( ('%clang', ' %s %s %s ' % (dtrace_wrapper, config.clang, sysroot_flags) ) ) |
45 | config.substitutions.append( ('%test_root', config.test_exec_root ) ) |
46 | |
47 | |