X-Git-Url: http://matita.cs.unibo.it/gitweb/?a=blobdiff_plain;f=helm%2Fmatita%2Fmatitaclean.ml;h=5aabf7558dab32467027798a40446199f0fc3646;hb=4167cea65ca58897d1a3dbb81ff95de5074700cc;hp=c7bbdf453a3f8e989a67bacc26a48be1b195a19e;hpb=828cc3e65c2a6387752f68afc716ff96b790c3eb;p=helm.git diff --git a/helm/matita/matitaclean.ml b/helm/matita/matitaclean.ml index c7bbdf453..5aabf7558 100644 --- a/helm/matita/matitaclean.ml +++ b/helm/matita/matitaclean.ml @@ -23,66 +23,48 @@ * http://helm.cs.unibo.it/ *) -module UM = UriManager;; -module TA = GrafiteAst;; +open Printf -let _ = - Helm_registry.load_from BuildTimeConf.matita_conf; - CicNotation.load_notation BuildTimeConf.core_notation_script; - Http_getter.init (); - MetadataTypes.ownerize_tables (Helm_registry.get "matita.owner"); - MatitaDb.create_owner_environment () +module UM = UriManager +module TA = GrafiteAst -let main uri_to_remove = MatitacleanLib.clean_baseuris uri_to_remove - -let usage () = - prerr_endline ""; - prerr_endline "usage:"; - prerr_endline "\tmatitaclean all"; - prerr_endline "\t\tcleans the whole environment"; - prerr_endline "\tmatitaclean files..."; - prerr_endline "\t\tcleans the output of the compilation of files...\n"; - prerr_endline ""; - exit 1 - -let _ = - if Array.length Sys.argv < 2 then usage (); - if Sys.argv.(1) = "all" then - begin +let main () = + let _ = MatitaInit.initialize_all () in + let uris_to_remove = ref [] in + let files_to_remove = ref [] in + (match Helm_registry.get_list Helm_registry.string "matita.args" with + | [ "all" ] -> MatitaDb.clean_owner_environment (); let xmldir = Helm_registry.get "matita.basedir" ^ "/xml" in ignore (Sys.command ("find " ^ xmldir ^ - " -name *.xml.gz -o -name *.moo -exec rm {} \\; 2> /dev/null")); - ignore (Sys.command ("find " ^ xmldir ^ " -type d -exec rmdir -p {} \\; 2> /dev/null")); + " \\( -name \\*.xml.gz -o -name \\*.moo \\) " ^ + "-exec rm \\{\\} \\; 2> /dev/null")); + ignore + (Sys.command ("find " ^ xmldir ^ + " -type d -exec rmdir -p {} \\; 2> /dev/null")); exit 0 - end - let uris_to_remove =ref [] in - let files_to_remove =ref [] in - (try - for i = 1 to Array.length Sys.argv - 1 do - let suri = Sys.argv.(i) in - let uri = - try - UM.buri_of_uri (UM.uri_of_string suri) - with - UM.IllFormedUri _ -> - files_to_remove := suri :: !files_to_remove; - let u = MatitaMisc.baseuri_of_file suri in - if String.length u < 5 || String.sub u 0 5 <> "cic:/" then - begin - MatitaLog.error ("File " ^ suri ^ " defines a bad baseuri: "^u); - exit 1 - end - else - u - in - uris_to_remove := uri :: !uris_to_remove - done - with - Invalid_argument _ -> usage ()); - main !uris_to_remove; - let moos = List.map MatitaMisc.obj_file_of_script !files_to_remove in + | [] -> MatitaInit.die_usage () + | files -> + List.iter + (fun suri -> + let uri = + try + UM.buri_of_uri (UM.uri_of_string suri) + with UM.IllFormedUri _ -> + files_to_remove := suri :: !files_to_remove; + let u = MatitacleanLib.baseuri_of_file suri in + if String.length u < 5 || String.sub u 0 5 <> "cic:/" then begin + MatitaLog.error (sprintf "File %s defines a bad baseuri: %s" + suri u); + exit 1 + end else + u + in + uris_to_remove := uri :: !uris_to_remove) + files); + MatitacleanLib.clean_baseuris !uris_to_remove; + let moos = List.map MatitacleanLib.obj_file_of_script !files_to_remove in List.iter MatitaMisc.safe_remove moos