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