diff --git a/src/dune_rules/pkg_rules.ml b/src/dune_rules/pkg_rules.ml index 02c5060f2891..d5bcd1ec2f04 100644 --- a/src/dune_rules/pkg_rules.ml +++ b/src/dune_rules/pkg_rules.ml @@ -1931,14 +1931,23 @@ let ocaml_toolchain context = | `System_provided -> None | `Inside_lock_dir pkg -> let toolchain = - let cookie = (Pkg_installed.of_paths pkg.paths).cookie in let open Action_builder.O in - let* cookie = cookie in - (* TODO we should use the closure of [pkg] *) - let binaries = - Section.Map.find cookie.files Bin |> Option.value ~default:[] |> Path.Set.of_list + let transitive_deps = pkg :: Pkg.deps_closure pkg in + let* env, binaries = + Action_builder.List.fold_left + ~init:(Global.env (), Path.Set.empty) + ~f:(fun (env, binaries) pkg -> + let env = Env.extend_env env (Pkg.exported_env pkg) in + let+ cookie = (Pkg_installed.of_paths pkg.paths).cookie in + let binaries = + Section.Map.find cookie.files Bin + |> Option.value ~default:[] + |> Path.Set.of_list + |> Path.Set.union binaries + in + env, binaries) + transitive_deps in - let env = Env.extend_env (Global.env ()) (Pkg.exported_env pkg) in let path = Env_path.path (Global.env ()) in Action_builder.of_memo @@ Ocaml_toolchain.of_binaries ~path context env binaries in diff --git a/src/dune_rules/pkg_toolchain.ml b/src/dune_rules/pkg_toolchain.ml index db4bd72da1ad..0236c7780084 100644 --- a/src/dune_rules/pkg_toolchain.ml +++ b/src/dune_rules/pkg_toolchain.ml @@ -49,22 +49,14 @@ let is_compiler_and_toolchains_enabled name = (* TODO don't hardcode these names here *) [ Package_name.of_string "ocaml-base-compiler" ; Package_name.of_string "ocaml-variants" + ; Package_name.of_string + "ocaml-compiler" (* HACK: This is required for ocaml.5.3.0 *) ] in List.mem compiler_package_names name ~equal:Package_name.equal | `Disabled -> false ;; -let ocaml context env ~bin_dir = - let which prog = - let path = Path.Outside_build_dir.relative bin_dir prog in - let+ exists = Fs_memo.file_exists path in - if exists then Some (Path.outside_build_dir path) else None - in - let get_ocaml_tool ~dir:_ prog = which prog in - Ocaml_toolchain.make context ~which ~env ~get_ocaml_tool -;; - (* Returns the path to the directory containing the artifacts within the temporary install directory. When installing with the DESTDIR variable, the absolute path to the final installation directory is concatenated to the @@ -174,11 +166,20 @@ let modify_install_action ~prefix ~suffix action = (* Create an empty config.cache file so other packages see that the compiler package is installed. *) let touch_config_cache = - Dune_lang.Action.Run - [ Slang.text "touch" - ; Slang.concat - [ Slang.pform (Pform.Var (Pform.Var.Pkg Pform.Var.Pkg.Build)) - ; Slang.text "/config.cache" + Dune_lang.Action.Progn + [ Dune_lang.Action.Run + [ Slang.text "touch" + ; Slang.concat + [ Slang.pform (Pform.Var (Pform.Var.Pkg Pform.Var.Pkg.Build)) + ; Slang.text "/config.cache" + ] + ] + ; Dune_lang.Action.Run + [ Slang.text "touch" + ; Slang.concat + [ Slang.pform (Pform.Var (Pform.Var.Pkg Pform.Var.Pkg.Build)) + ; Slang.text "/config.status" + ] ] ] ;; diff --git a/src/dune_rules/pkg_toolchain.mli b/src/dune_rules/pkg_toolchain.mli index d293a265e315..415380191694 100644 --- a/src/dune_rules/pkg_toolchain.mli +++ b/src/dune_rules/pkg_toolchain.mli @@ -30,12 +30,6 @@ val pkg_dir : Dune_pkg.Lock_dir.Pkg.t -> Path.Outside_build_dir.t script. *) val installation_prefix : pkg_dir:Path.Outside_build_dir.t -> Path.Outside_build_dir.t -val ocaml - : Context_name.t - -> Env.t - -> bin_dir:Path.Outside_build_dir.t - -> Ocaml_toolchain.t Memo.t - (** Rewrite the OCaml compiler install action so that it installs the compiler package to the users toolchain directory. If the compiler is found to be already installed in the users toolchain directory, the action is instead