Skip to content

Commit

Permalink
variants: tweak doc and error message
Browse files Browse the repository at this point in the history
Signed-off-by: Lucas Pluvinage <[email protected]>
  • Loading branch information
TheLortex committed Jun 4, 2019
1 parent d548ea9 commit 0f02f20
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 15 deletions.
10 changes: 5 additions & 5 deletions doc/variants.rst
Original file line number Diff line number Diff line change
Expand Up @@ -110,11 +110,11 @@ implementation would have the following configuration:
(implements time)
(variant js))
Since dune 1.11.0, the list of available variants is computed while building
the virtual library. This means only variant implementations that are part of
the same project are implicitely taken into account. It's possible to declare
an external implementation by using the `external_variant` stanza in the
virtual library scope.
The list of available variants is computed while building the virtual library.
This means only variant implementations that are part of the same project are
implicitely taken into account. It's possible to declare an external
implementation by using the `external_variant` stanza in the virtual library
scope.

.. code:: scheme
Expand Down
16 changes: 10 additions & 6 deletions src/lib.ml
Original file line number Diff line number Diff line change
Expand Up @@ -831,16 +831,20 @@ let rec instantiate db name (info : Lib_info.t) ~stack ~hidden =
Ok vlib
else
Errors.fail loc
"Library implementation %a for variant %a implements a \
library @ outside the project.@ Instead of using \
"Library implementation %a with variant %a implements@ a \
library outside the project.@ Instead of using \
(variant %a) here,@ you need to reference it in the \
virtual library definition, using @ \
(external_implementations (%a %a))."
Lib_name.pp (snd name)
virtual library project,@ using the external_variant stanza:@ \
(external_variant@\n\
\ (virtual_library %a)@\n\
\ (variant %a)@\n\
\ (implementation %a))"
Lib_name.pp info.name
Variant.pp variant
Variant.pp variant
Lib_name.pp vlib.name
Variant.pp variant
Lib_name.pp vlib.name)
Lib_name.pp info.name)
in
let default_implementation =
Option.map info.default_implementation ~f:(fun l -> lazy (resolve l)) in
Expand Down
12 changes: 8 additions & 4 deletions test/blackbox-tests/test-cases/variants-multi-project/run.t
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,12 @@ variant.
File "prj2/dune", line 4, characters 13-20:
4 | (implements vlibfoo)
^^^^^^^
Error: Library implementation vlibfoo for variant "somevariant" implements a library
outside the project. Instead of using (variant "somevariant") here,
you need to reference it in the virtual library definition, using
(external_implementations ("somevariant" vlibfoo)).
Error: Library implementation impl with variant "somevariant" implements
a library outside the project. Instead of using (variant "somevariant") here,
you need to reference it in the virtual library project,
using the external_variant stanza:
(external_variant
(virtual_library vlibfoo)
(variant "somevariant")
(implementation impl))
[1]

0 comments on commit 0f02f20

Please sign in to comment.