module TA = TacticAst module U = UriManager let deps = Hashtbl.create (Array.length Sys.argv) let baseuri = ref [] let aliases = Hashtbl.create (Array.length Sys.argv) (* let uri_of_alias = function | Ident_alias (_, uri) | Symbol_alias (_, _, uri) | Number_alias (_, uri) -> uri *) let buri alias = U.buri_of_uri (U.uri_of_string alias) let resolve alias = try Some (snd(List.find (fun (u, f) -> u = (buri alias)) !baseuri)) with | Not_found -> None (*** TODO MANCANO LE URI VERBATIM DENTRO GLI AST DEI TERMINI ****) let main () = for i = 1 to Array.length Sys.argv - 1 do let file = Sys.argv.(i) in let ic = open_in file in let stms = CicTextualParser2.parse_statements (Stream.of_channel ic) in close_in ic; let stms = List.iter (function | TA.Executable (_, TA.Command (_, TA.Set (_, "baseuri", uri))) -> let uri = MatitaMisc.strip_trailing_slash uri in baseuri := (uri, file) :: !baseuri | TA.Executable (_, TA.Command (_, TA.Alias (_, TA.Ident_alias(_, uri)))) -> Hashtbl.add aliases file uri | _ -> ()) stms in Hashtbl.iter (fun file alias -> let dep = resolve alias in match dep with | None -> () | Some d -> Hashtbl.add deps file d) aliases; done; for i = 1 to Array.length Sys.argv - 1 do let file = Sys.argv.(i) in let deps = Hashtbl.find_all deps file in let deps = List.fast_sort Pervasives.compare deps in let deps = MatitaMisc.list_uniq deps in let deps = file :: deps in Printf.printf "%s: %s\n" (MatitaMisc.obj_file_of_script file) (String.concat " " deps) done let _ = main ()