1import os 2 3import lit.formats 4import lit.util 5 6# python 2.7 backwards compatibility 7try: 8 from shlex import quote as shell_quote 9except ImportError: 10 from pipes import quote as shell_quote 11 12 13def add_update_script_substition(name, python_exe=config.python_executable, 14 extra_args=''): 15 assert name.startswith('%') 16 script_path = os.path.join(config.llvm_src_root, 'utils', name[1:] + '.py') 17 assert os.path.isfile(script_path) 18 config.substitutions.append( 19 (name, "'%s' %s %s" % (python_exe, script_path, extra_args))) 20 21 22config.test_format = lit.formats.ShTest(execute_external=False) 23config.suffixes = ['.test'] 24 25llc_path = os.path.join(config.llvm_tools_dir, 'llc') 26if os.path.isfile(llc_path): 27 config.available_features.add('llc-binary') 28 llc_arg = '--llc-binary ' + shell_quote(llc_path) 29 add_update_script_substition('%update_llc_test_checks', extra_args=llc_arg) 30 add_update_script_substition('%update_mir_test_checks', extra_args=llc_arg) 31 32opt_path = os.path.join(config.llvm_tools_dir, 'opt') 33if os.path.isfile(opt_path): 34 config.available_features.add('opt-binary') 35 opt_arg = '--opt-binary ' + shell_quote(opt_path) 36 add_update_script_substition('%update_test_checks', extra_args=opt_arg) 37 add_update_script_substition('%update_analyze_test_checks', 38 extra_args=opt_arg) 39 40llvm_mca_path = os.path.join(config.llvm_tools_dir, 'llvm-mca') 41if os.path.isfile(llvm_mca_path): 42 config.available_features.add('llvm-mca-binary') 43 mca_arg = '--llvm-mca-binary ' + shell_quote(llvm_mca_path) 44 add_update_script_substition('%update_test_checks', extra_args=mca_arg) 45