mirror of
https://github.com/revng/revng
synced 2026-06-21 14:07:57 +00:00
bfed42ed1e
Add the `get_llvmcpy` helper function which returns an instance of `LLVMCPy` which uses the `llvm-config` that's present in the search paths.
28 lines
607 B
Python
28 lines
607 B
Python
#
|
|
# This file is distributed under the MIT License. See LICENSE.md for details.
|
|
#
|
|
|
|
import os
|
|
from collections.abc import Iterable as CIterable
|
|
from pathlib import Path
|
|
from typing import Iterable, TypeVar
|
|
|
|
from xdg import xdg_cache_home
|
|
|
|
from revng.support import SingleOrIterable
|
|
|
|
T = TypeVar("T")
|
|
|
|
|
|
def to_iterable(obj: SingleOrIterable[T]) -> Iterable[T]:
|
|
if isinstance(obj, CIterable):
|
|
return obj
|
|
return (obj,)
|
|
|
|
|
|
def cache_directory() -> Path:
|
|
if "REVNG_CACHE_DIR" in os.environ:
|
|
return Path(os.environ["REVNG_CACHE_DIR"])
|
|
else:
|
|
return xdg_cache_home() / "revng"
|