Remove env_extra in Action
It's simply to just use Env.t everywhere. Also, there's no need to have the env in the execution context since it's not used for anything. Only the env that is passed directly is used.
This commit is contained in:
parent
f1baaa23a8
commit
e604c69510
|
@ -697,10 +697,9 @@ end
|
||||||
type exec_context =
|
type exec_context =
|
||||||
{ context : Context.t option
|
{ context : Context.t option
|
||||||
; purpose : Process.purpose
|
; purpose : Process.purpose
|
||||||
; env : Env.t
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let exec_run_direct ~ectx ~dir ~env_extra ~stdout_to ~stderr_to prog args =
|
let exec_run_direct ~ectx ~dir ~env ~stdout_to ~stderr_to prog args =
|
||||||
begin match ectx.context with
|
begin match ectx.context with
|
||||||
| None
|
| None
|
||||||
| Some { Context.for_host = None; _ } -> ()
|
| Some { Context.for_host = None; _ } -> ()
|
||||||
|
@ -715,7 +714,6 @@ let exec_run_direct ~ectx ~dir ~env_extra ~stdout_to ~stderr_to prog args =
|
||||||
invalid_prefix ("_build/" ^ target.name);
|
invalid_prefix ("_build/" ^ target.name);
|
||||||
invalid_prefix ("_build/install/" ^ target.name);
|
invalid_prefix ("_build/install/" ^ target.name);
|
||||||
end;
|
end;
|
||||||
let env = Env.extend ectx.env ~vars:env_extra in
|
|
||||||
Process.run Strict ~dir:(Path.to_string dir) ~env
|
Process.run Strict ~dir:(Path.to_string dir) ~env
|
||||||
~stdout_to ~stderr_to
|
~stdout_to ~stderr_to
|
||||||
~purpose:ectx.purpose
|
~purpose:ectx.purpose
|
||||||
|
@ -732,17 +730,17 @@ let exec_echo stdout_to str =
|
||||||
| None -> print_string str; flush stdout
|
| None -> print_string str; flush stdout
|
||||||
| Some (_, oc) -> output_string oc str)
|
| Some (_, oc) -> output_string oc str)
|
||||||
|
|
||||||
let rec exec t ~ectx ~dir ~env_extra ~stdout_to ~stderr_to =
|
let rec exec t ~ectx ~dir ~env ~stdout_to ~stderr_to =
|
||||||
match t with
|
match t with
|
||||||
| Run (Error e, _) ->
|
| Run (Error e, _) ->
|
||||||
Prog.Not_found.raise e
|
Prog.Not_found.raise e
|
||||||
| Run (Ok prog, args) ->
|
| Run (Ok prog, args) ->
|
||||||
exec_run ~ectx ~dir ~env_extra ~stdout_to ~stderr_to prog args
|
exec_run ~ectx ~dir ~env ~stdout_to ~stderr_to prog args
|
||||||
| Chdir (dir, t) ->
|
| Chdir (dir, t) ->
|
||||||
exec t ~ectx ~dir ~env_extra ~stdout_to ~stderr_to
|
exec t ~ectx ~dir ~env ~stdout_to ~stderr_to
|
||||||
| Setenv (var, value, t) ->
|
| Setenv (var, value, t) ->
|
||||||
exec t ~ectx ~dir ~stdout_to ~stderr_to
|
exec t ~ectx ~dir ~stdout_to ~stderr_to
|
||||||
~env_extra:(Env.Map.add env_extra var value)
|
~env:(Env.add env ~var ~value)
|
||||||
| Redirect (Stdout, fn, Echo s) ->
|
| Redirect (Stdout, fn, Echo s) ->
|
||||||
Io.write_file (Path.to_string fn) s;
|
Io.write_file (Path.to_string fn) s;
|
||||||
Fiber.return ()
|
Fiber.return ()
|
||||||
|
@ -754,13 +752,13 @@ let rec exec t ~ectx ~dir ~env_extra ~stdout_to ~stderr_to =
|
||||||
| Stderr -> (get_std_output stdout_to, out)
|
| Stderr -> (get_std_output stdout_to, out)
|
||||||
| Outputs -> (out, out)
|
| Outputs -> (out, out)
|
||||||
in
|
in
|
||||||
exec_run_direct ~ectx ~dir ~env_extra ~stdout_to ~stderr_to prog args
|
exec_run_direct ~ectx ~dir ~env ~stdout_to ~stderr_to prog args
|
||||||
| Redirect (outputs, fn, t) ->
|
| Redirect (outputs, fn, t) ->
|
||||||
redirect ~ectx ~dir outputs fn t ~env_extra ~stdout_to ~stderr_to
|
redirect ~ectx ~dir outputs fn t ~env ~stdout_to ~stderr_to
|
||||||
| Ignore (outputs, t) ->
|
| Ignore (outputs, t) ->
|
||||||
redirect ~ectx ~dir outputs Config.dev_null t ~env_extra ~stdout_to ~stderr_to
|
redirect ~ectx ~dir outputs Config.dev_null t ~env ~stdout_to ~stderr_to
|
||||||
| Progn l ->
|
| Progn l ->
|
||||||
exec_list l ~ectx ~dir ~env_extra ~stdout_to ~stderr_to
|
exec_list l ~ectx ~dir ~env ~stdout_to ~stderr_to
|
||||||
| Echo str -> exec_echo stdout_to str
|
| Echo str -> exec_echo stdout_to str
|
||||||
| Cat fn ->
|
| Cat fn ->
|
||||||
Io.with_file_in (Path.to_string fn) ~f:(fun ic ->
|
Io.with_file_in (Path.to_string fn) ~f:(fun ic ->
|
||||||
|
@ -813,9 +811,9 @@ let rec exec t ~ectx ~dir ~env_extra ~stdout_to ~stderr_to =
|
||||||
let path, arg =
|
let path, arg =
|
||||||
Utils.system_shell_exn ~needed_to:"interpret (system ...) actions"
|
Utils.system_shell_exn ~needed_to:"interpret (system ...) actions"
|
||||||
in
|
in
|
||||||
exec_run ~ectx ~dir ~env_extra ~stdout_to ~stderr_to path [arg; cmd]
|
exec_run ~ectx ~dir ~env ~stdout_to ~stderr_to path [arg; cmd]
|
||||||
| Bash cmd ->
|
| Bash cmd ->
|
||||||
exec_run ~ectx ~dir ~env_extra ~stdout_to ~stderr_to
|
exec_run ~ectx ~dir ~env ~stdout_to ~stderr_to
|
||||||
(Utils.bash_exn ~needed_to:"interpret (bash ...) actions")
|
(Utils.bash_exn ~needed_to:"interpret (bash ...) actions")
|
||||||
["-e"; "-u"; "-o"; "pipefail"; "-c"; cmd]
|
["-e"; "-u"; "-o"; "pipefail"; "-c"; cmd]
|
||||||
| Write_file (fn, s) ->
|
| Write_file (fn, s) ->
|
||||||
|
@ -867,7 +865,7 @@ let rec exec t ~ectx ~dir ~env_extra ~stdout_to ~stderr_to =
|
||||||
Print_diff.print file1 file2
|
Print_diff.print file1 file2
|
||||||
end
|
end
|
||||||
|
|
||||||
and redirect outputs fn t ~ectx ~dir ~env_extra ~stdout_to ~stderr_to =
|
and redirect outputs fn t ~ectx ~dir ~env ~stdout_to ~stderr_to =
|
||||||
let fn = Path.to_string fn in
|
let fn = Path.to_string fn in
|
||||||
let oc = Io.open_out fn in
|
let oc = Io.open_out fn in
|
||||||
let out = Some (fn, oc) in
|
let out = Some (fn, oc) in
|
||||||
|
@ -877,18 +875,18 @@ and redirect outputs fn t ~ectx ~dir ~env_extra ~stdout_to ~stderr_to =
|
||||||
| Stderr -> (stdout_to, out)
|
| Stderr -> (stdout_to, out)
|
||||||
| Outputs -> (out, out)
|
| Outputs -> (out, out)
|
||||||
in
|
in
|
||||||
exec t ~ectx ~dir ~env_extra ~stdout_to ~stderr_to >>| fun () ->
|
exec t ~ectx ~dir ~env ~stdout_to ~stderr_to >>| fun () ->
|
||||||
close_out oc
|
close_out oc
|
||||||
|
|
||||||
and exec_list l ~ectx ~dir ~env_extra ~stdout_to ~stderr_to =
|
and exec_list l ~ectx ~dir ~env ~stdout_to ~stderr_to =
|
||||||
match l with
|
match l with
|
||||||
| [] ->
|
| [] ->
|
||||||
Fiber.return ()
|
Fiber.return ()
|
||||||
| [t] ->
|
| [t] ->
|
||||||
exec t ~ectx ~dir ~env_extra ~stdout_to ~stderr_to
|
exec t ~ectx ~dir ~env ~stdout_to ~stderr_to
|
||||||
| t :: rest ->
|
| t :: rest ->
|
||||||
exec t ~ectx ~dir ~env_extra ~stdout_to ~stderr_to >>= fun () ->
|
exec t ~ectx ~dir ~env ~stdout_to ~stderr_to >>= fun () ->
|
||||||
exec_list rest ~ectx ~dir ~env_extra ~stdout_to ~stderr_to
|
exec_list rest ~ectx ~dir ~env ~stdout_to ~stderr_to
|
||||||
|
|
||||||
let exec ~targets ?context t =
|
let exec ~targets ?context t =
|
||||||
let env =
|
let env =
|
||||||
|
@ -898,9 +896,8 @@ let exec ~targets ?context t =
|
||||||
in
|
in
|
||||||
let targets = Path.Set.to_list targets in
|
let targets = Path.Set.to_list targets in
|
||||||
let purpose = Process.Build_job targets in
|
let purpose = Process.Build_job targets in
|
||||||
let ectx = { purpose; context; env } in
|
let ectx = { purpose; context } in
|
||||||
exec t ~ectx ~dir:Path.root ~env_extra:Env.Map.empty
|
exec t ~ectx ~dir:Path.root ~env ~stdout_to:None ~stderr_to:None
|
||||||
~stdout_to:None ~stderr_to:None
|
|
||||||
|
|
||||||
let sandbox t ~sandboxed ~deps ~targets =
|
let sandbox t ~sandboxed ~deps ~targets =
|
||||||
Progn
|
Progn
|
||||||
|
|
Loading…
Reference in New Issue