From: Claudio Sacerdoti Coen Date: Fri, 19 Jun 2009 12:42:05 +0000 (+0000) Subject: NG decompilation is now activated. However, it is called from the old X-Git-Tag: make_still_working~3838 X-Git-Url: http://matita.cs.unibo.it/gitweb/?a=commitdiff_plain;h=bd3680d6b90f6c8bdda4eb4a915a86a0e806de63;p=helm.git NG decompilation is now activated. However, it is called from the old decompilation that cannot detect when a NG-only file A is used by another NG-only file B. As a consequence, decompiling A does not decompile B too. --- diff --git a/helm/software/components/library/libraryClean.ml b/helm/software/components/library/libraryClean.ml index 9a3b17245..8e9f430ba 100644 --- a/helm/software/components/library/libraryClean.ml +++ b/helm/software/components/library/libraryClean.ml @@ -34,6 +34,8 @@ module HGT = Http_getter_types;; module HG = Http_getter;; module UM = UriManager;; +let decompile = ref (fun ~baseuri -> assert false);; +let set_decompile_cb f = decompile := f;; let strip_xpointer s = Pcre.replace ~pat:"#.*$" s ;; @@ -230,6 +232,7 @@ let clean_baseuris ?(verbose=true) buris = List.iter (fun u -> debug_prerr (UriManager.string_of_uri u)) l; List.iter (fun baseuri -> + !decompile ~baseuri; try let obj_file = LibraryMisc.obj_file_of_baseuri ~must_exist:false ~writable:true ~baseuri diff --git a/helm/software/components/library/libraryClean.mli b/helm/software/components/library/libraryClean.mli index 4d65cfe38..89f3b7b1d 100644 --- a/helm/software/components/library/libraryClean.mli +++ b/helm/software/components/library/libraryClean.mli @@ -23,5 +23,7 @@ * http://helm.cs.unibo.it/ *) +val set_decompile_cb: (baseuri: string -> unit) -> unit + val db_uris_of_baseuri : string -> string list val clean_baseuris : ?verbose:bool -> string list -> unit diff --git a/helm/software/components/ng_kernel/nCicLibrary.ml b/helm/software/components/ng_kernel/nCicLibrary.ml index 47c8d67c6..18b7903e5 100644 --- a/helm/software/components/ng_kernel/nCicLibrary.ml +++ b/helm/software/components/ng_kernel/nCicLibrary.ml @@ -38,13 +38,16 @@ let time_travel status = storage := sto; aliases := ali; cache := cac ;; -let path_of_baseuri baseuri = +let path_of_baseuri ?(no_suffix=false) baseuri = let uri = NUri.string_of_uri baseuri in let path = String.sub uri 4 (String.length uri - 4) in let path = Helm_registry.get "matita.basedir" ^ path in let dirname = Filename.dirname path in HExtlib.mkdir dirname; - path ^ ".ng" + if no_suffix then + path + else + path ^ ".ng" ;; let magic = 0;; @@ -127,10 +130,27 @@ module Serializer(S: sig type status end) = end let decompile ~baseuri = - Unix.unlink (path_of_baseuri baseuri) - (* WE ARE NOT REMOVING ALL THE OBJECTS YET! *) + HExtlib.safe_remove (path_of_baseuri baseuri); + let basepath = path_of_baseuri ~no_suffix:true baseuri in + try + let od = Unix.opendir basepath in + let rec aux names = + try + let name = Unix.readdir od in + if name <> "." && name <> ".." then aux (name::names) else aux names + with + End_of_file -> names in + let names = List.map (fun name -> basepath ^ "/" ^ name) (aux []) in + Unix.closedir od; + List.iter Unix.unlink names; + HExtlib.rmdir_descend basepath + with + Unix.Unix_error _ -> () (* raised by Unix.opendir, we hope :-) *) ;; +LibraryClean.set_decompile_cb + (fun ~baseuri -> decompile ~baseuri:(NUri.uri_of_string baseuri));; + let fetch_obj uri = let obj = require0 ~baseuri:uri in refresh_uri_in_obj obj