2016-01-16 05:21:12 +08:00
|
|
|
# -*- Python -*-
|
|
|
|
|
|
|
|
from lit import Test
|
|
|
|
import lit.formats
|
|
|
|
import lit.util
|
|
|
|
import os
|
2017-07-06 05:06:11 +08:00
|
|
|
import subprocess
|
2016-01-16 05:21:12 +08:00
|
|
|
|
|
|
|
def getSysrootFlagsOnDarwin(config, lit_config):
|
|
|
|
# On Darwin, support relocatable SDKs by providing Clang with a
|
|
|
|
# default system root path.
|
|
|
|
if 'darwin' in config.target_triple:
|
|
|
|
try:
|
2017-07-06 05:06:11 +08:00
|
|
|
out = subprocess.check_output(['xcrun', '--show-sdk-path']).strip()
|
2016-01-16 05:21:12 +08:00
|
|
|
res = 0
|
|
|
|
except OSError:
|
|
|
|
res = -1
|
|
|
|
if res == 0 and out:
|
|
|
|
sdk_path = out
|
|
|
|
lit_config.note('using SDKROOT: %r' % sdk_path)
|
|
|
|
return '-isysroot %s' % sdk_path
|
|
|
|
return ''
|
|
|
|
|
|
|
|
sysroot_flags = getSysrootFlagsOnDarwin(config, lit_config)
|
|
|
|
|
|
|
|
config.clang = os.path.realpath(lit.util.which('clang', config.clang_tools_dir)).replace('\\', '/')
|
|
|
|
|
|
|
|
config.name = 'Clang Perf Training'
|
|
|
|
config.suffixes = ['.c', '.cpp', '.m', '.mm', '.cu', '.ll', '.cl', '.s', '.S', '.modulemap']
|
|
|
|
|
|
|
|
dtrace_wrapper = '%s %s/perf-helper.py dtrace' % (config.python_exe, config.test_source_root)
|
2016-03-22 06:37:14 +08:00
|
|
|
dtrace_wrapper_cc1 = '%s %s/perf-helper.py dtrace --cc1' % (config.python_exe, config.test_source_root)
|
2016-01-16 05:21:12 +08:00
|
|
|
|
2016-08-25 06:09:46 +08:00
|
|
|
if 'darwin' in config.target_triple:
|
|
|
|
lit_config.note('using DTrace oneshot probe')
|
|
|
|
dtrace_wrapper = '%s --use-oneshot' % dtrace_wrapper
|
|
|
|
dtrace_wrapper_cc1 = '%s --use-oneshot' % dtrace_wrapper_cc1
|
|
|
|
|
2016-01-16 05:21:12 +08:00
|
|
|
use_lit_shell = os.environ.get("LIT_USE_INTERNAL_SHELL")
|
|
|
|
config.test_format = lit.formats.ShTest(use_lit_shell == "0")
|
2017-01-04 12:33:28 +08:00
|
|
|
config.substitutions.append( ('%clang_cpp_skip_driver', ' %s %s --driver-mode=g++ %s ' % (dtrace_wrapper_cc1, config.clang, sysroot_flags)))
|
|
|
|
config.substitutions.append( ('%clang_cpp', ' %s %s --driver-mode=g++ %s ' % (dtrace_wrapper, config.clang, sysroot_flags)))
|
2016-03-22 06:37:14 +08:00
|
|
|
config.substitutions.append( ('%clang_skip_driver', ' %s %s %s ' % (dtrace_wrapper_cc1, config.clang, sysroot_flags)))
|
2016-01-16 05:21:12 +08:00
|
|
|
config.substitutions.append( ('%clang', ' %s %s %s ' % (dtrace_wrapper, config.clang, sysroot_flags) ) )
|
|
|
|
config.substitutions.append( ('%test_root', config.test_exec_root ) )
|
|
|
|
|