|
|
|
@ -12,32 +12,6 @@ open PolyVariantEqual
|
|
|
|
|
|
|
|
|
|
type zip_library = {zip_filename: string; zip_channel: Zip.in_file Lazy.t}
|
|
|
|
|
|
|
|
|
|
let get_cache_dir infer_cache zip_filename =
|
|
|
|
|
let basename = Filename.basename zip_filename in
|
|
|
|
|
let key = basename ^ Utils.string_crc_hex32 zip_filename in
|
|
|
|
|
Filename.concat infer_cache key
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let load_from_cache serializer zip_path cache_dir zip_library =
|
|
|
|
|
let absolute_path = Filename.concat cache_dir zip_path in
|
|
|
|
|
let deserialize = Serialization.read_from_file serializer in
|
|
|
|
|
let extract to_path =
|
|
|
|
|
if Sys.file_exists to_path <> `Yes then (
|
|
|
|
|
Unix.mkdir_p (Filename.dirname to_path) ;
|
|
|
|
|
let lazy zip_channel = zip_library.zip_channel in
|
|
|
|
|
let entry = Zip.find_entry zip_channel zip_path in
|
|
|
|
|
Zip.copy_entry_to_file zip_channel entry to_path ) ;
|
|
|
|
|
DB.filename_from_string to_path
|
|
|
|
|
in
|
|
|
|
|
match deserialize (extract absolute_path) with
|
|
|
|
|
| Some _ as data ->
|
|
|
|
|
data
|
|
|
|
|
| None ->
|
|
|
|
|
None
|
|
|
|
|
| exception Caml.Not_found ->
|
|
|
|
|
None
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let load_from_zip serializer zip_path zip_library =
|
|
|
|
|
let lazy zip_channel = zip_library.zip_channel in
|
|
|
|
|
let deserialize = Serialization.read_from_string serializer in
|
|
|
|
@ -52,12 +26,7 @@ let load_from_zip serializer zip_path zip_library =
|
|
|
|
|
|
|
|
|
|
let load_data serializer path zip_library =
|
|
|
|
|
let zip_path = Filename.concat Config.default_in_zip_results_dir path in
|
|
|
|
|
match Config.infer_cache with
|
|
|
|
|
| None ->
|
|
|
|
|
load_from_zip serializer zip_path zip_library
|
|
|
|
|
| Some infer_cache ->
|
|
|
|
|
let cache_dir = get_cache_dir infer_cache zip_library.zip_filename in
|
|
|
|
|
load_from_cache serializer zip_path cache_dir zip_library
|
|
|
|
|
load_from_zip serializer zip_path zip_library
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(** list of the zip files to search for specs files *)
|
|
|
|
@ -66,19 +35,17 @@ let zip_libraries =
|
|
|
|
|
lazy
|
|
|
|
|
(let mk_zip_lib zip_filename = {zip_filename; zip_channel= lazy (Zip.open_in zip_filename)} in
|
|
|
|
|
let zip_libs =
|
|
|
|
|
if Config.use_jar_cache && Option.is_some Config.infer_cache then []
|
|
|
|
|
else
|
|
|
|
|
let load_zip fname =
|
|
|
|
|
if Filename.check_suffix fname ".jar" then
|
|
|
|
|
(* fname is a zip of specs *)
|
|
|
|
|
Some (mk_zip_lib fname)
|
|
|
|
|
else (* fname is a dir of specs *)
|
|
|
|
|
None
|
|
|
|
|
in
|
|
|
|
|
(* Order matters: jar files should appear in the order in which they should be searched for
|
|
|
|
|
let load_zip fname =
|
|
|
|
|
if Filename.check_suffix fname ".jar" then
|
|
|
|
|
(* fname is a zip of specs *)
|
|
|
|
|
Some (mk_zip_lib fname)
|
|
|
|
|
else (* fname is a dir of specs *)
|
|
|
|
|
None
|
|
|
|
|
in
|
|
|
|
|
(* Order matters: jar files should appear in the order in which they should be searched for
|
|
|
|
|
specs files. [Config.specs_library] is in reverse order of appearance on the command
|
|
|
|
|
line. *)
|
|
|
|
|
List.rev_filter_map Config.specs_library ~f:load_zip
|
|
|
|
|
List.rev_filter_map Config.specs_library ~f:load_zip
|
|
|
|
|
in
|
|
|
|
|
if Config.biabduction && not Config.models_mode && Sys.file_exists Config.models_jar = `Yes
|
|
|
|
|
then mk_zip_lib Config.models_jar :: zip_libs
|
|
|
|
|