Files
revng-revng/python/revng/support/__init__.py
Alessandro Di Federico 416c59c43b support.py: rework get_command
We introduce two paths where we can hard code search prefixes
(`/additional-search-prefixes`) and additional binaries paths
(`/share/revng/additional-bin-paths`).

This enables us to add to `additional-bin-paths` the configure-time
specified path of the preferred LLVM installation, instead of relying on
`PATH` to look up, e.g., `opt` at run-time.
2023-04-13 18:11:48 +02:00

32 lines
782 B
Python

#
# This file is distributed under the MIT License. See LICENSE.md for details.
#
from collections.abc import Iterable as CIterable
from pathlib import Path
from typing import Iterable, List, TypeVar, Union
T = TypeVar("T")
SingleOrIterable = Union[T, Iterable[T]]
AnyPath = Union[str, Path]
AnyPaths = SingleOrIterable[AnyPath]
def to_iterable(obj: SingleOrIterable[T]) -> Iterable[T]:
if isinstance(obj, CIterable):
return obj
return (obj,)
# We assume this file is in <root>/lib/python$VERSION/site-packages/revng/support
def get_root() -> Path:
return (Path(__file__) / "../../../../../../").resolve()
def read_lines(path: Path) -> List[str]:
if not path.exists():
return []
else:
return path.read_text().strip().split("\n")