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