Skip to content

Commit a872036

Browse files
authored
refactor: [bin_artifacts] to [artifacts] (#8742)
Signed-off-by: Rudi Grinberg <[email protected]>
1 parent 597e6b9 commit a872036

File tree

5 files changed

+38
-45
lines changed

5 files changed

+38
-45
lines changed

src/dune_rules/env_node.ml

+6-6
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ type t =
1919
; foreign_flags : string list Action_builder.t Foreign_language.Dict.t
2020
; link_flags : Link_flags.t Memo.Lazy.t
2121
; external_env : Env.t Memo.Lazy.t
22-
; bin_artifacts : Artifacts.t Memo.Lazy.t
22+
; artifacts : Artifacts.t Memo.Lazy.t
2323
; inline_tests : Dune_env.Stanza.Inline_tests.t Memo.Lazy.t
2424
; menhir_flags : string list Action_builder.t Memo.Lazy.t
2525
; odoc : Odoc.t Memo.Lazy.t
@@ -35,7 +35,7 @@ let ocaml_flags t = Memo.Lazy.force t.ocaml_flags
3535
let foreign_flags t = t.foreign_flags
3636
let link_flags t = Memo.Lazy.force t.link_flags
3737
let external_env t = Memo.Lazy.force t.external_env
38-
let bin_artifacts t = Memo.Lazy.force t.bin_artifacts
38+
let artifacts t = Memo.Lazy.force t.artifacts
3939
let inline_tests t = Memo.Lazy.force t.inline_tests
4040
let js_of_ocaml t = Memo.Lazy.force t.js_of_ocaml
4141
let menhir_flags t = Memo.Lazy.force t.menhir_flags |> Action_builder.of_memo_join
@@ -69,7 +69,7 @@ let make
6969
~expander_for_artifacts
7070
~default_context_flags
7171
~default_env
72-
~default_bin_artifacts
72+
~default_artifacts
7373
~default_bin_annot
7474
=
7575
let open Memo.O in
@@ -113,8 +113,8 @@ let make
113113
in
114114
Memo.return env)
115115
in
116-
let bin_artifacts =
117-
inherited ~field:bin_artifacts ~root:default_bin_artifacts (fun binaries ->
116+
let artifacts =
117+
inherited ~field:artifacts ~root:default_artifacts (fun binaries ->
118118
let+ local_binaries = Memo.Lazy.force local_binaries in
119119
Artifacts.add_binaries binaries ~dir local_binaries)
120120
in
@@ -234,7 +234,7 @@ let make
234234
; foreign_flags
235235
; link_flags
236236
; external_env
237-
; bin_artifacts
237+
; artifacts
238238
; local_binaries
239239
; inline_tests
240240
; js_of_ocaml

src/dune_rules/env_node.mli

+2-2
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ val make
2727
-> expander_for_artifacts:Expander.t Memo.Lazy.t
2828
-> default_context_flags:string list Action_builder.t Foreign_language.Dict.t
2929
-> default_env:Env.t
30-
-> default_bin_artifacts:Artifacts.t
30+
-> default_artifacts:Artifacts.t
3131
-> default_bin_annot:bool
3232
-> t
3333

@@ -39,7 +39,7 @@ val js_of_ocaml : t -> string list Action_builder.t Js_of_ocaml.Env.t Memo.t
3939
val foreign_flags : t -> string list Action_builder.t Foreign_language.Dict.t
4040
val link_flags : t -> Link_flags.t Memo.t
4141
val local_binaries : t -> File_binding.Expanded.t list Memo.t
42-
val bin_artifacts : t -> Artifacts.t Memo.t
42+
val artifacts : t -> Artifacts.t Memo.t
4343
val odoc : t -> Odoc.t Memo.t
4444
val coq : t -> Coq.t Action_builder.t Memo.t
4545
val menhir_flags : t -> string list Action_builder.t

src/dune_rules/expander.ml

+8-8
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ type t =
5050
; local_env : string Action_builder.t Env.Var.Map.t
5151
; lib_artifacts : Lib.DB.t
5252
; lib_artifacts_host : Lib.DB.t
53-
; bin_artifacts_host : Artifacts.t
53+
; artifacts_host : Artifacts.t
5454
; bindings : value Pform.Map.t
5555
; scope : Scope.t
5656
; scope_host : Scope.t
@@ -63,7 +63,7 @@ type t =
6363
}
6464

6565
let scope t = t.scope
66-
let artifacts t = t.bin_artifacts_host
66+
let artifacts t = t.artifacts_host
6767
let dir t = t.dir
6868
let context t = t.context
6969
let set_foreign_flags t ~f:foreign_flags = { t with foreign_flags }
@@ -74,7 +74,7 @@ let set_local_env_var t ~var ~value =
7474

