- let deps = Hashtbl.find_all include_deps ma_file in
- let deps = List.fast_sort Pervasives.compare deps in
- let deps = HExtlib.list_uniq deps in
- let deps = ma_file :: deps in
- let baseuri = Hashtbl.find baseuri_of ma_file in
- let moo = LibraryMisc.obj_file_of_baseuri ~basedir ~baseuri in
- Printf.printf "%s: %s\n" moo (String.concat " " deps);
- Printf.printf "%s: %s\n" (Pcre.replace ~pat:"ma$" ~templ:"mo" ma_file) moo)
- (Helm_registry.get_list Helm_registry.string "matita.args")
+ let ma_baseuri = baseuri_of_script ma_file in
+ let dependencies = DependenciesParser.deps_of_file ma_file in
+ List.iter
+ (function
+ | DependenciesParser.UriDep uri ->
+ let uri = UriManager.string_of_uri uri in
+ if not (Http_getter_storage.is_legacy uri) then
+ let dep = resolve uri ma_baseuri in
+ (match dep with
+ | None -> ()
+ | Some u ->
+ match script_of_baseuri ma_file u with
+ | Some d -> Hashtbl.add include_deps ma_file d
+ | None -> ())
+ | DependenciesParser.IncludeDep path ->
+ ignore (baseuri_of_script path);
+ Hashtbl.add include_deps ma_file path)
+ dependencies)
+ ma_files;
+ (* generate regular depend output *)
+ let deps =
+ List.fold_left
+ (fun acc ma_file ->
+ let deps = Hashtbl.find_all include_deps ma_file in
+ let deps = List.fast_sort Pervasives.compare deps in
+ let deps = HExtlib.list_uniq deps in
+ let deps = List.map fix_name deps in
+ (fix_name ma_file, deps) :: acc)
+ [] ma_files
+ in
+ let extern =
+ List.fold_left
+ (fun acc (_,d) ->
+ List.fold_left
+ (fun a x ->
+ if List.exists (fun (t,_) -> x=t) deps then a
+ else x::a)
+ acc d)
+ [] deps
+ in
+ Librarian.write_deps_file (Sys.getcwd())
+ (deps@HExtlib.list_uniq (List.sort Pervasives.compare (List.map (fun x ->
+ x,[]) extern)));
+ (* dot generation *)
+ if !dot_file <> "" then
+ begin
+ let oc = open_out !dot_file in
+ let fmt = Format.formatter_of_out_channel oc in
+ GraphvizPp.Dot.header fmt;
+ List.iter
+ (fun (ma_file,deps) ->
+ GraphvizPp.Dot.node ma_file fmt;
+ List.iter (fun dep -> GraphvizPp.Dot.edge ma_file dep fmt) deps)
+ deps;
+ List.iter
+ (fun x -> GraphvizPp.Dot.node ~attrs:["style","dashed"] x fmt)
+ extern;
+ GraphvizPp.Dot.trailer fmt;
+ close_out oc;
+ ignore(Sys.command ("tred "^ !dot_file^"| dot -Tpng -o"^dot_name^".png"));
+ HLog.message ("Type 'eog "^dot_name^".png' to view the graph");
+ end;
+;;