diff options
author | Carst Tankink <carst.tankink@inria.fr> | 2014-10-09 15:39:08 +0200 |
---|---|---|
committer | Enrico Tassi <Enrico.Tassi@inria.fr> | 2014-10-13 18:13:21 +0200 |
commit | 0253fc47be156d0d87cccda32c5bb90bc37960da (patch) | |
tree | f5eac948b0a6eddceef5403185e5fb9760b8e628 /library/library.ml | |
parent | e1ea8a70094dfed28223d02dfca5d768737d4421 (diff) |
When loading libraries, feed back dependencies.
These dependencies between files can be used by UIs to guide compilation
and reloading of files.
FileDependency (Some "/foo.v", "/bar.v") means foo depends on bar.
FileDependency (None, "/bar.v") means the current file depends on bar.
Diffstat (limited to 'library/library.ml')
-rw-r--r-- | library/library.ml | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/library/library.ml b/library/library.ml index ceadb3ace..97c416556 100644 --- a/library/library.ml +++ b/library/library.ml @@ -402,7 +402,11 @@ let intern_from_file f = module DPMap = Map.Make(DirPath) -let rec intern_library (needed, contents) (dir, f) = +let deps_to_string deps = + Array.fold_left (fun s (n, _) -> s^"\n - "^(DirPath.to_string n)) "" deps + +let rec intern_library (needed, contents) (dir, f) from = + Pp.feedback(Feedback.FileDependency (from, f)); (* Look if in the current logical environment *) try find_library dir, (needed, contents) with Not_found -> @@ -417,14 +421,14 @@ let rec intern_library (needed, contents) (dir, f) = pr_dirpath m.library_name ++ spc () ++ str "and not library" ++ spc() ++ pr_dirpath dir); Pp.feedback(Feedback.FileLoaded(DirPath.to_string dir, f)); - m, intern_library_deps (needed, contents) dir m + m, intern_library_deps (needed, contents) dir m (Some f) -and intern_library_deps libs dir m = - let needed, contents = Array.fold_left (intern_mandatory_library dir) libs m.library_deps in +and intern_library_deps libs dir m from = + let needed, contents = Array.fold_left (intern_mandatory_library dir from) libs m.library_deps in (dir :: needed, DPMap.add dir m contents ) -and intern_mandatory_library caller libs (dir,d) = - let m, libs = intern_library libs (try_locate_absolute_library dir) in +and intern_mandatory_library caller from libs (dir,d) = + let m, libs = intern_library libs (try_locate_absolute_library dir) from in if not (Safe_typing.digest_match ~actual:m.library_digests ~required:d) then errorlabstrm "" (strbrk ("Compiled library "^ DirPath.to_string caller ^ ".vo makes inconsistent assumptions over library " ^ @@ -432,7 +436,7 @@ and intern_mandatory_library caller libs (dir,d) = libs let rec_intern_library libs mref = - let _, libs = intern_library libs mref in + let _, libs = intern_library libs mref None in libs let check_library_short_name f dir = function @@ -458,7 +462,7 @@ let rec_intern_by_filename_only id f = m.library_name, [] end else - let needed, contents = intern_library_deps ([], DPMap.empty) m.library_name m in + let needed, contents = intern_library_deps ([], DPMap.empty) m.library_name m (Some f) in let needed = List.map (fun dir -> dir, DPMap.find dir contents) needed in m.library_name, needed |