7575
let set_dir t ~dir = { t with dir }
7676
let set_scope t ~scope ~scope_host = { t with scope; scope_host }
77-
let set_bin_artifacts t ~bin_artifacts_host = { t with bin_artifacts_host }
77+
let set_artifacts t ~artifacts_host = { t with artifacts_host }
7878
let set_lookup_ml_sources t ~f = { t with lookup_artifacts = Some f }
7979
let set_expanding_what t x = { t with expanding_what = x }
8080

@@ -570,7 +570,7 @@ let expand_pform_macro
570570
Action_builder.of_memo
571571
(Artifacts.binary
572572
~loc:(Some (Dune_lang.Template.Pform.loc source))
573-
t.bin_artifacts_host
573+
t.artifacts_host
574574
s)
575575
in
576576
dep (Action.Prog.ok_exn prog)))
@@ -596,7 +596,7 @@ let expand_pform_macro
596596
(fun t ->
597597
Without
598598
(let open Memo.O in
599-
let+ b = Artifacts.binary_available t.bin_artifacts_host s in
599+
let+ b = Artifacts.binary_available t.artifacts_host s in
600600
b |> string_of_bool |> string))
601601
| Read -> expand_read_macro ~dir ~source s ~read:Io.read_file ~pack:string
602602
| Read_lines -> expand_read_macro ~dir ~source s ~read:Io.lines_of_file ~pack:strings
@@ -617,7 +617,7 @@ let expand_pform_macro
617617
(fun t ->
618618
Without
619619
(let open Memo.O in
620-
let* coqc = Artifacts.binary t.bin_artifacts_host ~loc:None "coqc" in
620+
let* coqc = Artifacts.binary t.artifacts_host ~loc:None "coqc" in
621621
let+ t = Coq_config.make ~coqc in
622622
match Coq_config.by_name t s with
623623
| None ->
@@ -725,7 +725,7 @@ let make_root
725725
~env
726726
~lib_artifacts
727727
~lib_artifacts_host
728-
~bin_artifacts_host
728+
~artifacts_host
729729
=
730730
{ dir = Context.build_dir context
731731
; env
@@ -735,7 +735,7 @@ let make_root
735735
; scope_host
736736
; lib_artifacts
737737
; lib_artifacts_host
738-
; bin_artifacts_host
738+
; artifacts_host
739739
; c_compiler = Ocaml_config.c_compiler (Context.ocaml context).ocaml_config
740740
; context
741741
; lookup_artifacts = None

src/dune_rules/expander.mli

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ val make_root
1515
-> env:Env.t
1616
-> lib_artifacts:Lib.DB.t
1717
-> lib_artifacts_host:Lib.DB.t
18-
-> bin_artifacts_host:Artifacts.t
18+
-> artifacts_host:Artifacts.t
1919
-> t
2020

2121
val set_foreign_flags
@@ -26,7 +26,7 @@ val set_foreign_flags
2626
val set_local_env_var : t -> var:string -> value:string Action_builder.t -> t
2727
val set_dir : t -> dir:Path.Build.t -> t
2828
val set_scope : t -> scope:Scope.t -> scope_host:Scope.t -> t
29-
val set_bin_artifacts : t -> bin_artifacts_host:Artifacts.t -> t
29+
val set_artifacts : t -> artifacts_host:Artifacts.t -> t
3030

3131
val set_lookup_ml_sources
3232
: t

src/dune_rules/super_context.ml

+20-27
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ let default_context_flags (ctx : Build_context.t) ocaml_config ~project =
2929
module Env_tree : sig
3030
type t
3131

32-
val force_bin_artifacts : t -> unit Memo.t
32+
val force_artifacts : t -> unit Memo.t
3333
val context : t -> Context.t
3434
val get_node : t -> dir:Path.Build.t -> Env_node.t Memo.t
3535
val get_context_env : t -> Env.t
@@ -39,11 +39,11 @@ module Env_tree : sig
3939
-> host_env_tree:t option
4040
-> default_env:Env_node.t Memo.Lazy.t
4141
-> root_expander:Expander.t
42-
-> bin_artifacts:Artifacts.t
42+
-> artifacts:Artifacts.t
4343
-> context_env:Env.t
4444
-> t
4545

46-
val bin_artifacts_host : t -> dir:Path.Build.t -> Artifacts.t Memo.t
46+
val artifacts_host : t -> dir:Path.Build.t -> Artifacts.t Memo.t
4747
val expander : t -> dir:Path.Build.t -> Expander.t Memo.t
4848
end = struct
4949
open Memo.O
@@ -54,25 +54,25 @@ end = struct
5454
; default_env : Env_node.t Memo.Lazy.t
5555
; host : t option
5656
; root_expander : Expander.t
57-
; bin_artifacts : Artifacts.t
57+
; artifacts : Artifacts.t
5858
; get_node : Path.Build.t -> Env_node.t Memo.t
5959
}
6060

61-
let force_bin_artifacts { bin_artifacts; _ } = Artifacts.force bin_artifacts
61+
let force_artifacts { artifacts; _ } = Artifacts.force artifacts
6262
let context t = t.context
6363
let get_node t ~dir = t.get_node dir
6464
let get_context_env t = t.context_env
6565

66-
let bin_artifacts_host t ~dir =
67-
let bin_artifacts t ~dir = get_node t ~dir >>= Env_node.bin_artifacts in
66+
let artifacts_host t ~dir =
67+
let artifacts t ~dir = get_node t ~dir >>= Env_node.artifacts in
6868
match t.host with
69-
| None -> bin_artifacts t ~dir
69+
| None -> artifacts t ~dir
7070
| Some host ->
7171
let dir =
7272
Path.Build.drop_build_context_exn dir
7373
|> Path.Build.append_source (Context.build_dir host.context)
7474
in
75-
bin_artifacts host ~dir
75+
artifacts host ~dir
7676
;;
7777

7878
let external_env t ~dir = get_node t ~dir >>= Env_node.external_env
@@ -97,14 +97,14 @@ end = struct
9797
;;
9898

9999
let extend_expander t ~dir ~expander_for_artifacts =
100-
let+ bin_artifacts_host = bin_artifacts_host t ~dir
100+
let+ artifacts_host = artifacts_host t ~dir
101101
and+ bindings =
102102
let+ inline_tests = get_node t ~dir >>= Env_node.inline_tests in
103103
let str = Dune_env.Stanza.Inline_tests.to_string inline_tests in
104104
Pform.Map.singleton (Var Inline_tests) [ Value.String str ]
105105
in
106106
Expander.add_bindings ~bindings expander_for_artifacts
107-
|> Expander.set_bin_artifacts ~bin_artifacts_host
107+
|> Expander.set_artifacts ~artifacts_host
108108
;;
109109

110110
let expander t ~dir =
@@ -177,7 +177,7 @@ end = struct
177177
~expander_for_artifacts
178178
~default_context_flags
179179
~default_env:t.context_env
180-
~default_bin_artifacts:t.bin_artifacts
180+
~default_artifacts:t.artifacts
181181
~default_bin_annot:true
182182
;;
183183

@@ -192,14 +192,7 @@ end = struct
192192
binding. To work around this limitation, we place the functions into a
193193
recursive module [Rec]. Since recursive let-modules are not allowed either,
194194
we need to also wrap [Rec] inside a non-recursive module [Non_rec]. *)
195-
let create
196-
~context
197-
~host_env_tree
198-
~default_env
199-
~root_expander
200-
~bin_artifacts
201-
~context_env
202-
=
195+
let create ~context ~host_env_tree ~default_env ~root_expander ~artifacts ~context_env =
203196
let module Non_rec = struct
204197
module rec Rec : sig
205198
val env_tree : unit -> t
@@ -211,7 +204,7 @@ end = struct
211204
; default_env
212205
; host = host_env_tree
213206
; root_expander
214-
; bin_artifacts
207+
; artifacts
215208
; get_node = Rec.memo
216209
}
217210
;;
@@ -330,8 +323,8 @@ let dump_env t ~dir =
330323
;;
331324

