feat: ability to produce .gz proof files

This commit is contained in:
Simon Cruanes 2021-11-10 18:23:26 -05:00
parent 8c780e3ed5
commit a8a851a7de
No known key found for this signature in database
GPG key ID: 4AC01D0849AA62B6

View file

@ -129,6 +129,15 @@ let mk_progress (_s:Solver.t) : _ -> unit =
flush stdout flush stdout
) )
let with_file_out (file:string) (f:out_channel -> 'a): 'a =
if Filename.extension file = ".gz" then (
let p =
Unix.open_process_out
(Printf.sprintf "gzip -c - > \"%s\"" (String.escaped file))
in
CCFun.finally1 ~h:(fun () -> Unix.close_process_out p) f p
) else CCIO.with_out file f
(* call the solver to check-sat *) (* call the solver to check-sat *)
let solve let solve
?gc:_ ?gc:_
@ -186,11 +195,10 @@ let solve
Profile.with_ "proof.to-quip" @@ fun () -> Profile.with_ "proof.to-quip" @@ fun () ->
Proof_quip.of_proof proof ~unsat:unsat_step Proof_quip.of_proof proof ~unsat:unsat_step
in in
Profile.with_ "proof.write-file" Profile.with_ "proof.write-file" @@ fun () ->
(fun () -> with_file_out file @@ fun oc ->
CCIO.with_out file @@ fun oc -> Proof_quip.output oc proof_quip;
Proof_quip.output oc proof_quip; flush oc
flush oc);
end end
| _ -> () | _ -> ()
end; end;