Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR brings back #8356. It's clear that there's a need for this construct, but I felt that the PR had some shortcomings that had to be addressed, and I've attempted to do so here. The following changes were made to make this feature make more sense in the context of dune's other features:
First, the field is renamed to
enabled_if. This is inconsistent with opam, but is consistent with the rest of dune, which I deem as much more important. Second, the syntax is switched to pforms. Again, dune already has its own syntax for this stuff and we might as well reuse it.The field is given meaning independently of opam. It is interpreted exactly as
--only-packagesis. Packages which are "disabled" are essentially masked off the build, which I think is a fairly intepretation.I've added proper validation to this field to avoid users writing any garbage they want.
One important possibility for improvement is giving user proper error messages when packages are unavailable. I'm leaving that for future work as dune doesn't handle this properly in many other places already.