From d9fd758ee98c371d5a9bd867fd8b35e5da92ac06 Mon Sep 17 00:00:00 2001 From: Romain Beauxis Date: Mon, 2 Aug 2021 09:35:33 +0200 Subject: [PATCH] Fix META generation for private libs. Signed-off-by: Romain Beauxis --- CHANGES.md | 2 ++ src/dune_rules/gen_meta.ml | 9 ++++++++- .../test-cases/private-package-lib.t/run.t | 2 +- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 2601087d0f2..e6d6b590520 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,6 +1,8 @@ Unreleased ---------- +- Fixes `opam` META file requires entry for private libs (#4841, fixes #4839, @toots) + - Fixes `dune exec` not adding .exe on Windows (#4371, fixes #3322, @MisterDA) - Allow multiple cinaps stanzas in the same directory (#4460, @rgrinberg) diff --git a/src/dune_rules/gen_meta.ml b/src/dune_rules/gen_meta.ml index c1785d5711e..eaedfbc2d57 100644 --- a/src/dune_rules/gen_meta.ml +++ b/src/dune_rules/gen_meta.ml @@ -89,7 +89,14 @@ let gen_lib pub_name lib ~path ~version = | Ppx_deriver _ -> [ Pos "ppx_driver" ] in - let to_names = Lib_name.Set.of_list_map ~f:Lib.name in + let name lib = + let name = Lib.name lib in + match Lib_info.status (Lib.info lib) with + | Private (_, Some pkg) -> + Lib_name.mangled (Package.name pkg) (Lib_name.to_local_exn name) + | _ -> name + in + let to_names = Lib_name.Set.of_list_map ~f:name in let* lib_deps = Resolve.read_memo_build (Lib.requires lib) >>| to_names in let* ppx_rt_deps = Resolve.read_memo_build (Lib.ppx_runtime_deps lib) >>| to_names diff --git a/test/blackbox-tests/test-cases/private-package-lib.t/run.t b/test/blackbox-tests/test-cases/private-package-lib.t/run.t index 756743d2fe5..804c27eda98 100644 --- a/test/blackbox-tests/test-cases/private-package-lib.t/run.t +++ b/test/blackbox-tests/test-cases/private-package-lib.t/run.t @@ -62,7 +62,7 @@ Note the name mangling convention in the META file: package "bar" ( directory = "bar" description = "" - requires = "secret" + requires = "foo.__private__.secret" archive(byte) = "foo.cma" archive(native) = "foo.cmxa" plugin(byte) = "foo.cma"