From d9c82669776da2a7ec6ff8420564181679bc5bc6 Mon Sep 17 00:00:00 2001 From: Rudi Grinberg Date: Mon, 19 Oct 2020 23:59:35 -0700 Subject: [PATCH] Move all lib install path to Config Previously, they were present in Config + Context Signed-off-by: Rudi Grinberg --- src/dune_engine/config.ml | 5 ++++- src/dune_engine/config.mli | 2 ++ src/dune_rules/context.ml | 26 ++++++++++---------------- 3 files changed, 16 insertions(+), 17 deletions(-) diff --git a/src/dune_engine/config.ml b/src/dune_engine/config.ml index 7bb4daa2180..06b84a68956 100644 --- a/src/dune_engine/config.ml +++ b/src/dune_engine/config.ml @@ -5,6 +5,9 @@ let local_install_dir ~context = let context = Context_name.to_string context in Path.Build.relative Dpath.Build.install_dir context +let local_install_lib_root ~context = + Path.Build.relative (local_install_dir ~context) "lib" + let local_install_bin_dir ~context = Path.Build.relative (local_install_dir ~context) "bin" @@ -13,7 +16,7 @@ let local_install_man_dir ~context = let local_install_lib_dir ~context ~package = Path.Build.relative - (Path.Build.relative (local_install_dir ~context) "lib") + (local_install_lib_root ~context) (Package.Name.to_string package) let dev_null = diff --git a/src/dune_engine/config.mli b/src/dune_engine/config.mli index c805be68187..ea0c859cee0 100644 --- a/src/dune_engine/config.mli +++ b/src/dune_engine/config.mli @@ -5,6 +5,8 @@ open! Import (** Local installation directory *) val local_install_dir : context:Context_name.t -> Path.Build.t +val local_install_lib_root : context:Context_name.t -> Path.Build.t + val local_install_bin_dir : context:Context_name.t -> Path.Build.t val local_install_man_dir : context:Context_name.t -> Path.Build.t diff --git a/src/dune_rules/context.ml b/src/dune_rules/context.ml index e7baa6712b2..4a3f6f3d30b 100644 --- a/src/dune_rules/context.ml +++ b/src/dune_rules/context.ml @@ -452,33 +452,28 @@ let create ~(kind : Kind.t) ~path ~env ~env_nodes ~name ~merlin ~targets let env = let cwd = Sys.getcwd () in let extend_var var ?(path_sep = Bin.path_sep) v = - let v = Filename.concat cwd (Path.to_string v) in + let v = Filename.concat cwd (Path.Build.to_string v) in match Env.get env var with | None -> (var, v) | Some prev -> (var, sprintf "%s%c%s" v path_sep prev) in let vars = - let local_lib_path = - Path.Build.relative (Config.local_install_dir ~context:name) "lib" - |> Path.build - in + let local_lib_root = Config.local_install_lib_root ~context:name in [ extend_var "CAML_LD_LIBRARY_PATH" - (Path.build - (Path.Build.relative - (Config.local_install_dir ~context:name) - "lib/stublibs")) - ; extend_var "OCAMLPATH" ~path_sep:ocamlpath_sep local_lib_path + (Path.Build.relative + (Config.local_install_dir ~context:name) + "lib/stublibs") + ; extend_var "OCAMLPATH" ~path_sep:ocamlpath_sep local_lib_root ; ("DUNE_OCAML_STDLIB", Ocaml_config.standard_library ocfg) ; ( "DUNE_OCAML_HARDCODED" , String.concat ~sep:(Char.escaped ocamlpath_sep) (List.map ~f:Path.to_string default_findlib_paths) ) ; extend_var "OCAMLTOP_INCLUDE_PATH" - (Path.relative local_lib_path "toplevel") + (Path.Build.relative local_lib_root "toplevel") ; extend_var "OCAMLFIND_IGNORE_DUPS_IN" ~path_sep:ocamlpath_sep - local_lib_path - ; extend_var "MANPATH" - (Path.build (Config.local_install_man_dir ~context:name)) + local_lib_root + ; extend_var "MANPATH" (Config.local_install_man_dir ~context:name) ; ("INSIDE_DUNE", Path.to_absolute_filename (Path.build build_dir)) ; ( "DUNE_SOURCEROOT" , Path.to_absolute_filename (Path.source Path.Source.root) ) @@ -489,8 +484,7 @@ let create ~(kind : Kind.t) ~path ~env ~env_nodes ~name ~merlin ~targets match host with | None -> let _key, path = - Path.build (Config.local_install_bin_dir ~context:name) - |> extend_var "PATH" + Config.local_install_bin_dir ~context:name |> extend_var "PATH" in Some path | Some host -> Env.get host.env "PATH")