Make Process.run take Env.t directly
This commit is contained in:
parent
4b191b2b03
commit
3193e4902d
|
@ -716,7 +716,7 @@ let exec_run_direct ~ectx ~dir ~env_extra ~stdout_to ~stderr_to prog args =
|
||||||
invalid_prefix ("_build/install/" ^ target.name);
|
invalid_prefix ("_build/install/" ^ target.name);
|
||||||
end;
|
end;
|
||||||
let env = Env.extend ectx.env ~vars:env_extra in
|
let env = Env.extend ectx.env ~vars:env_extra in
|
||||||
Process.run Strict ~dir:(Path.to_string dir) ~env:(Env.to_unix env)
|
Process.run Strict ~dir:(Path.to_string dir) ~env
|
||||||
~stdout_to ~stderr_to
|
~stdout_to ~stderr_to
|
||||||
~purpose:ectx.purpose
|
~purpose:ectx.purpose
|
||||||
(Path.reach_for_running ~from:dir prog) args
|
(Path.reach_for_running ~from:dir prog) args
|
||||||
|
|
|
@ -110,8 +110,7 @@ let opam_config_var ~env ~cache var =
|
||||||
match Bin.opam with
|
match Bin.opam with
|
||||||
| None -> Fiber.return None
|
| None -> Fiber.return None
|
||||||
| Some fn ->
|
| Some fn ->
|
||||||
Process.run_capture (Accept All) (Path.to_string fn)
|
Process.run_capture (Accept All) (Path.to_string fn) ~env
|
||||||
~env:(Env.to_unix env)
|
|
||||||
["config"; "var"; var]
|
["config"; "var"; var]
|
||||||
>>| function
|
>>| function
|
||||||
| Ok s ->
|
| Ok s ->
|
||||||
|
@ -146,7 +145,7 @@ let create ~(kind : Kind.t) ~path ~env_extra ~name ~merlin
|
||||||
match Sys.getenv "OCAMLFIND_CONF" with
|
match Sys.getenv "OCAMLFIND_CONF" with
|
||||||
| s -> Fiber.return (Path.absolute s)
|
| s -> Fiber.return (Path.absolute s)
|
||||||
| exception Not_found ->
|
| exception Not_found ->
|
||||||
Process.run_capture_line ~env:(Env.to_unix env) Strict
|
Process.run_capture_line ~env Strict
|
||||||
(Path.to_string fn) ["printconf"; "conf"]
|
(Path.to_string fn) ["printconf"; "conf"]
|
||||||
>>| Path.absolute)
|
>>| Path.absolute)
|
||||||
in
|
in
|
||||||
|
@ -208,9 +207,7 @@ let create ~(kind : Kind.t) ~path ~env_extra ~name ~merlin
|
||||||
| None -> args
|
| None -> args
|
||||||
| Some s -> "-toolchain" :: s :: args
|
| Some s -> "-toolchain" :: s :: args
|
||||||
in
|
in
|
||||||
Process.run_capture_lines
|
Process.run_capture_lines ~env Strict (Path.to_string fn) args
|
||||||
~env:(Env.to_unix env)
|
|
||||||
Strict (Path.to_string fn) args
|
|
||||||
>>| List.map ~f:Path.absolute
|
>>| List.map ~f:Path.absolute
|
||||||
| None ->
|
| None ->
|
||||||
(* If there no ocamlfind in the PATH, check if we have opam
|
(* If there no ocamlfind in the PATH, check if we have opam
|
||||||
|
@ -233,7 +230,7 @@ let create ~(kind : Kind.t) ~path ~env_extra ~name ~merlin
|
||||||
Fiber.fork_and_join
|
Fiber.fork_and_join
|
||||||
findlib_path
|
findlib_path
|
||||||
(fun () ->
|
(fun () ->
|
||||||
Process.run_capture_lines ~env:(Env.to_unix env) Strict
|
Process.run_capture_lines ~env Strict
|
||||||
(Path.to_string ocamlc) ["-config"]
|
(Path.to_string ocamlc) ["-config"]
|
||||||
>>| fun lines ->
|
>>| fun lines ->
|
||||||
let open Result.O in
|
let open Result.O in
|
||||||
|
@ -409,7 +406,7 @@ let install_ocaml_libdir t =
|
||||||
(* If ocamlfind is present, it has precedence over everything else. *)
|
(* If ocamlfind is present, it has precedence over everything else. *)
|
||||||
match which t "ocamlfind" with
|
match which t "ocamlfind" with
|
||||||
| Some fn ->
|
| Some fn ->
|
||||||
(Process.run_capture_line ~env:(Env.to_unix t.env) Strict
|
(Process.run_capture_line ~env:t.env Strict
|
||||||
(Path.to_string fn) ["printconf"; "destdir"]
|
(Path.to_string fn) ["printconf"; "destdir"]
|
||||||
>>| fun s ->
|
>>| fun s ->
|
||||||
Some (Path.absolute s))
|
Some (Path.absolute s))
|
||||||
|
|
|
@ -149,7 +149,7 @@ end
|
||||||
]}
|
]}
|
||||||
*)
|
*)
|
||||||
Process.run Strict ~dir:(Path.to_string dir)
|
Process.run Strict ~dir:(Path.to_string dir)
|
||||||
~env:(Env.to_unix context.env)
|
~env:context.env
|
||||||
(Path.to_string context.ocaml)
|
(Path.to_string context.ocaml)
|
||||||
args
|
args
|
||||||
>>= fun () ->
|
>>= fun () ->
|
||||||
|
|
|
@ -243,7 +243,7 @@ let run_internal ?dir ?(stdout_to=Terminal) ?(stderr_to=Terminal) ?env ~purpose
|
||||||
Unix.create_process prog argv
|
Unix.create_process prog argv
|
||||||
Unix.stdin stdout stderr
|
Unix.stdin stdout stderr
|
||||||
| Some env ->
|
| Some env ->
|
||||||
Unix.create_process_env prog argv env
|
Unix.create_process_env prog argv (Env.to_unix env)
|
||||||
Unix.stdin stdout stderr
|
Unix.stdin stdout stderr
|
||||||
in
|
in
|
||||||
let pid =
|
let pid =
|
||||||
|
|
|
@ -41,7 +41,7 @@ val run
|
||||||
: ?dir:string
|
: ?dir:string
|
||||||
-> ?stdout_to:std_output_to
|
-> ?stdout_to:std_output_to
|
||||||
-> ?stderr_to:std_output_to
|
-> ?stderr_to:std_output_to
|
||||||
-> ?env:string array
|
-> ?env:Env.t
|
||||||
-> ?purpose:purpose
|
-> ?purpose:purpose
|
||||||
-> (unit, 'a) failure_mode
|
-> (unit, 'a) failure_mode
|
||||||
-> string
|
-> string
|
||||||
|
@ -51,7 +51,7 @@ val run
|
||||||
(** Run a command and capture its output *)
|
(** Run a command and capture its output *)
|
||||||
val run_capture
|
val run_capture
|
||||||
: ?dir:string
|
: ?dir:string
|
||||||
-> ?env:string array
|
-> ?env:Env.t
|
||||||
-> ?purpose:purpose
|
-> ?purpose:purpose
|
||||||
-> (string, 'a) failure_mode
|
-> (string, 'a) failure_mode
|
||||||
-> string
|
-> string
|
||||||
|
@ -59,7 +59,7 @@ val run_capture
|
||||||
-> 'a Fiber.t
|
-> 'a Fiber.t
|
||||||
val run_capture_line
|
val run_capture_line
|
||||||
: ?dir:string
|
: ?dir:string
|
||||||
-> ?env:string array
|
-> ?env:Env.t
|
||||||
-> ?purpose:purpose
|
-> ?purpose:purpose
|
||||||
-> (string, 'a) failure_mode
|
-> (string, 'a) failure_mode
|
||||||
-> string
|
-> string
|
||||||
|
@ -67,7 +67,7 @@ val run_capture_line
|
||||||
-> 'a Fiber.t
|
-> 'a Fiber.t
|
||||||
val run_capture_lines
|
val run_capture_lines
|
||||||
: ?dir:string
|
: ?dir:string
|
||||||
-> ?env:string array
|
-> ?env:Env.t
|
||||||
-> ?purpose:purpose
|
-> ?purpose:purpose
|
||||||
-> (string list, 'a) failure_mode
|
-> (string list, 'a) failure_mode
|
||||||
-> string
|
-> string
|
||||||
|
|
Loading…
Reference in New Issue