1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495openStdunetypemetadata=Sexp.tlistmoduleFile=structtypet={in_the_cache:Path.t;in_the_build_directory:Path.Build.t;digest:Digest.t}endtypepromotion=|Already_promotedofFile.t|PromotedofFile.ttyperepository={directory:string;remote:string;commit:string}typecommand=DedupofFile.tmoduleDuplication_mode=structtypet=|Copy|Hardlinkletall=[("copy",Copy);("hardlink",Hardlink)]letof_stringrepr=matchList.assocallreprwith|Somemode->Result.Okmode|None->Result.Error(Format.sprintf"invalid duplication mode: %s"repr)letto_string=function|Copy->"copy"|Hardlink->"hardlink"endmoduletypeCache=sigtypet(** Set the absolute path to the build directory for interpreting relative
paths when promoting files. *)valset_build_dir:t->Path.t->t(** Set all the version controlled repositories in the workspace to be
referred to when promoting files. *)valwith_repositories:t->repositorylist->t(** Promote files produced by a build rule into the cache. *)valpromote:t->(Path.Build.t*Digest.t)list->Key.t->metadata->repository:intoption->duplication:Duplication_mode.toption->(unit,string)Result.t(** Find a build rule in the cache by its key. *)valsearch:t->Key.t->(metadata*File.tlist,string)Result.t(** Materialise a cached file in the build directory (using [Copy] or
[Hardlink] as per the duplication mode) and return the path to it. *)valretrieve:t->File.t->Path.t(** Deduplicate a file, i.e. replace the file [in_the_build_directory] with a
hardlink to the one [in_the_cache] if the deduplication mode is set to
[Hardlink] (or do nothing if the mode is [Copy]). *)valdeduplicate:t->File.t->unit(** Remove the local cache and disconnect with a distributed cache client if
any. *)valteardown:t->unitendmoduletypeCaching=sigmoduleCache:Cachevalcache:Cache.tendtypecaching=(moduleCaching)letcommand_to_dyn=function|Dedup{in_the_build_directory;in_the_cache;digest}->letopenDyn.Encoderinrecord[("in_the_build_directory",Path.Build.to_dynin_the_build_directory);("in_the_cache",Path.to_dynin_the_cache);("digest",Digest.to_dyndigest)]