From ab18b13a0406b92351cb8b5bba6ef2c1fa93d343 Mon Sep 17 00:00:00 2001 From: Rudi Grinberg Date: Wed, 24 Jan 2018 16:32:10 +0800 Subject: [PATCH] Fix META generation wrt scope We should respect the scope of the current internal library to generate the META --- src/lib_db.ml | 8 +++--- .../blackbox-tests/test-cases/scope-bug/run.t | 26 ++++++++++++++++--- 2 files changed, 26 insertions(+), 8 deletions(-) diff --git a/src/lib_db.ml b/src/lib_db.ml index a192ebd4..be534bd0 100644 --- a/src/lib_db.ml +++ b/src/lib_db.ml @@ -199,7 +199,7 @@ let ppx_runtime_deps_for_deprecated_method_exn t ~dir lib_deps = let lib_is_available name = String_set.mem name !seen || lib_is_available t ~from:dir name in - let rec loop lib_dep = + let rec loop dir lib_dep = match lib_dep with | Lib_dep.Direct name -> if not (String_set.mem name !seen) then begin @@ -227,7 +227,7 @@ let ppx_runtime_deps_for_deprecated_method_exn t ~dir lib_deps = | None -> Loc.fail loc "No solution found for this select form" and process (lib : Lib.t) = match lib with - | Internal (_, lib) -> + | Internal (dir, lib) -> seen := (let set = String_set.add lib.name !seen in match lib.public with @@ -235,14 +235,14 @@ let ppx_runtime_deps_for_deprecated_method_exn t ~dir lib_deps = | Some p -> String_set.add p.name set); result := String_set.union !result (String_set.of_list lib.ppx_runtime_libraries); - List.iter lib.buildable.libraries ~f:loop + List.iter lib.buildable.libraries ~f:(loop dir) | External pkg -> seen := String_set.add pkg.name !seen; result := String_set.union !result (String_set.of_list (List.map pkg.ppx_runtime_deps ~f:(fun p -> p.Findlib.name))) in - List.iter lib_deps ~f:loop; + List.iter lib_deps ~f:(loop dir); !result type resolved_select = diff --git a/test/blackbox-tests/test-cases/scope-bug/run.t b/test/blackbox-tests/test-cases/scope-bug/run.t index 1c3f3e34..3c71f44e 100644 --- a/test/blackbox-tests/test-cases/scope-bug/run.t +++ b/test/blackbox-tests/test-cases/scope-bug/run.t @@ -1,5 +1,23 @@ $ $JBUILDER build -j1 --root . @install - Error: External library "sub" not found. - -> required by "alib/jbuild (context default)" - Hint: try: jbuilder external-lib-deps --missing --root . @install - [1] + ocamldep alib/alib.depends.ocamldep-output + ocamlc alib/alib__.{cmi,cmo,cmt} + ocamldep blib/blib.depends.ocamldep-output + ocamldep blib/sub/sub.depends.ocamldep-output + ocamlopt alib/alib__.{cmx,o} + ocamlc blib/sub/sub.{cmi,cmo,cmt} + ocamlopt blib/sub/sub.{cmx,o} + ocamlc blib/blib.{cmi,cmo,cmt} + ocamlc blib/sub/sub.cma + ocamlopt blib/sub/sub.{a,cmxa} + ocamlopt blib/blib.{cmx,o} + ocamlc alib/alib.{cmi,cmo,cmt} + ocamlc alib/alib__Main.{cmi,cmo,cmt} + ocamlc blib/blib.cma + ocamlopt blib/sub/sub.cmxs + ocamlopt blib/blib.{a,cmxa} + ocamlopt alib/alib.{cmx,o} + ocamlopt alib/alib__Main.{cmx,o} + ocamlc alib/alib.cma + ocamlopt blib/blib.cmxs + ocamlopt alib/alib.{a,cmxa} + ocamlopt alib/alib.cmxs