Merge pull request #623 from rgrinberg/modify-run-action

Change Action to include the context's exec env
This commit is contained in:
Rudi Grinberg 2018-03-16 10:57:03 +08:00 committed by GitHub
commit 4c69d3e540
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 29 additions and 32 deletions

View File

@ -1131,9 +1131,8 @@ let exec =
raise Already_reported
| Some real_prog, _ ->
let real_prog = Path.to_string real_prog in
let env = Context.env_for_exec context in
let argv = Array.of_list (prog :: args) in
restore_cwd_and_execve common real_prog argv env
restore_cwd_and_execve common real_prog argv context.env
in
( Term.(const go
$ common
@ -1233,7 +1232,7 @@ let utop =
) |> Scheduler.go ~log ~common in
Build_system.finalize build_system;
restore_cwd_and_execve common utop_path (Array.of_list (utop_path :: args))
(Context.env_for_exec context)
context.env
in
let name_ = Arg.info [] ~docv:"PATH" in
( Term.(const go

View File

@ -1,5 +1,7 @@
(** OCaml binaries *)
val path_sep : char
(** Contents of [PATH] *)
val path : Path.t list

View File

@ -253,6 +253,31 @@ let create ~(kind : Kind.t) ~path ~env ~name ~merlin ~targets () =
else
env
in
let env =
let cwd = Sys.getcwd () in
let extend_var var v =
let v = Filename.concat cwd (Path.to_string v) in
match Env.get env var with
| None -> (var, v)
| Some prev -> (var, sprintf "%s%c%s" v Bin.path_sep prev)
in
let vars =
[ extend_var "CAML_LD_LIBRARY_PATH"
(Path.relative
(Config.local_install_dir ~context:name)
"lib/stublibs")
; extend_var "OCAMLPATH"
(Path.relative
(Config.local_install_dir ~context:name)
"lib")
; extend_var "PATH"
(Config.local_install_bin_dir ~context:name)
; extend_var "MANPATH"
(Config.local_install_man_dir ~context:name)
]
in
Env.extend env ~vars:(Env.Map.of_list_exn vars)
in
let stdlib_dir = Path.of_string (Ocaml_config.standard_library ocfg) in
let natdynlink_supported = Ocaml_config.natdynlink_supported ocfg in
let version = Ocaml_config.version ocfg in
@ -408,33 +433,6 @@ let install_ocaml_libdir t =
| None ->
Fiber.return None
(* CR-someday jdimino: maybe we should just do this for [t.env] directly? *)
let env_for_exec t =
let sep = if Sys.win32 then ';' else ':' in
let cwd = Sys.getcwd () in
let extend_var var v =
let v = Filename.concat cwd (Path.to_string v) in
match Env.get t.env var with
| None -> (var, v)
| Some prev -> (var, sprintf "%s%c%s" v sep prev)
in
let vars =
[ extend_var "CAML_LD_LIBRARY_PATH"
(Path.relative
(Config.local_install_dir ~context:t.name)
"lib/stublibs")
; extend_var "OCAMLPATH"
(Path.relative
(Config.local_install_dir ~context:t.name)
"lib")
; extend_var "PATH"
(Config.local_install_bin_dir ~context:t.name)
; extend_var "MANPATH"
(Config.local_install_man_dir ~context:t.name)
]
in
Env.extend t.env ~vars:(Env.Map.of_list_exn vars)
let compiler t (mode : Mode.t) =
match mode with
| Byte -> Some t.ocamlc

View File

@ -130,8 +130,6 @@ val opam_config_var : t -> string -> string option Fiber.t
val install_prefix : t -> Path.t Fiber.t
val install_ocaml_libdir : t -> Path.t option Fiber.t
val env_for_exec : t -> Env.t
(** Return the compiler needed for this compilation mode *)
val compiler : t -> Mode.t -> Path.t option