@@ -97,16 +97,14 @@ module T = struct
97
97
; supports_shared_libraries : Dynlink_supported.By_the_os .t
98
98
; which : string -> Path .t option
99
99
; lib_config : Lib_config .t
100
+ ; build_context : Build_context .t
100
101
}
101
102
102
103
let equal x y = Context_name. equal x.name y.name
103
104
104
105
let hash t = Context_name. hash t.name
105
106
106
- let rec to_build_context
107
- { name; build_dir; env; for_host; stdlib_dir; default_ocamlpath; _ } =
108
- Build_context. create ~name ~build_dir ~env ~stdlib_dir ~default_ocamlpath
109
- ~host: (Option. map ~f: to_build_context for_host)
107
+ let build_context t = t.build_context
110
108
111
109
let to_dyn t : Dyn.t =
112
110
let open Dyn.Encoder in
@@ -419,7 +417,7 @@ let create ~(kind : Kind.t) ~path ~env ~env_nodes ~name ~merlin ~targets
419
417
| Error (Makefile_config file , msg ) ->
420
418
User_error. raise ~loc: (Loc. in_file file) [ Pp. text msg ]
421
419
in
422
- let * default_findlib_paths , (ocaml_config_vars, ocfg) =
420
+ let * default_ocamlpath , (ocaml_config_vars, ocfg) =
423
421
Fiber. fork_and_join default_findlib_paths (fun () ->
424
422
let + lines =
425
423
Process. run_capture_lines ~env Strict ocamlc [ " -config" ]
@@ -432,7 +430,7 @@ let create ~(kind : Kind.t) ~path ~env ~env_nodes ~name ~merlin ~targets
432
430
(vars, ocfg)
433
431
| Error msg -> Error (Ocamlc_config , msg) ))
434
432
in
435
- let findlib_paths = ocamlpath @ default_findlib_paths in
433
+ let findlib_paths = ocamlpath @ default_ocamlpath in
436
434
let version = Ocaml_version. of_ocaml_config ocfg in
437
435
let env =
438
436
(* See comment in ansi_color.ml for setup_env_for_colors. For versions
@@ -473,7 +471,7 @@ let create ~(kind : Kind.t) ~path ~env ~env_nodes ~name ~merlin ~targets
473
471
; ( " DUNE_OCAML_HARDCODED"
474
472
, String. concat
475
473
~sep: (Char. escaped ocamlpath_sep)
476
- (List. map ~f: Path. to_string default_findlib_paths ) )
474
+ (List. map ~f: Path. to_string default_ocamlpath ) )
477
475
; extend_var " OCAMLTOP_INCLUDE_PATH"
478
476
(Path.Build. relative local_lib_root " toplevel" )
479
477
; extend_var " OCAMLFIND_IGNORE_DUPS_IN" ~path_sep: ocamlpath_sep
@@ -545,6 +543,11 @@ let create ~(kind : Kind.t) ~path ~env ~env_nodes ~name ~merlin ~targets
545
543
supports_shared_libraries && dynamically_linked_foreign_archives
546
544
in
547
545
let t =
546
+ let build_context =
547
+ Build_context. create ~name ~build_dir ~env ~stdlib_dir
548
+ ~default_ocamlpath
549
+ ~host: (Option. map host ~f: (fun c -> c.build_context))
550
+ in
548
551
{ name
549
552
; implicit
550
553
; kind
@@ -570,7 +573,7 @@ let create ~(kind : Kind.t) ~path ~env ~env_nodes ~name ~merlin ~targets
570
573
; env
571
574
; findlib = Findlib. create ~paths: findlib_paths ~lib_config
572
575
; findlib_toolchain
573
- ; default_ocamlpath = default_findlib_paths
576
+ ; default_ocamlpath
574
577
; arch_sixtyfour
575
578
; install_prefix
576
579
; stdlib_dir
@@ -581,6 +584,7 @@ let create ~(kind : Kind.t) ~path ~env ~env_nodes ~name ~merlin ~targets
581
584
Dynlink_supported.By_the_os. of_bool supports_shared_libraries
582
585
; which
583
586
; lib_config
587
+ ; build_context
584
588
}
585
589
in
586
590
if Ocaml_version. supports_response_file version then (
0 commit comments