332325
let resolve_program t ~dir ?hint ~loc bin =
333-
let* bin_artifacts = Env_tree.bin_artifacts_host t ~dir in
334-
Artifacts.binary ?hint ~loc bin_artifacts bin
326+
let* artifacts = Env_tree.artifacts_host t ~dir in
327+
Artifacts.binary ?hint ~loc artifacts bin
335328
;;
336329

337330
let add_packages_env context ~base stanzas packages =
@@ -437,7 +430,7 @@ let make_default_env_node
437430
~expander_for_artifacts
438431
~default_context_flags
439432
~default_env:root_env
440-
~default_bin_artifacts:artifacts
433+
~default_artifacts:artifacts
441434
~default_bin_annot:true
442435
in
443436
make
@@ -510,7 +503,7 @@ let create ~(context : Context.t) ~(host : t option) ~packages ~stanzas =
510503
~context
511504
~env:expander_env
512505
~lib_artifacts:public_libs
513-
~bin_artifacts_host:artifacts_host
506+
~artifacts_host
514507
~lib_artifacts_host:public_libs_host
515508
and+ artifacts = artifacts
516509
and+ root_env =
@@ -535,7 +528,7 @@ let create ~(context : Context.t) ~(host : t option) ~packages ~stanzas =
535528
~default_env
536529
~host_env_tree:host
537530
~root_expander
538-
~bin_artifacts:artifacts
531+
~artifacts
539532
~context_env:root_env
540533
;;
541534

@@ -580,7 +573,7 @@ let find name =
580573

581574
let all_init_deferred () =
582575
let* all = Memo.Lazy.force all in
583-
Context_name.Map.values all |> Memo.parallel_iter ~f:Env_tree.force_bin_artifacts
576+
Context_name.Map.values all |> Memo.parallel_iter ~f:Env_tree.force_artifacts
584577
;;
585578

586579
module As_memo_key = struct

0 commit comments

Comments
 (0)