From b5bae0ee363a1cd0dd5128126b9c62fd1053e873 Mon Sep 17 00:00:00 2001 From: ArthurW Date: Tue, 25 Mar 2025 15:30:52 +0100 Subject: [PATCH] chore(cram): remove Sanitizer dead code Signed-off-by: ArthurW --- src/dune_rules/cram/cram_exec.ml | 89 -------------------------------- 1 file changed, 89 deletions(-) diff --git a/src/dune_rules/cram/cram_exec.ml b/src/dune_rules/cram/cram_exec.ml index 09888192b87..35b54580dbc 100644 --- a/src/dune_rules/cram/cram_exec.ml +++ b/src/dune_rules/cram/cram_exec.ml @@ -1,94 +1,5 @@ open Import -module Sanitizer : sig - [@@@ocaml.warning "-32"] - - module Command : sig - type t = - { output : string - ; build_path_prefix_map : string - ; script : Path.t - } - end - - val impl_sanitizer : (Command.t -> string) -> in_channel -> out_channel -> unit - - val run_sanitizer - : ?temp_dir:Path.t - -> prog:Path.t - -> argv:string list - -> Command.t list - -> string list Fiber.t -end = struct - module Command = struct - type t = - { output : string - ; build_path_prefix_map : string - ; script : Path.t - } - - let of_sexp script (csexp : Sexp.t) : t = - match csexp with - | List [ Atom build_path_prefix_map; Atom output ] -> - { build_path_prefix_map; output; script } - | _ -> Code_error.raise "Command.of_csexp: invalid csexp" [] - ;; - - let to_sexp { output; build_path_prefix_map; script } : Sexp.t = - List - [ Atom build_path_prefix_map - ; Atom output - ; Atom (Path.to_absolute_filename script) - ] - ;; - end - - let run_sanitizer ?temp_dir ~prog ~argv commands = - let temp_dir = - match temp_dir with - | Some d -> d - | None -> Temp.create Dir ~prefix:"sanitizer" ~suffix:"unspecified" - in - let fname = Path.relative temp_dir in - let stdout_path = fname "sanitizer.stdout" in - let stdout_to = Process.Io.file stdout_path Process.Io.Out in - let stdin_from = - let path = fname "sanitizer.stdin" in - let csexp = List.map commands ~f:Command.to_sexp in - Io.with_file_out ~binary:true path ~f:(fun oc -> - List.iter csexp ~f:(Csexp.to_channel oc)); - Process.Io.file path Process.Io.In - in - let open Fiber.O in - let+ () = Process.run ~display:Quiet ~stdin_from ~stdout_to Strict prog argv in - Io.with_file_in stdout_path ~f:(fun ic -> - let rec loop acc = - match Csexp.input_opt ic with - | Ok None -> List.rev acc - | Ok (Some (Sexp.Atom s)) -> loop (s :: acc) - | Error error -> Code_error.raise "invalid csexp" [ "error", String error ] - | Ok _ -> Code_error.raise "unexpected output" [] - in - loop []) - ;; - - let impl_sanitizer f in_ out = - set_binary_mode_in in_ true; - set_binary_mode_out out true; - let rec loop () = - match Csexp.input_opt in_ with - | Error error -> Code_error.raise "unable to parse csexp" [ "error", String error ] - | Ok None -> () - | Ok (Some sexp) -> - let command = Command.of_sexp (assert false) sexp in - Csexp.to_channel out (Atom (f command)); - flush out; - loop () - in - loop () - ;; -end - (* Translate a path for [sh]. On Windows, [sh] will come from Cygwin so if we are a real windows program we need to pass the path through [cygpath] *) let translate_path_for_sh =