elasticai.creator.hw_function_id#
Module Contents#
Classes#
Hash all files in |
API#
- class elasticai.creator.hw_function_id.HwFunctionIdUpdater(build_dir: pathlib.Path, target_file: str | pathlib.Path, replace_id_fn: collections.abc.Callable[[collections.abc.Iterable[str], bytes], collections.abc.Iterator[str]], file_filter: collections.abc.Callable[[pathlib.Path], bool] = lambda f: ...)[source]#
Hash all files in
build_direxcept fortarget_fileand usesreplace_id_fnto write the result totarget_file.The id will stay the same, if none of the files, except for the target file changed.
You can use the optional
file_filterto exclude additional files from the id computation. Example:generate_my_source_files(build_dir) def replace_id(code: Iterable[str], id: bytes) -> Iterator[str]: for line in code: if line == "my_id_placeholder": yield f"my_id = {id.hex()};" else: yield line def filter_non_vhd(file): return str(file).endswith(".vhd") id_updater = HwFunctionIdUpdate(build_dir, "id_package.vhd", replace_id, filter_non_vhd) id_update.compute_id() id_updater.write_id() print(id_updater.id)
Initialization
- property id: bytes#