Fix #15
When there are no <pkg>.opam files in parent directories, use the whole workspace as scope
This commit is contained in:
parent
df7658914d
commit
dd6a23ec18
|
@ -656,9 +656,9 @@ always prefered to ones that are part of the installed world.
|
|||
|
||||
The scope of internal library names is not the whole workspace. It is
|
||||
restricted to the sub-tree starting from the closest parent containing
|
||||
a =<package>.opam= file. Moreover, a sub-tree containing
|
||||
=<package>.opam= doesn' t inherit the internal names available in its
|
||||
parent scope.
|
||||
a =<package>.opam= file, or the whole workspace if no such directory
|
||||
exist. Moreover, a sub-tree containing =<package>.opam= doesn' t
|
||||
inherit the internal names available in its parent scope.
|
||||
|
||||
The idea behing this rule is that public library names must be
|
||||
universally unique, but internal ones don't need to. In particular you
|
||||
|
|
|
@ -16,6 +16,8 @@ let rec internal_name_scope t ~dir =
|
|||
match Hashtbl.find t.by_internal_name dir with
|
||||
| Some scope -> scope
|
||||
| None ->
|
||||
(* [create] ensures that [Hashtbl.find t.by_internal_name Path.root] is [Some _] so
|
||||
this [Path.parent dir] is never called with [Path.root] *)
|
||||
let scope = internal_name_scope t ~dir:(Path.parent dir) in
|
||||
Hashtbl.add t.by_internal_name ~key:dir ~data:scope;
|
||||
scope
|
||||
|
@ -98,8 +100,9 @@ let create findlib ~dirs_with_dot_opam_files internal_libraries =
|
|||
; instalable_internal_libs = String_map.empty
|
||||
}
|
||||
in
|
||||
(* Initializes the scopes *)
|
||||
Path.Set.iter dirs_with_dot_opam_files ~f:(fun dir ->
|
||||
(* Initializes the scopes, including [Path.root] so that when there are no <pkg>.opam
|
||||
files in parent directories, the scope is the whole workspace. *)
|
||||
Path.Set.iter (Path.add Path.root dirs_with_dot_opam_files) ~f:(fun dir ->
|
||||
Hashtbl.add t.by_internal_name ~key:dir
|
||||
~data:(ref String_map.empty));
|
||||
List.iter internal_libraries ~f:(fun ((dir, lib) as internal) ->
|
||||
|
|
Loading…
Reference in New Issue