2017-10-09 12:55:12 +04:00
|
|
|
(**************************************************************************)
|
|
|
|
(* *)
|
|
|
|
(* Copyright (c) 2014 - 2016. *)
|
|
|
|
(* Dynamic Ledger Solutions, Inc. <contact@tezos.com> *)
|
|
|
|
(* *)
|
|
|
|
(* All rights reserved. No warranty, explicit or implicit, provided. *)
|
|
|
|
(* *)
|
|
|
|
(**************************************************************************)
|
|
|
|
|
|
|
|
let dump_file oc file =
|
|
|
|
let ic = open_in file in
|
|
|
|
let buflen = 8096 in
|
|
|
|
let buf = Bytes.create buflen in
|
|
|
|
let rec loop () =
|
|
|
|
let len = input ic buf 0 buflen in
|
|
|
|
if len <> 0 then begin
|
2017-11-13 17:29:28 +04:00
|
|
|
Printf.fprintf oc "%s" (Bytes.to_string (if len = buflen then buf else Bytes.sub buf 0 len)) ;
|
2017-10-09 12:55:12 +04:00
|
|
|
loop ()
|
|
|
|
end
|
|
|
|
in
|
|
|
|
loop () ;
|
|
|
|
close_in ic
|
|
|
|
|
|
|
|
let opened_modules = [
|
|
|
|
"Pervasives" ;
|
|
|
|
"Error_monad" ;
|
|
|
|
"Hash" ;
|
|
|
|
"Tezos_data" ;
|
|
|
|
]
|
|
|
|
|
|
|
|
let include_mli oc file =
|
|
|
|
let unit =
|
|
|
|
String.capitalize_ascii
|
|
|
|
(Filename.chop_extension (Filename.basename file)) in
|
2017-11-13 17:29:28 +04:00
|
|
|
Printf.fprintf oc "module %s : sig\n" unit ;
|
|
|
|
Printf.fprintf oc "# 1 %S\n" file ;
|
|
|
|
dump_file oc file ;
|
|
|
|
Printf.fprintf oc "end\n" ;
|
2017-10-09 12:55:12 +04:00
|
|
|
if unit = "Result" then
|
2017-11-13 17:29:28 +04:00
|
|
|
Printf.fprintf oc
|
2017-10-09 12:55:12 +04:00
|
|
|
"type ('a, 'b) result = ('a, 'b) Result.result = \
|
|
|
|
\ Ok of 'a | Error of 'b\n" ;
|
2017-11-13 17:29:28 +04:00
|
|
|
if List.mem unit opened_modules then Printf.fprintf oc "open %s\n" unit
|
2017-10-09 12:55:12 +04:00
|
|
|
|
|
|
|
let () =
|
|
|
|
Printf.fprintf stdout "module type T = sig\n" ;
|
|
|
|
for i = 1 to Array.length Sys.argv - 1 do
|
|
|
|
let file = Sys.argv.(i) in
|
|
|
|
include_mli stdout file ;
|
|
|
|
done ;
|
|
|
|
Printf.fprintf stdout "end\n%!"
|