| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
open Coqargs |
| 12 |
open Coqcargs |
| 13 |
open Common_compile |
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
let source ldir file = Loc.InFile { |
| 20 |
dirpath=Some (Names.DirPath.to_string ldir); |
| 21 |
file = file; |
| 22 |
} |
| 23 |
|
| 24 |
|
| 25 |
let compile opts stm_options injections copts ~echo ~f_in ~f_out = |
| 26 |
let open Vernac.State in |
| 27 |
let output_native_objects = match opts.config.native_compiler with |
| 28 |
| NativeOff -> false | NativeOn {ondemand} -> not ondemand |
| 29 |
in |
| 30 |
let mode = copts.compilation_mode in |
| 31 |
let ext_in, ext_out = |
| 32 |
match mode with |
| 33 |
| BuildVo -> ".v", ".vo" |
| 34 |
| BuildVos -> ".v", ".vos" |
| 35 |
| BuildVok -> ".v", ".vok" |
| 36 |
in |
| 37 |
let long_f_dot_in, long_f_dot_out = |
| 38 |
ensure_exists_with_prefix ~src:f_in ~tgt:f_out ~src_ext:ext_in ~tgt_ext:ext_out in |
| 39 |
match mode with |
| 40 |
| BuildVo | BuildVok -> |
| 41 |
let doc, sid = Topfmt.(in_phase ~phase:LoadingPrelude) |
| 42 |
Stm.new_doc |
| 43 |
Stm.{ doc_type = VoDoc long_f_dot_out; injections; } in |
| 44 |
let state = { doc; sid; proof = None; time = Option.map Vernac.make_time_output opts.config.time } in |
| 45 |
let state = Load.load_init_vernaculars opts ~state in |
| 46 |
let ldir = Stm.get_ldir ~doc:state.doc in |
| 47 |
Aux_file.(start_aux_file |
| 48 |
~aux_file:(aux_file_name_for long_f_dot_out) |
| 49 |
~v_file:long_f_dot_in); |
| 50 |
|
| 51 |
let dump = match copts.glob_out with |
| 52 |
| None -> Dumpglob.MultFiles { vofile = long_f_dot_out; vfile = long_f_dot_in } |
| 53 |
| Some NoGlob -> Dumpglob.NoGlob |
| 54 |
| Some (GlobFile f) -> Dumpglob.File f |
| 55 |
in |
| 56 |
Dumpglob.push_output dump; |
| 57 |
Dumpglob.dump_string ("F" ^ Names.DirPath.to_string ldir ^ "\n"); |
| 58 |
|
| 59 |
let wall_clock1 = Unix.gettimeofday () in |
| 60 |
let check = Stm.AsyncOpts.(stm_options.async_proofs_mode = APoff) in |
| 61 |
let source = source ldir long_f_dot_in in |
| 62 |
let state = Vernac.load_vernac ~echo ~check ~state ~source long_f_dot_in in |
| 63 |
let fullstate = Stm.finish ~doc:state.doc in |
| 64 |
ensure_no_pending_proofs ~filename:long_f_dot_in fullstate; |
| 65 |
let () = Stm.join ~doc:state.doc in |
| 66 |
let wall_clock2 = Unix.gettimeofday () in |
| 67 |
|
| 68 |
let () = if mode = BuildVo then |
| 69 |
Library.save_library_to ~output_native_objects Library.ProofsTodoNone ldir long_f_dot_out |
| 70 |
in |
| 71 |
let () = Aux_file.record_in_aux_at "vo_compile_time" |
| 72 |
(Printf.sprintf "%.3f" (wall_clock2 -. wall_clock1)) |
| 73 |
in |
| 74 |
let () = Aux_file.stop_aux_file () in |
| 75 |
() |
| 76 |
|
| 77 |
| BuildVos -> |
| 78 |
let doc, sid = Topfmt.(in_phase ~phase:LoadingPrelude) |
| 79 |
Stm.new_doc |
| 80 |
Stm.{ doc_type = VosDoc long_f_dot_out; injections; |
| 81 |
} in |
| 82 |
|
| 83 |
let state = { doc; sid; proof = None; time = Option.map Vernac.make_time_output opts.config.time } in |
| 84 |
let state = Load.load_init_vernaculars opts ~state in |
| 85 |
let ldir = Stm.get_ldir ~doc:state.doc in |
| 86 |
let source = source ldir long_f_dot_in in |
| 87 |
let state = Vernac.load_vernac ~echo ~check:false ~source ~state long_f_dot_in in |
| 88 |
let state = Stm.finish ~doc:state.doc in |
| 89 |
ensure_no_pending_proofs state ~filename:long_f_dot_in; |
| 90 |
let () = Stm.snapshot_vos ~doc ~output_native_objects ldir long_f_dot_out in |
| 91 |
Stm.reset_task_queue (); |
| 92 |
() |
| 93 |
|
| 94 |
let compile opts stm_opts copts injections ~echo ~f_in ~f_out = |
| 95 |
ignore(CoqworkmgrApi.get 1); |
| 96 |
compile opts stm_opts injections copts ~echo ~f_in ~f_out; |
| 97 |
CoqworkmgrApi.giveback 1 |
| 98 |
|
| 99 |
let compile_file opts stm_opts copts injections (f_in, echo) = |
| 100 |
let f_out = copts.compilation_output_name in |
| 101 |
if !Flags.beautify then |
| 102 |
Flags.with_option Flags.beautify_file |
| 103 |
(fun f_in -> compile opts stm_opts copts injections ~echo ~f_in ~f_out) f_in |
| 104 |
else |
| 105 |
compile opts stm_opts copts injections ~echo ~f_in ~f_out |
| 106 |
|
| 107 |
let compile_file opts stm_opts copts injections = |
| 108 |
Option.iter (compile_file opts stm_opts copts injections) copts.compile_file |