From 0f02f20205814ddc958fe17e2741de2d4a0eb7b0 Mon Sep 17 00:00:00 2001 From: Lucas Pluvinage Date: Tue, 4 Jun 2019 15:20:52 +0200 Subject: [PATCH] variants: tweak doc and error message Signed-off-by: Lucas Pluvinage --- doc/variants.rst | 10 +++++----- src/lib.ml | 16 ++++++++++------ .../test-cases/variants-multi-project/run.t | 12 ++++++++---- 3 files changed, 23 insertions(+), 15 deletions(-) diff --git a/doc/variants.rst b/doc/variants.rst index 1e3401122da4..bb5dc1e799a3 100644 --- a/doc/variants.rst +++ b/doc/variants.rst @@ -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 diff --git a/src/lib.ml b/src/lib.ml index d92609dd9bcc..3ebfb7010a2c 100644 --- a/src/lib.ml +++ b/src/lib.ml @@ -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 diff --git a/test/blackbox-tests/test-cases/variants-multi-project/run.t b/test/blackbox-tests/test-cases/variants-multi-project/run.t index 1ffab0b3ea13..c9688857876c 100644 --- a/test/blackbox-tests/test-cases/variants-multi-project/run.t +++ b/test/blackbox-tests/test-cases/variants-multi-project/run.t @@ -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]