Skip to content

Commit 5e23b37

Browse files
authored
refactor: remove [Artifacts.Local.t] (#8743)
Signed-off-by: Rudi Grinberg <[email protected]>
1 parent a872036 commit 5e23b37

File tree

3 files changed

+18
-25
lines changed

3 files changed

+18
-25
lines changed

src/dune_rules/artifacts.ml

+17-16
Original file line numberDiff line numberDiff line change
@@ -60,19 +60,20 @@ let add_binaries t ~dir l =
6060
{ t with local_bins }
6161
;;
6262

63-
module Local = struct
64-
type t = Path.Build.t Filename.Map.t
65-
66-
let create =
67-
Path.Build.Set.fold ~init:Filename.Map.empty ~f:(fun path acc ->
68-
let name = Path.Build.basename path in
69-
let key =
70-
if Sys.win32
71-
then Option.value ~default:name (String.drop_suffix name ~suffix:".exe")
72-
else name
73-
in
74-
Filename.Map.set acc key path)
75-
;;
76-
end
77-
78-
let create (context : Context.t) ~local_bins = { context; local_bins }
63+
let create =
64+
let drop_suffix name =
65+
if Sys.win32
66+
then Option.value ~default:name (String.drop_suffix name ~suffix:".exe")
67+
else name
68+
in
69+
fun (context : Context.t) ~local_bins ->
70+
let local_bins =
71+
Memo.lazy_ (fun () ->
72+
let+ local_bins = Memo.Lazy.force local_bins in
73+
Path.Build.Set.fold local_bins ~init:Filename.Map.empty ~f:(fun path acc ->
74+
let name = Path.Build.basename path in
75+
let key = drop_suffix name in
76+
Filename.Map.set acc key path))
77+
in
78+
{ context; local_bins }
79+
;;

src/dune_rules/artifacts.mli

+1-8
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,5 @@ val local_bin : Path.Build.t -> Path.Build.t
1818
val binary : t -> ?hint:string -> loc:Loc.t option -> string -> Action.Prog.t Memo.t
1919

2020
val binary_available : t -> string -> bool Memo.t
21-
22-
module Local : sig
23-
type t
24-
25-
val create : Path.Build.Set.t -> t
26-
end
27-
2821
val add_binaries : t -> dir:Path.Build.t -> File_binding.Expanded.t list -> t
29-
val create : Context.t -> local_bins:Local.t Memo.Lazy.t -> t
22+
val create : Context.t -> local_bins:Path.Build.Set.t Memo.Lazy.t -> t

src/dune_rules/artifacts_db.ml

-1
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,6 @@ let get_installed_binaries ~(context : Context.t) stanzas =
8888
| _ -> Memo.return Path.Build.Set.empty)
8989
>>| Path.Build.Set.union_all)
9090
>>| Path.Build.Set.union_all
91-
>>| Artifacts.Local.create
9291
;;
9392

9493
let all =

0 commit comments

Comments
 (0)