|
15 | 15 |
|
16 | 16 | from __future__ import annotations |
17 | 17 |
|
| 18 | +import sys |
18 | 19 | from pathlib import Path |
19 | 20 |
|
20 | 21 | import lit.formats |
|
38 | 39 | # Define where to execute tests (and produce the output). |
39 | 40 | config.test_exec_root = Path(config.mqt_core_mlir_test_dir) |
40 | 41 |
|
41 | | -multi_config_path = Path(config.mqt_core_mlir_tools_dir) / config.cmake_build_type |
42 | | -tool_dirs = [config.llvm_tools_dir, config.mqt_core_mlir_tools_dir, str(multi_config_path)] |
43 | | -tools = ["not", "FileCheck", "quantum-opt"] |
44 | | -llvm_config.add_tool_substitutions(tools, tool_dirs) |
| 42 | +# Add substitutions for the required tools. |
| 43 | +found = llvm_config.add_tool_substitutions(tools=["not", "FileCheck", "split-file"]) |
| 44 | +if not found: |
| 45 | + msg = "Could not find required LLVM tools 'not' and 'FileCheck'." |
| 46 | + raise RuntimeError(msg) |
| 47 | + |
| 48 | +# Successively check directories whether they contain the quantum-opt tool |
| 49 | +tool_name = "quantum-opt" if sys.platform != "win32" else "quantum-opt.exe" |
| 50 | +base_tool_dir = Path(config.mqt_core_mlir_tools_dir) |
| 51 | + |
| 52 | +candidate_dirs = [base_tool_dir] |
| 53 | +if config.cmake_build_type: |
| 54 | + candidate_dirs.append(base_tool_dir / config.cmake_build_type) |
| 55 | +candidate_dirs.extend(base_tool_dir / cfg for cfg in ["Debug", "Release", "RelWithDebInfo", "MinSizeRel"]) |
| 56 | + |
| 57 | +found = False |
| 58 | +for candidate_dir in candidate_dirs: |
| 59 | + if (candidate_dir / tool_name).exists(): |
| 60 | + success = llvm_config.add_tool_substitutions(["quantum-opt"], [str(candidate_dir)]) |
| 61 | + found = True |
| 62 | + break |
| 63 | + |
| 64 | +if not found: |
| 65 | + msg = f"Could not find {tool_name} anywhere under {base_tool_dir}." |
| 66 | + raise RuntimeError(msg) |
0 commit comments