- ["-dot",Arg.Unit (fun () -> do_dot:=true),
- "Generate deps for dot instead of make"];
- MatitaInit.parse_cmdline ();
- MatitaInit.load_configuration_file ();
- let include_paths =
- Helm_registry.get_list Helm_registry.string "matita.includes" in
- let args = Helm_registry.get_list Helm_registry.string "matita.args" in
- if args = [] then
- begin
- prerr_endline "At least one .ma file must be specified";
- exit 1
- end;
+ ["-dot", Arg.Unit set_dot_file,
+ "Save dependency graph in dot format and generate a png";];
+ MatitaInit.parse_cmdline_and_configuration_file ();
+ MatitaInit.initialize_environment ();
+ let args =
+ let roots = Librarian.find_roots_in_dir (Sys.getcwd ()) in
+ match roots with
+ | [] ->
+ prerr_endline ("No roots found in " ^ Sys.getcwd ());
+ exit 1
+ | [x] ->
+ Sys.chdir (Filename.dirname x);
+ let opts = Librarian.load_root_file "root" in
+ include_paths :=
+ (try Str.split (Str.regexp " ") (List.assoc "include_paths" opts)
+ with Not_found -> []) @
+ (Helm_registry.get_list Helm_registry.string "matita.includes");
+ HExtlib.find ~test:(fun x -> Filename.check_suffix x ".ma") "."
+ | _ ->
+ let roots = List.map (HExtlib.chop_prefix (Sys.getcwd()^"/")) roots in
+ prerr_endline ("Too many roots found:\n\t"^String.concat "\n\t" roots);
+ prerr_endline ("\nEnter one of these directories and retry");
+ exit 1
+ in
+ let fix_name f =
+ let f =
+ if Pcre.pmatch ~pat:"^\\./" f then String.sub f 2 (String.length f - 2)
+ else f
+ in
+ HExtlib.normalize_path f
+ in