let build_why_file basename preludes p =
let preludes = match preludes with
| [] -> []
| _ ->
let frama_c_whylib =
String.escaped (Filename.concat Config.datadir "why") in
let dir_ok dirname =
try let d = Unix.opendir dirname in Unix.closedir d; true
with Unix.Unix_error (Unix.ENOENT, "opendir",_) -> false
in
if dir_ok frama_c_whylib then
List.map (fun f -> Filename.concat frama_c_whylib f) preludes
else
(Wp_parameters.warning "Could not find 'why' library in %s.@."
frama_c_whylib;
preludes)
in
begin
begin try ignore (Macros.get_env "WHYLIB") with Not_found -> () end;
let why_file = Filename.temp_file basename ".why" in
output preludes ~file:why_file p;
why_file
end