Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix META generation for private libs. #4841

Merged
merged 1 commit into from
Aug 16, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
9 changes: 8 additions & 1 deletion src/dune_rules/gen_meta.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion test/blackbox-tests/test-cases/private-package-lib.t/run.t
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ Note the name mangling convention in the META file:
package "bar" (
directory = "bar"
description = ""
requires = "secret"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just wondering what would be the difference with only __private__.secrete

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried and it was not working.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The __private__ name is the only one valid in META files. The other name is only usable in dune files (in the same project)

requires = "foo.__private__.secret"
archive(byte) = "foo.cma"
archive(native) = "foo.cmxa"
plugin(byte) = "foo.cma"
Expand Down