From 3193e4902dc39f94fadf1f8e377608ac314b1d67 Mon Sep 17 00:00:00 2001 From: Rudi Grinberg Date: Sun, 11 Mar 2018 11:20:37 +0700 Subject: [PATCH] Make Process.run take Env.t directly --- src/action.ml | 2 +- src/context.ml | 13 +++++-------- src/jbuild_load.ml | 2 +- src/process.ml | 2 +- src/process.mli | 8 ++++---- 5 files changed, 12 insertions(+), 15 deletions(-) diff --git a/src/action.ml b/src/action.ml index d6b25de3..16f5ca86 100644 --- a/src/action.ml +++ b/src/action.ml @@ -716,7 +716,7 @@ let exec_run_direct ~ectx ~dir ~env_extra ~stdout_to ~stderr_to prog args = invalid_prefix ("_build/install/" ^ target.name); end; 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 ~purpose:ectx.purpose (Path.reach_for_running ~from:dir prog) args diff --git a/src/context.ml b/src/context.ml index ff59ee66..518c2f62 100644 --- a/src/context.ml +++ b/src/context.ml @@ -110,8 +110,7 @@ let opam_config_var ~env ~cache var = match Bin.opam with | None -> Fiber.return None | Some fn -> - Process.run_capture (Accept All) (Path.to_string fn) - ~env:(Env.to_unix env) + Process.run_capture (Accept All) (Path.to_string fn) ~env ["config"; "var"; var] >>| function | Ok s -> @@ -146,7 +145,7 @@ let create ~(kind : Kind.t) ~path ~env_extra ~name ~merlin match Sys.getenv "OCAMLFIND_CONF" with | s -> Fiber.return (Path.absolute s) | 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.absolute) in @@ -208,9 +207,7 @@ let create ~(kind : Kind.t) ~path ~env_extra ~name ~merlin | None -> args | Some s -> "-toolchain" :: s :: args in - Process.run_capture_lines - ~env:(Env.to_unix env) - Strict (Path.to_string fn) args + Process.run_capture_lines ~env Strict (Path.to_string fn) args >>| List.map ~f:Path.absolute | None -> (* 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 findlib_path (fun () -> - Process.run_capture_lines ~env:(Env.to_unix env) Strict + Process.run_capture_lines ~env Strict (Path.to_string ocamlc) ["-config"] >>| fun lines -> let open Result.O in @@ -409,7 +406,7 @@ let install_ocaml_libdir t = (* If ocamlfind is present, it has precedence over everything else. *) match which t "ocamlfind" with | 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"] >>| fun s -> Some (Path.absolute s)) diff --git a/src/jbuild_load.ml b/src/jbuild_load.ml index 3564edcf..2bf6e9dd 100644 --- a/src/jbuild_load.ml +++ b/src/jbuild_load.ml @@ -149,7 +149,7 @@ end ]} *) Process.run Strict ~dir:(Path.to_string dir) - ~env:(Env.to_unix context.env) + ~env:context.env (Path.to_string context.ocaml) args >>= fun () -> diff --git a/src/process.ml b/src/process.ml index 39fbb651..3a6ae0e4 100644 --- a/src/process.ml +++ b/src/process.ml @@ -243,7 +243,7 @@ let run_internal ?dir ?(stdout_to=Terminal) ?(stderr_to=Terminal) ?env ~purpose Unix.create_process prog argv Unix.stdin stdout stderr | Some env -> - Unix.create_process_env prog argv env + Unix.create_process_env prog argv (Env.to_unix env) Unix.stdin stdout stderr in let pid = diff --git a/src/process.mli b/src/process.mli index 0a7ea370..ad406f8c 100644 --- a/src/process.mli +++ b/src/process.mli @@ -41,7 +41,7 @@ val run : ?dir:string -> ?stdout_to:std_output_to -> ?stderr_to:std_output_to - -> ?env:string array + -> ?env:Env.t -> ?purpose:purpose -> (unit, 'a) failure_mode -> string @@ -51,7 +51,7 @@ val run (** Run a command and capture its output *) val run_capture : ?dir:string - -> ?env:string array + -> ?env:Env.t -> ?purpose:purpose -> (string, 'a) failure_mode -> string @@ -59,7 +59,7 @@ val run_capture -> 'a Fiber.t val run_capture_line : ?dir:string - -> ?env:string array + -> ?env:Env.t -> ?purpose:purpose -> (string, 'a) failure_mode -> string @@ -67,7 +67,7 @@ val run_capture_line -> 'a Fiber.t val run_capture_lines : ?dir:string - -> ?env:string array + -> ?env:Env.t -> ?purpose:purpose -> (string list, 'a) failure_mode -> string