From b02c61f63c572b5617e441cf49e46073779301a2 Mon Sep 17 00:00:00 2001 From: Rudi Grinberg Date: Wed, 25 Apr 2018 16:30:18 +0700 Subject: [PATCH] Change the prog arg in Process to Path.t --- bin/main.ml | 3 +-- src/context.ml | 17 +++++++---------- src/jbuild_load.ml | 4 +--- src/print_diff.ml | 7 +++---- src/process.ml | 3 +++ src/process.mli | 8 ++++---- src/stdune/path.mli | 2 +- src/watermarks.ml | 2 +- 8 files changed, 21 insertions(+), 25 deletions(-) diff --git a/bin/main.ml b/bin/main.ml index 6323efef..108a5740 100644 --- a/bin/main.ml +++ b/bin/main.ml @@ -1007,8 +1007,7 @@ let install_uninstall ~what = >>= fun libdir -> Fiber.parallel_iter install_files ~f:(fun path -> let purpose = Process.Build_job install_files in - Process.run ~purpose ~env:setup.env Strict - (Path.to_string opam_installer) + Process.run ~purpose ~env:setup.env Strict opam_installer ([ sprintf "-%c" what.[0] ; Path.to_string path ; "--prefix" diff --git a/src/context.ml b/src/context.ml index 4528c30f..a38ffcfd 100644 --- a/src/context.ml +++ b/src/context.ml @@ -109,7 +109,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 + Process.run_capture (Accept All) fn ~env ["config"; "var"; var] >>| function | Ok s -> @@ -151,7 +151,7 @@ let create ~(kind : Kind.t) ~path ~env ~name ~merlin ~targets () = | Some s -> Fiber.return (Path.absolute s) | None -> Process.run_capture_line ~env Strict - (Path.to_string fn) ["printconf"; "conf"] + fn ["printconf"; "conf"] >>| Path.absolute) in @@ -232,7 +232,7 @@ let create ~(kind : Kind.t) ~path ~env ~name ~merlin ~targets () = | None -> args | Some s -> "-toolchain" :: s :: args in - Process.run_capture_lines ~env Strict (Path.to_string fn) args + Process.run_capture_lines ~env Strict fn args >>| fun l -> (* Don't prepend the contents of [OCAMLPATH] since findlib does it already *) @@ -258,8 +258,7 @@ let create ~(kind : Kind.t) ~path ~env ~name ~merlin ~targets () = Fiber.fork_and_join findlib_path (fun () -> - Process.run_capture_lines ~env Strict - (Path.to_string ocamlc) ["-config"] + Process.run_capture_lines ~env Strict ocamlc ["-config"] >>| fun lines -> let open Result.O in ocaml_config_ok_exn @@ -411,10 +410,9 @@ let create_for_opam ?root ~env ~targets ~switch ~name ?(merlin=false) () = (match root with | Some root -> Fiber.return root | None -> - Process.run_capture_line Strict ~env - (Path.to_string fn) ["config"; "var"; "root"]) + Process.run_capture_line Strict ~env fn ["config"; "var"; "root"]) >>= fun root -> - Process.run_capture ~env Strict (Path.to_string fn) + Process.run_capture ~env Strict fn ["config"; "env"; "--root"; root; "--switch"; switch; "--sexp"] >>= fun s -> let vars = @@ -465,8 +463,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:t.env Strict - (Path.to_string fn) ["printconf"; "destdir"] + (Process.run_capture_line ~env:t.env Strict fn ["printconf"; "destdir"] >>| fun s -> Some (Path.absolute s)) | None -> diff --git a/src/jbuild_load.ml b/src/jbuild_load.ml index 7df54961..3c8d6a7b 100644 --- a/src/jbuild_load.ml +++ b/src/jbuild_load.ml @@ -147,9 +147,7 @@ end in ]} *) - Process.run Strict ~dir - ~env:context.env - (Path.to_string context.ocaml) + Process.run Strict ~dir ~env:context.env context.ocaml args >>= fun () -> if not (Path.exists generated_jbuild) then diff --git a/src/print_diff.ml b/src/print_diff.ml index 28a43ac3..0cf03568 100644 --- a/src/print_diff.ml +++ b/src/print_diff.ml @@ -24,8 +24,7 @@ let print path1 path2 = | None -> fallback () | Some prog -> Format.eprintf "%a@?" Loc.print loc; - Process.run ~dir ~env:Env.initial Strict (Path.to_string prog) - ["-u"; file1; file2] + Process.run ~dir ~env:Env.initial Strict prog ["-u"; file1; file2] >>= fun () -> fallback () in @@ -35,7 +34,7 @@ let print path1 path2 = let cmd = sprintf "%s %s %s" cmd (quote_for_shell file1) (quote_for_shell file2) in - Process.run ~dir ~env:Env.initial Strict (Path.to_string sh) [arg; cmd] + Process.run ~dir ~env:Env.initial Strict sh [arg; cmd] >>= fun () -> die "command reported no differences: %s" (if Path.is_root dir then @@ -46,7 +45,7 @@ let print path1 path2 = match Bin.which "patdiff" with | None -> normal_diff () | Some prog -> - Process.run ~dir ~env:Env.initial Strict (Path.to_string prog) + Process.run ~dir ~env:Env.initial Strict prog [ "-keep-whitespace" ; "-location-style"; "omake" ; if Lazy.force Colors.stderr_supports_colors then diff --git a/src/process.ml b/src/process.ml index bbc93ffd..9a5ab24a 100644 --- a/src/process.ml +++ b/src/process.ml @@ -112,6 +112,7 @@ module Fancy = struct | x :: rest -> x :: colorize_args rest let command_line ~prog ~args ~dir ~stdout_to ~stderr_to = + let prog = Path.to_string prog in let quote = quote_for_shell in let prog = colorize_prog (quote prog) in let s = @@ -228,6 +229,7 @@ let run_internal ?dir ?(stdout_to=Terminal) ?(stderr_to=Terminal) ~env ~purpose if display = Verbose then Format.eprintf "@{Running@}[@{%d@}]: %s@." id (Colors.strip_colors_for_stderr command_line); + let prog = Path.to_string prog in let argv = Array.of_list (prog :: args) in let output_filename, stdout_fd, stderr_fd, to_close = match stdout_to, stderr_to with @@ -342,6 +344,7 @@ let run_capture_line ?dir ~env ?(purpose=Internal_job) fail_mode prog args = | [x] -> x | l -> let cmdline = + let prog = Path.to_string prog in let s = String.concat (prog :: args) ~sep:" " in match dir with | None -> s diff --git a/src/process.mli b/src/process.mli index 525eb955..41a53585 100644 --- a/src/process.mli +++ b/src/process.mli @@ -44,7 +44,7 @@ val run -> env:Env.t -> ?purpose:purpose -> (unit, 'a) failure_mode - -> string + -> Path.t -> string list -> 'a Fiber.t @@ -54,7 +54,7 @@ val run_capture -> env:Env.t -> ?purpose:purpose -> (string, 'a) failure_mode - -> string + -> Path.t -> string list -> 'a Fiber.t val run_capture_line @@ -62,7 +62,7 @@ val run_capture_line -> env:Env.t -> ?purpose:purpose -> (string, 'a) failure_mode - -> string + -> Path.t -> string list -> 'a Fiber.t val run_capture_lines @@ -70,7 +70,7 @@ val run_capture_lines -> env:Env.t -> ?purpose:purpose -> (string list, 'a) failure_mode - -> string + -> Path.t -> string list -> 'a Fiber.t diff --git a/src/stdune/path.mli b/src/stdune/path.mli index 37d30150..f4c9984f 100644 --- a/src/stdune/path.mli +++ b/src/stdune/path.mli @@ -70,7 +70,7 @@ val absolute : string -> t val to_absolute_filename : t -> root:string -> string val reach : t -> from:t -> string -val reach_for_running : t -> from:t -> string +val reach_for_running : t -> from:t -> t val descendant : t -> of_:t -> t option val is_descendant : t -> of_:t -> bool diff --git a/src/watermarks.ml b/src/watermarks.ml index b85e75cf..98b4c1b4 100644 --- a/src/watermarks.ml +++ b/src/watermarks.ml @@ -201,7 +201,7 @@ let subst_git ?name () = let rev = "HEAD" in let git = match Bin.which "git" with - | Some x -> Path.to_string x + | Some x -> x | None -> Utils.program_not_found "git" in let env = Env.initial in