This is just a bit of a musing, to see it can go anywhere. In the context of #723 and crates requiring different compilers (native, cross-compilers), I wonder if an old feature that is lurking unused could come in handy, which is the "equivalent" crates (the "provides" alias of a release).
So, let's assume a dependency A requires a modern GNAT version. This is currently expressed for example as gnat = ">=10"
. This is a utility library that doesn't care about the target.
Now, there's our project B which we know requires a cross-compiler gnat-cross-X
. Obviously, both crates should be compiled with the same compiler but they do not refer to the same dependency, so currently that's a no-no.
The equivalent crate feature comes in now. This was inspired by virtual apt
packages (here and here). Let's say that we redefine our compiler crates this way (let's forget what gnat
currently means):
gnat
: this is the "virtual" crate: any other crate may indicate that it provides this dependency. This is not an actual crate in the index.gnat-native
: a native compiler (from binares, system packages...)gnat-cross-X
: an example cross compiler.In the crate definitions of gnat-native
and gnat-cross
, they should indicate that they fulfill the gnat
dependency (provides = "gnat"
). During resolution, the solver accepts any crate that provides the virtual one. In this example, due to B depending on gnat-cross
, and A depending on any gnat, gnat-cross
will be used.
Now, for the case where crates only specify any gnat
, if we detect a installed gnat
(via #723, or the system compiler, or manually), that one should take precedence over other alternatives (this is unimplemented).
Finally, if a crate depends on gnat-native
and another one on gnat-cross
, or two different cross-compilers, these are obviously incompatible. (I wonder if "or" dependencies (also lurking unused) might also serve for crates that can target several boards, but that's a separate topic.)
In short, the provides
field creates an alias that unifies a family of crates. Dependents can refer either to any from the family via the alias, or concretely to an actual crate.
Ping @Fabien-Chouteau because I botched the initial issue creation...
Pay now to fund the work behind this issue.
Get updates on progress being made.
Maintainer is rewarded once the issue is completed.
You're funding impactful open source efforts
You want to contribute to this effort
You want to get funding like this too