Skip to content
This repository has been archived by the owner on Sep 28, 2022. It is now read-only.

handle platform dependencies + update feature graph construction #82

Merged
merged 11 commits into from
Apr 1, 2020

Conversation

sunshowers
Copy link
Contributor

@sunshowers sunshowers commented Mar 28, 2020

This is a complete overhaul of the way platform-specific dependencies are
handled. Based on my experimentation and reading the Cargo source code, I
believe that this is now correct.

Doing so also required feature graph construction to be updated, so the
feature graph construction is ready for the new feature resolver, and is now
platform-sensitive as well. The APIs for the feature graph are still to
come, but making the data model be full-fidelity allows for both the current
and new feature resolvers to be implemented.

Now that target logic is internalized in guppy, cargo-guppy no longer needs
to do its own evaluation.

For more about the new feature resolver, see:

Closes #64.

@sunshowers sunshowers requested a review from metajack March 28, 2020 02:10
@sunshowers sunshowers self-assigned this Mar 28, 2020
@sunshowers sunshowers force-pushed the target-spec branch 3 times, most recently from d0ca869 to f2f6be4 Compare March 28, 2020 02:27
@sunshowers
Copy link
Contributor Author

I'd want to get EmbarkStudios/cfg-expr#6 landed + include the three-value logic support in https://github.com/sunshowers/cfg-expr/tree/logic.

Copy link
Contributor

@metajack metajack left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great. A few minor comments below.

target-spec/src/parser.rs Outdated Show resolved Hide resolved
guppy/src/graph/graph_impl.rs Show resolved Hide resolved
Since target features are CPU-dependent, the caller has to pass in a list to
match against.
This is useful for evaluating against the current platform.
Addressing review feedback -- it's somewhat inconvenient to try and amend
the earlier commits with this change, so here it is.
We're standardizing on naming the `cfg()` expression a `TargetSpec` and a
triple a `Platform`.
Move the definitions and tests for `TargetSpec` and `Target` into
`parser.rs`.
Moving this earlier provides a type-level guarantee that this works, which
means that the `eval` method no longer needs to return any errors. The next
commit will clean `eval` up.
Now that all checking happens at parse time, this can be done.
This wasn't really obvious to me when I was looking at this code.
This is because we're going to replace the Dependency enum's variants with
TargetPredicates, which don't implement any of those.

We may reintroduce this in the future if necessary.
This is a complete overhaul of the way platform-specific dependencies are
handled. Based on my experimentation and reading the Cargo source code, I
believe that this is now correct.

Doing so also required feature graph construction to be updated, so the
feature graph construction is ready for the new feature resolver, and is now
platform-sensitive as well. The APIs for the feature graph are still to
come, but making the data model be full-fidelity allows for both the current
and new feature resolvers to be implemented.

Now that target logic is internalized in guppy, cargo-guppy no longer needs
to do its own evaluation.

For more about the new feature resolver, see:

* https://doc.rust-lang.org/nightly/cargo/reference/unstable.html#features
* rust-lang/cargo#7914
* rust-lang/cargo#7915
* rust-lang/cargo#7916
@sunshowers
Copy link
Contributor Author

Thanks for the review! Before landing, I did some further refactoring so that TargetSpec::eval no longer returns errors -- all error checking is now done upfront. Will land shortly, thanks again!

Just need to wait on EmbarkStudios/cfg-expr#7 to land and be published to crates.io now. At that point we can release a guppy update ^_^

@sunshowers sunshowers merged commit 49db30b into facebookarchive:master Apr 1, 2020
@sunshowers sunshowers deleted the target-spec branch April 1, 2020 19:32
sunshowers added a commit to sunshowers/cargo-guppy that referenced this pull request May 1, 2020
This works by:
* setting up a real, fairly complex fixture
* generating random queries using proptest
* running them through cargo and guppy
* ensuring that they produce the same results

Not only does this give us high confidence that cargo
and guppy produce the same results, it also gets us
most of the way to facebookarchive#82.

Most of the work in this commit is simply setting up
all the necessary test infrastructure. We piggy-back on
existing proptest infrastructure as much as possible.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add model for new feature resolver once it lands upstream
2 participants