Skip to content

Commit

Permalink
Put back library variants in development mode (#2116)
Browse files Browse the repository at this point in the history
* Put back library variants in development mode

Signed-off-by: Jeremie Dimino <jeremie@dimino.org>

* _

Signed-off-by: Jeremie Dimino <jeremie@dimino.org>
  • Loading branch information
jeremiedimino authored May 2, 2019
1 parent 5080f6e commit e7a5d7e
Show file tree
Hide file tree
Showing 22 changed files with 60 additions and 17 deletions.
7 changes: 7 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
unreleased
----------

- Put back library variants in development mode. We discovered a
serious unexpected issue and we might need to adjust the design of
this feature before we are ready to commit to a final version. Users
will need to write `(using library_variants 0.1)` in their
`dune-project` file if they want to use it before the design is
finalized. (#2116, @diml)

- Restricted the set of variables available for expansion in the destination filename
of `install` stanza to simplify implementation and avoid dependency
cycles. (#2073, @aalekseyev, @diml)
Expand Down
6 changes: 6 additions & 0 deletions doc/variants.rst
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,10 @@ implementation for every virtual library that we've used:
Variants
========

This feature is still under development and may change with new dune
releases. You need to write ``(using library_variants 0.1)`` in your
``dune-project`` file to unlock it.

When building a binary, implementations can be selected using a set of variants
rather than individually specifying implementations.

Expand Down Expand Up @@ -107,6 +111,8 @@ implementation would have the following configuration:
Default implementation
======================

This feature is also guarded by ``(using library_variants ...)``.

A virtual library may select a default implementation, which is enabled after
variant resolution, if no suitable implementation has been found.

Expand Down
17 changes: 14 additions & 3 deletions src/dune_file.ml
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,20 @@ let relative_file =
else
of_sexp_errorf loc "relative filename expected")


let library_variants =
let syntax =
Syntax.create ~name:"library_variants"
~desc:"the experimental library variants feature."
[ (0, 1) ]
in
Dune_project.Extension.register_simple ~experimental:true
syntax (Dune_lang.Decoder.return []);
syntax

let variants_field =
field_o "variants" (
let* () = Syntax.since Stanza.syntax (1, 9) in
let* () = Syntax.since library_variants (0, 1) in
located (list Variant.decode >>| Variant.Set.of_list))

(* Parse and resolve "package" fields *)
Expand Down Expand Up @@ -901,11 +912,11 @@ module Library = struct
located Lib_name.decode)
and+ variant =
field_o "variant" (
Syntax.since Stanza.syntax (1, 9) >>>
Syntax.since library_variants (0, 1) >>>
located Variant.decode)
and+ default_implementation =
field_o "default_implementation" (
Syntax.since Stanza.syntax (1, 9) >>>
Syntax.since library_variants (0, 1) >>>
located Lib_name.decode)
and+ private_modules =
field_o "private_modules" (
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
(lang dune 1.9)
(lang dune 1.9)
(using library_variants 0.1)
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
(lang dune 1.10)
(using library_variants 0.1)
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
(lang dune 1.10)
(using library_variants 0.1)
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
(lang dune 1.9)
(name a)
(using library_variants 0.1)
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
(lang dune 1.9)
(lang dune 1.9)
(using library_variants 0.1)
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
(lang dune 1.9)
(lang dune 1.9)
(using library_variants 0.1)
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
(lang dune 1.9)
(using fmt 1.1)
(using library_variants 0.1)
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
(lang dune 1.9)
(lang dune 1.9)
(using library_variants 0.1)
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
(lang dune 1.9)
(lang dune 1.9)
(using library_variants 0.1)
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
(lang dune 1.9)
(lang dune 1.9)
(using library_variants 0.1)
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
(lang dune 1.9)
(lang dune 1.9)
(using library_variants 0.1)
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
(lang dune 1.9)
(lang dune 1.9)
(using library_variants 0.1)
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
(lang dune 1.9)
(lang dune 1.9)
(using library_variants 0.1)
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
(lang dune 1.9)
(lang dune 1.9)
(using library_variants 0.1)
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
(lang dune 1.9)
(lang dune 1.9)
(using library_variants 0.1)
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
(lang dune 1.9)
(lang dune 1.9)
(using library_variants 0.1)
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
(lang dune 1.9)
(name a)
(using library_variants 0.1)
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
(lang dune 1.9)
(lang dune 1.9)
(using library_variants 0.1)
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
(lang dune 1.9)
(lang dune 1.9)
(using library_variants 0.1)

0 comments on commit e7a5d7e

Please sign in to comment.