1 (***********************************************************************)
5 (* Xavier Leroy, projet Cristal, INRIA Rocquencourt *)
7 (* Copyright 1996 Institut National de Recherche en Informatique et *)
8 (* en Automatique. All rights reserved. This file is distributed *)
9 (* under the terms of the GNU Library General Public License, with *)
10 (* the special exception on linking described in file ../../LICENSE. *)
12 (***********************************************************************)
14 (* $Id: extract_crc.ml 6195 2004-04-09 13:26:41Z xleroy $ *)
16 (* Print the digests of unit interfaces *)
18 let load_path = ref []
23 let crc = Dynlink.digest_interface unit (!load_path @ ["."]) in
24 if !first then first := false else print_string ";\n";
25 print_string " \""; print_string (String.capitalize unit);
26 print_string "\",\n \"";
27 for i = 0 to String.length crc - 1 do
28 Printf.printf "\\%03d" (Char.code crc.[i])
32 prerr_string "Error while reading the interface for ";
35 Sys_error msg -> prerr_endline msg
36 | Dynlink.Error(Dynlink.File_not_found name) ->
37 prerr_string "Cannot find file "; prerr_endline name
38 | Dynlink.Error _ -> prerr_endline "Ill-formed .cmi file"
43 let usage = "Usage: extract_crc [-I <dir>] <files>"
46 print_string "let crc_unit_list = [\n";
48 ["-I", Arg.String(fun dir -> load_path := !load_path @ [dir]),
49 "<dir> Add <dir> to the list of include directories"]
53 let _ = main(); exit 0