C build tool of the 21st century
at main 13 lines 524 B view raw
1let with_log_file ?(keep = false) ~build_dir ~name f = 2 let logs_dir = Eio.Path.(build_dir / "logs") in 3 Eio.Path.mkdirs ~exists_ok:true logs_dir ~perm:0o755; 4 let tmp_path = Eio.Path.(logs_dir / name) in 5 Fun.protect ~finally:(fun () -> if not keep then Eio.Path.unlink tmp_path) 6 @@ fun () -> 7 Eio.Path.with_open_out ~create:(`Or_truncate 0o644) tmp_path @@ fun file -> 8 f (tmp_path, file) 9 10let get ?(unlink = false) log_path = 11 let log = Eio.Path.load log_path in 12 if unlink then Eio.Path.unlink log_path; 13 log