|
11 | 11 | import lit.util
|
12 | 12 |
|
13 | 13 | from lit.llvm import llvm_config
|
| 14 | +from lit.llvm.subst import ToolSubst, FindTool |
14 | 15 |
|
15 | 16 | # Configuration file for the 'lit' test runner.
|
16 | 17 |
|
|
34 | 35 | # test_exec_root: The root path where tests should be run.
|
35 | 36 | config.test_exec_root = config.sycl_obj_root
|
36 | 37 |
|
| 38 | +# allow expanding substitutions that are based on other substitutions |
| 39 | +config.recursiveExpansionLimit = 10 |
| 40 | + |
37 | 41 | # Cleanup environment variables which may affect tests
|
38 | 42 | possibly_dangerous_env_vars = ['COMPILER_PATH', 'RC_DEBUG_OPTIONS',
|
39 | 43 | 'CINDEXTEST_PREAMBLE_FILE', 'LIBRARY_PATH',
|
|
390 | 394 |
|
391 | 395 | if config.run_launcher:
|
392 | 396 | config.substitutions.append(('%e2e_tests_root', config.test_source_root))
|
393 |
| - config.recursiveExpansionLimit = 10 |
394 | 397 |
|
395 | 398 | if config.sycl_be == 'ext_oneapi_cuda' or (config.sycl_be == 'ext_oneapi_hip' and config.hip_platform == 'NVIDIA'):
|
396 | 399 | config.substitutions.append( ('%sycl_triple', "nvptx64-nvidia-cuda" ) )
|
|
399 | 402 | else:
|
400 | 403 | config.substitutions.append( ('%sycl_triple', "spir64" ) )
|
401 | 404 |
|
402 |
| -if find_executable('sycl-ls'): |
403 |
| - config.available_features.add('sycl-ls') |
404 |
| - |
405 | 405 | # TODO properly set XPTIFW include and runtime dirs
|
406 | 406 | xptifw_lib_dir = os.path.join(config.dpcpp_root_dir, 'lib')
|
407 | 407 | xptifw_dispatcher = ""
|
|
418 | 418 | else:
|
419 | 419 | config.substitutions.append(('%xptifw_lib', " -L{} -lxptifw -I{} ".format(xptifw_lib_dir, xptifw_includes)))
|
420 | 420 |
|
421 |
| - |
422 |
| -llvm_tools = ["llvm-spirv", "llvm-link"] |
423 |
| -for llvm_tool in llvm_tools: |
424 |
| - llvm_tool_path = find_executable(llvm_tool) |
425 |
| - if llvm_tool_path: |
426 |
| - lit_config.note("Found " + llvm_tool) |
427 |
| - config.available_features.add(llvm_tool) |
428 |
| - config.substitutions.append( ('%' + llvm_tool.replace('-', '_'), |
429 |
| - os.path.realpath(llvm_tool_path)) ) |
430 |
| - else: |
431 |
| - lit_config.warning("Can't find " + llvm_tool) |
| 421 | +# Tools for which we add a corresponding feature when available. |
| 422 | +feature_tools = [ |
| 423 | + ToolSubst('llvm-spirv', unresolved='ignore'), |
| 424 | + ToolSubst('llvm-link', unresolved='ignore'), |
| 425 | +] |
| 426 | + |
| 427 | +tools = [ |
| 428 | + ToolSubst('FileCheck', unresolved='ignore'), |
| 429 | + # not is only substituted in certain circumstances; this is lit's default |
| 430 | + # behaviour. |
| 431 | + ToolSubst(r'\| \bnot\b', command=FindTool('not'), |
| 432 | + verbatim=True, unresolved='ignore'), |
| 433 | + ToolSubst('sycl-ls', unresolved='ignore'), |
| 434 | +] + feature_tools |
| 435 | + |
| 436 | +# Try and find each of these tools in the llvm tools directory or the PATH, in |
| 437 | +# that order. If found, they will be added as substitutions with the full path |
| 438 | +# to the tool. This allows us to support both in-tree builds and standalone |
| 439 | +# builds, where the tools may be externally defined. |
| 440 | +llvm_config.add_tool_substitutions(tools, [config.llvm_tools_dir, |
| 441 | + os.environ.get('PATH', '')]) |
| 442 | +for tool in feature_tools: |
| 443 | + if tool.was_resolved: |
| 444 | + config.available_features.add(tool.key) |
| 445 | + else: |
| 446 | + lit_config.warning("Can't find " + tool.key) |
432 | 447 |
|
433 | 448 | if find_executable('cmc'):
|
434 | 449 | config.available_features.add('cm-compiler')
|
|
0 commit comments