From 0873ae2b10e0f593b7cdf98650a8970ca047079a Mon Sep 17 00:00:00 2001 From: Rudi Grinberg Date: Sat, 10 Feb 2018 22:38:28 +0800 Subject: [PATCH] Remove primed Lib_db.find_scope (#505) Two versions aren't really necessary as mostly the primed version was used. --- src/gen_rules.ml | 4 ++-- src/lib_db.ml | 11 +++++------ src/lib_db.mli | 3 +-- src/super_context.ml | 4 ++-- 4 files changed, 10 insertions(+), 12 deletions(-) diff --git a/src/gen_rules.ml b/src/gen_rules.ml index 3584172b..4cb7f90d 100644 --- a/src/gen_rules.ml +++ b/src/gen_rules.ml @@ -959,7 +959,7 @@ module Gen(P : Params) = struct in let meta_contents = version >>^ fun version -> - let scope = Lib_db.find_scope (SC.libs sctx) ~dir:path in + let scope = (Lib_db.find_scope (SC.libs sctx) ~dir:path).data in Gen_meta.gen ~package:pkg.name ~scope ~version @@ -1049,7 +1049,7 @@ module Gen(P : Params) = struct else pps in - let scope = Lib_db.find_scope' (SC.libs sctx) ~dir in + let scope = Lib_db.find_scope (SC.libs sctx) ~dir in let ppx_exe = SC.PP.get_ppx_driver sctx ~scope pps in [ppx_exe] in diff --git a/src/lib_db.ml b/src/lib_db.ml index d3cec8af..737fd1f4 100644 --- a/src/lib_db.ml +++ b/src/lib_db.ml @@ -163,7 +163,7 @@ module Scope = struct ; scope = internal_name_scope t ~dir } - let find_scope' t ~dir = + let find_scope t ~dir = let scope = find_scope t ~dir in required_in_jbuild scope ~jbuild_dir:dir @@ -190,7 +190,7 @@ module Scope = struct let acc = f lib acc in match lib with | Internal (dir, lib) -> - let scope = find_scope' scope.With_required_by.data.lib_db ~dir in + let scope = find_scope scope.With_required_by.data.lib_db ~dir in List.fold_left lib.buildable.libraries ~init:acc ~f:(loop scope) | External pkg -> if deep_traverse_externals then @@ -215,7 +215,7 @@ module Scope = struct let rt_deps = match lib with | Internal (dir, lib) -> - let scope = lazy (find_scope' scope.data.lib_db ~dir) in + let scope = lazy (find_scope scope.data.lib_db ~dir) in List.map lib.ppx_runtime_libraries ~f:(fun name -> Lib.best_name (find_exn (Lazy.force scope) name)) | External pkg -> @@ -225,7 +225,6 @@ module Scope = struct end let find_scope = Scope.find_scope -let find_scope' = Scope.find_scope' let local_public_libs t = t.local_public_libs @@ -234,7 +233,7 @@ module Local_closure = Top_closure.Make(String)(struct type t = Lib.Internal.t let key ((_, lib) : t) = lib.name let deps ((dir, lib) : Lib.Internal.t) graph = - let scope = find_scope' graph ~dir in + let scope = find_scope graph ~dir in List.concat_map lib.buildable.libraries ~f:(fun dep -> List.filter_map (Lib_dep.to_lib_names dep) ~f:(Scope.find_internal scope)) @ List.filter_map lib.ppx_runtime_libraries ~f:(fun dep -> @@ -252,7 +251,7 @@ let top_sort_internals t ~internal_libraries = let compute_instalable_internal_libs t ~internal_libraries = List.fold_left (top_sort_internals t ~internal_libraries) ~init:t ~f:(fun t (dir, lib) -> - let scope = find_scope' t ~dir in + let scope = find_scope t ~dir in if not lib.Library.optional || (List.for_all (Library.all_lib_deps lib) ~f:(Scope.dep_is_available scope) && List.for_all lib.ppx_runtime_libraries ~f:(Scope.lib_is_available scope)) diff --git a/src/lib_db.mli b/src/lib_db.mli index ecf2d6e5..9768bd43 100644 --- a/src/lib_db.mli +++ b/src/lib_db.mli @@ -74,8 +74,7 @@ val local_public_libs : t -> Path.t String_map.t (** Unique name, even for internal libraries *) val unique_library_name : t -> Lib.t -> string -val find_scope : t -> dir:Path.t -> Scope.t -val find_scope' : t -> dir:Path.t -> Scope.t With_required_by.t +val find_scope : t -> dir:Path.t -> Scope.t With_required_by.t (** Includes the private libraries not belonging to any named scope. Corresopnds to the context's build root path.*) diff --git a/src/super_context.ml b/src/super_context.ml index 8087717a..093fbb8c 100644 --- a/src/super_context.ml +++ b/src/super_context.ml @@ -94,7 +94,7 @@ let create src_dir = dir ; ctx_dir ; stanzas - ; scope = Lib_db.find_scope' libs ~dir:ctx_dir + ; scope = Lib_db.find_scope libs ~dir:ctx_dir }) in let stanzas_to_consider_for_install = @@ -120,7 +120,7 @@ let create (struct open Sexp.Of_sexp let t dir sexp = - let scope = Lib_db.find_scope' libs ~dir in + let scope = Lib_db.find_scope libs ~dir in List.map (list string sexp) ~f:(Lib_db.Scope.find_exn scope) end) in