Skip to content

[RFC] New variant proposal #2134

@ghost

Description

Following recent events, this ticket describes a new proposal for variants that we discussed yesterday with @rgrinberg, @TheLortex and @aalekseyev.

Proposal

The proposal is the same as before, except that we only allow an implementation to be tagged with a variant if it is part of the same project as the virtual library it implements.

This limitation has several consequence:

  • it will avoid all the issues observed with the initial version of variants
  • it will encourage users to make their implementations part of the same repository as their virtual libraries, which should lead to a more healthy ecosystem

Implementation

This restriction simplifies the implementation a lot as we will now know all the variants of a virtual library immediately when compiling the virtual library. In particular, it will not be possible to add new variants afterwards. As a result, we can store in the metadata of a virtual library the list of variants it supports, with the corresponding implementation (as just a library name) for each variant.

This local variant index will be stored directly in the library stanza of the virtual library in the dune-package file. Dune will no longer need to scan the whole package DB to construct the variant map. In fact, it will no longer need a global variant index. Instead, when looking for an implementation for a virtual library that doesn't have one, it will simply look in the local index attached to this virtual library.

Interaction with -p

-p hides all the stanzas that are not part of the package being built. This mean that when an implementation tagged with a variant is distributed as a separate package, we will no longer see it when building the virtual library. This is a problem.

To avoid this problem, instead of completely suppressing library stanzas that are not part of the current package, we will replace them by a stanza that only declare the tagged implementation. I.e. this stanzas will contain 3 pieces of information:

  • the public name of a virtual library
  • the public name of an implementation of this virtual library
  • a variant name
    This stanza will be used to construct the variant index of the virtual library. We could make this stanza available in dune files so that users can declare external variant tagged implementations.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions