Merge pull request #623 from rgrinberg/modify-run-action
Change Action to include the context's exec env
This commit is contained in:
commit
4c69d3e540
|
@ -1131,9 +1131,8 @@ let exec =
|
||||||
raise Already_reported
|
raise Already_reported
|
||||||
| Some real_prog, _ ->
|
| Some real_prog, _ ->
|
||||||
let real_prog = Path.to_string real_prog in
|
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
|
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
|
in
|
||||||
( Term.(const go
|
( Term.(const go
|
||||||
$ common
|
$ common
|
||||||
|
@ -1233,7 +1232,7 @@ let utop =
|
||||||
) |> Scheduler.go ~log ~common in
|
) |> Scheduler.go ~log ~common in
|
||||||
Build_system.finalize build_system;
|
Build_system.finalize build_system;
|
||||||
restore_cwd_and_execve common utop_path (Array.of_list (utop_path :: args))
|
restore_cwd_and_execve common utop_path (Array.of_list (utop_path :: args))
|
||||||
(Context.env_for_exec context)
|
context.env
|
||||||
in
|
in
|
||||||
let name_ = Arg.info [] ~docv:"PATH" in
|
let name_ = Arg.info [] ~docv:"PATH" in
|
||||||
( Term.(const go
|
( Term.(const go
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
(** OCaml binaries *)
|
(** OCaml binaries *)
|
||||||
|
|
||||||
|
val path_sep : char
|
||||||
|
|
||||||
(** Contents of [PATH] *)
|
(** Contents of [PATH] *)
|
||||||
val path : Path.t list
|
val path : Path.t list
|
||||||
|
|
||||||
|
|
|
@ -253,6 +253,31 @@ let create ~(kind : Kind.t) ~path ~env ~name ~merlin ~targets () =
|
||||||
else
|
else
|
||||||
env
|
env
|
||||||
in
|
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 stdlib_dir = Path.of_string (Ocaml_config.standard_library ocfg) in
|
||||||
let natdynlink_supported = Ocaml_config.natdynlink_supported ocfg in
|
let natdynlink_supported = Ocaml_config.natdynlink_supported ocfg in
|
||||||
let version = Ocaml_config.version ocfg in
|
let version = Ocaml_config.version ocfg in
|
||||||
|
@ -408,33 +433,6 @@ let install_ocaml_libdir t =
|
||||||
| None ->
|
| None ->
|
||||||
Fiber.return 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) =
|
let compiler t (mode : Mode.t) =
|
||||||
match mode with
|
match mode with
|
||||||
| Byte -> Some t.ocamlc
|
| Byte -> Some t.ocamlc
|
||||||
|
|
|
@ -130,8 +130,6 @@ val opam_config_var : t -> string -> string option Fiber.t
|
||||||
val install_prefix : t -> Path.t Fiber.t
|
val install_prefix : t -> Path.t Fiber.t
|
||||||
val install_ocaml_libdir : t -> Path.t option 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 *)
|
(** Return the compiler needed for this compilation mode *)
|
||||||
val compiler : t -> Mode.t -> Path.t option
|
val compiler : t -> Mode.t -> Path.t option
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue