Minimize use of Lib_name.of_local
Signed-off-by: Rudi Grinberg <rudi.grinberg@gmail.com>
This commit is contained in:
parent
071c2377de
commit
52238a35f0
|
@ -188,7 +188,7 @@ include Sub_system.Register_end_point(
|
|||
Result.List.concat_map backends
|
||||
~f:(fun (backend : Backend.t) -> backend.runner_libraries)
|
||||
>>= fun libs ->
|
||||
Lib.DB.find_many (Scope.libs scope) [Lib_name.of_local lib.name]
|
||||
Lib.DB.find_many (Scope.libs scope) [Dune_file.Library.best_name lib]
|
||||
>>= fun lib ->
|
||||
Result.List.all
|
||||
(List.map info.libraries
|
||||
|
|
|
@ -954,11 +954,11 @@ module DB = struct
|
|||
let info = Info.of_library_stanza ~dir ~ext_lib conf in
|
||||
match conf.public with
|
||||
| None ->
|
||||
[Lib_name.of_local conf.name, Resolve_result.Found info]
|
||||
[Dune_file.Library.best_name conf, Resolve_result.Found info]
|
||||
| Some p ->
|
||||
let name = Dune_file.Public_lib.name p in
|
||||
if name = Lib_name.of_local conf.name then
|
||||
[(name, Found info)]
|
||||
[name, Found info]
|
||||
else
|
||||
[ name , Found info
|
||||
; Lib_name.of_local conf.name, Redirect (None, name)
|
||||
|
@ -1032,10 +1032,10 @@ module DB = struct
|
|||
let available t name = available_internal t name ~stack:Dep_stack.empty
|
||||
|
||||
let get_compile_info t ?(allow_overlaps=false) name =
|
||||
match find_even_when_hidden t (Lib_name.of_local name) with
|
||||
match find_even_when_hidden t name with
|
||||
| None ->
|
||||
Exn.code_error "Lib.DB.get_compile_info got library that doesn't exist"
|
||||
[ "name", Lib_name.Local.to_sexp name ]
|
||||
[ "name", Lib_name.to_sexp name ]
|
||||
| Some lib ->
|
||||
let t = Option.some_if (not allow_overlaps) t in
|
||||
Compile.for_lib t lib
|
||||
|
|
|
@ -284,8 +284,7 @@ module DB : sig
|
|||
|
||||
(** Retrieve the compile information for the given library. Works
|
||||
for libraries that are optional and not available as well. *)
|
||||
val get_compile_info
|
||||
: t -> ?allow_overlaps:bool -> Lib_name.Local.t -> Compile.t
|
||||
val get_compile_info : t -> ?allow_overlaps:bool -> Lib_name.t -> Compile.t
|
||||
|
||||
val resolve : t -> Loc.t * Lib_name.t -> lib Or_exn.t
|
||||
|
||||
|
|
|
@ -422,7 +422,7 @@ module Gen (P : Install_rules.Params) = struct
|
|||
let rules (lib : Library.t) ~dir_contents ~dir ~scope
|
||||
~dir_kind : Compilation_context.t * Merlin.t =
|
||||
let compile_info =
|
||||
Lib.DB.get_compile_info (Scope.libs scope) lib.name
|
||||
Lib.DB.get_compile_info (Scope.libs scope) (Library.best_name lib)
|
||||
~allow_overlaps:lib.buildable.allow_overlapping_dependencies
|
||||
in
|
||||
SC.Libs.gen_select_rules sctx compile_info ~dir;
|
||||
|
|
|
@ -197,7 +197,7 @@ module Gen (S : sig val sctx : SC.t end) = struct
|
|||
~requires ~(dep_graphs:Ocamldep.Dep_graph.t Ml_kind.Dict.t) =
|
||||
let lib =
|
||||
Option.value_exn (Lib.DB.find_even_when_hidden (Scope.libs scope)
|
||||
(Lib_name.of_local library.name)) in
|
||||
(Library.best_name library)) in
|
||||
(* Using the proper package name doesn't actually work since odoc assumes
|
||||
that a package contains only 1 library *)
|
||||
let pkg_or_lnu = pkg_or_lnu lib in
|
||||
|
@ -517,7 +517,7 @@ module Gen (S : sig val sctx : SC.t end) = struct
|
|||
let scope = SC.find_scope_by_dir sctx w.ctx_dir in
|
||||
Some (Option.value_exn (
|
||||
Lib.DB.find_even_when_hidden (Scope.libs scope)
|
||||
(Lib_name.of_local l.name))
|
||||
(Library.best_name l))
|
||||
)
|
||||
end
|
||||
| _ -> None
|
||||
|
|
|
@ -541,7 +541,7 @@ let create
|
|||
let keep =
|
||||
match (stanza : Stanza.t) with
|
||||
| Library lib ->
|
||||
Lib.DB.available (Scope.libs scope) (Lib_name.of_local lib.name)
|
||||
Lib.DB.available (Scope.libs scope) (Library.best_name lib)
|
||||
| Documentation _
|
||||
| Install _ -> true
|
||||
| _ -> false
|
||||
|
|
|
@ -65,9 +65,7 @@ let setup sctx ~dir ~(libs : Library.t list) ~scope =
|
|||
let requires =
|
||||
let open Result.O in
|
||||
Lib.DB.find_many (Scope.libs scope)
|
||||
(Lib_name.of_string_exn "utop"
|
||||
:: List.map libs ~f:(fun (lib : Library.t) ->
|
||||
Lib_name.of_local lib.name))
|
||||
(Lib_name.of_string_exn "utop" :: List.map libs ~f:Library.best_name)
|
||||
>>= Lib.closure
|
||||
in
|
||||
let cctx =
|
||||
|
|
Loading…
Reference in New Issue