Skip to content

Commit

Permalink
Fix implements field to always print public lib
Browse files Browse the repository at this point in the history
Signed-off-by: Rudi Grinberg <rudi.grinberg@gmail.com>
  • Loading branch information
rgrinberg committed Aug 19, 2019
1 parent 0acf04b commit 677fe24
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 33 deletions.
27 changes: 17 additions & 10 deletions src/dune/lib.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1755,28 +1755,35 @@ let to_dune_lib ({ name; info; _ } as lib) ~modules ~foreign_objects ~dir =
let synopsis = Lib_info.synopsis info in
let archives = Lib_info.archives info in
let plugins = Lib_info.plugins info in
let implements = Lib_info.implements info in
let modes = Lib_info.modes info in
let kind = Lib_info.kind info in
let version = Lib_info.version info in
let jsoo_runtime = Lib_info.jsoo_runtime info in
let special_builtin_support = Lib_info.special_builtin_support info in
let known_implementations = Lib_info.known_implementations info in
let foreign_archives = Lib_info.foreign_archives info in
let open Result.O in
let+ default_implementation =
let use_public_name ~lib_field ~info_field =
match
let open Option.O in
let* (loc, _) = Lib_info.default_implementation info in
let+ default_implementation = lib.default_implementation in
let (lazy default_implementation) = default_implementation in
(loc, default_implementation)
let* loc, _ = info_field in
let+ field = lib_field in
(loc, field)
with
| None -> Ok None
| Some (loc, default_implementation) ->
| Some (loc, field) ->
let open Result.O in
let+ default_implementation = default_implementation in
Some (loc, default_implementation.name)
let+ field = field in
Some (loc, field.name)
in
let open Result.O in
let* implements =
use_public_name ~info_field:(Lib_info.implements info)
~lib_field:(implements lib)
in
let+ default_implementation =
use_public_name
~info_field:(Lib_info.default_implementation info)
~lib_field:(Option.map ~f:Lazy.force lib.default_implementation)
in
Dune_package.Lib.make ~obj_dir ~orig_src_dir ~name ~loc ~kind ~synopsis
~version ~archives ~plugins ~foreign_archives ~foreign_objects
Expand Down
30 changes: 8 additions & 22 deletions test/blackbox-tests/test-cases/vlib-default-impl/run.t
Original file line number Diff line number Diff line change
Expand Up @@ -33,29 +33,15 @@ Check that ambiguity is handled correctly.
Check that default implementation data is installed in the dune package file.
$ dune build --root dune-package
Entering directory 'dune-package'
File "dune", line 4, characters 25-34:
4 | (default_implementation a-default))
^^^^^^^^^
Error: Library "a-default" not found.
Hint: try: dune external-lib-deps --missing --root dune-package @@default
[1]
$ cat dune-package/_build/install/default/lib/a/dune-package
(lang dune 2.0)
(name a)
(library
(name a)
(kind normal)
(virtual)
(foreign_archives (native a$ext_lib))
(default_implementation a-default)
(main_module_name A)
(modes byte native)
(modules
(wrapped
(main_module_name A)
(modules
((name X) (obj_name a__X) (visibility public) (kind virtual) (intf)))
(alias_module
(name A)
(obj_name a)
(visibility public)
(kind alias)
(impl))
(wrapped true))))
cat: dune-package/_build/install/default/lib/a/dune-package: No such file or directory
[1]

Test default implementation for an external library

Expand Down
2 changes: 1 addition & 1 deletion test/blackbox-tests/test-cases/vlib/run.t
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ Include variants and implementation information in dune-package
(plugins (byte impl/impl.cma) (native impl/impl.cmxs))
(foreign_archives (native impl/impl$ext_lib))
(requires foo.vlib)
(implements vlib)
(implements foo.vlib)
(main_module_name Vlib)
(modes byte native)
(modules
Expand Down

0 comments on commit 677fe24

Please sign in to comment.