(tool: str, llvm_version: str, *, echo: bool = False)
| 81 | |
| 82 | @_async_cache |
| 83 | async def _find_tool(tool: str, llvm_version: str, *, echo: bool = False) -> str | None: |
| 84 | # Unversioned executables: |
| 85 | path = tool |
| 86 | if await _check_tool_version(path, llvm_version, echo=echo): |
| 87 | return path |
| 88 | # Versioned executables: |
| 89 | path = f"{tool}-{llvm_version}" |
| 90 | if await _check_tool_version(path, llvm_version, echo=echo): |
| 91 | return path |
| 92 | # PCbuild externals: |
| 93 | externals = os.environ.get("EXTERNALS_DIR", _targets.EXTERNALS) |
| 94 | path = os.path.join(externals, _EXTERNALS_LLVM_TAG, "bin", tool) |
| 95 | # On Windows, executables need .exe extension |
| 96 | if os.name == "nt" and not path.endswith(".exe"): |
| 97 | path_with_exe = path + ".exe" |
| 98 | if os.path.exists(path_with_exe): |
| 99 | path = path_with_exe |
| 100 | if await _check_tool_version(path, llvm_version, echo=echo): |
| 101 | return path |
| 102 | # Homebrew-installed executables: |
| 103 | prefix = await _get_brew_llvm_prefix(llvm_version, echo=echo) |
| 104 | if prefix is not None: |
| 105 | path = os.path.join(prefix, "bin", tool) |
| 106 | if await _check_tool_version(path, llvm_version, echo=echo): |
| 107 | return path |
| 108 | # Nothing found: |
| 109 | return None |
| 110 | |
| 111 | |
| 112 | async def maybe_run( |
no test coverage detected
searching dependent graphs…