123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100openStdunetypemetadata=Sexp.tlist(** A file stored in Dune cache is fully determined by the build [path] and its
content [digest]. There may be multiple [File]s with the same [digest] due
to sharing between multiple workspaces. In fact, the more such pairs there
are, the more effective the cache is. *)moduleFile=structtypet={path: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,string)Result.t(** Set all the version controlled repositories in the workspace to be
referred to when promoting files. *)valwith_repositories:t->repositorylist->(t,string)Result.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->unit(* Hint that the given rule will be looked up soon *)valhint:t->Key.tlist->(unit,string)Result.tendmoduletypeCaching=sigmoduleCache:Cachevalcache:Cache.tendtypecaching=(moduleCaching)letcommand_to_dyn=function|Dedup{path;digest}->letopenDyn.Encoderinpairstringrecord@@("dedup",[("path",Path.Build.to_dynpath);("digest",Digest.to_dyndigest)])