Skip to content

Commit

Permalink
Merge branch 'master' into describe_executables
Browse files Browse the repository at this point in the history
  • Loading branch information
nojb authored Oct 27, 2020
2 parents ac3a3fe + 76c161d commit 00781e5
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 17 deletions.
5 changes: 4 additions & 1 deletion src/dune_engine/config.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand All @@ -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 =
Expand Down
2 changes: 2 additions & 0 deletions src/dune_engine/config.mli
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
26 changes: 10 additions & 16 deletions src/dune_rules/context.ml
Original file line number Diff line number Diff line change
Expand Up @@ -457,33 +457,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) )
Expand All @@ -494,8 +489,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")
Expand Down

0 comments on commit 00781e5

Please sign in to comment.