-
Notifications
You must be signed in to change notification settings - Fork 24
Add a way not to enable features in workspace crates #655
Comments
Thanks for the report! hakari has the ability to define exclusions in the config: Another option is to specify your feature as a platform-specific one if possible, e.g. with: [dependencies]
transitive-dep = "0.1.0"
[target.'cfg(target_os = "linux")'.dependencies]
transitive-dep = { version = "0.1.0", features = ["fips"] } In that case hakari will automatically exclude it from consideration. If you specify Linux as a platform, it'll then be included for Linux. |
That's clever! I didn't realize cargo would unify the features across target-specific tables like that :)
hmm, I tried this but got an error I didn't understand:
I am not sure it would solve my problem even if I got it working, though - I do want to pull in |
Could you paste the contents of the relevant sections of
You'll be able to pull in transitive-dep while building, it just won't be part of the workspace-hack. |
[final-excludes]
third-party = [
{ name = "transitive-dep", git = "ssh://git@redacted/transitive-dep.git" }
] |
If I try |
Ahh I did some experimentation and it looks like you have to specify both the URL and the branch: [final-excludes]
third-party = [
{ name = "transitive-dep", git = "ssh://git@redacted/transitive-dep.git", branch = "my-branch" }
] I think this is a bug (not specifying a branch should mean "include all branches") but hopefully this workaround will work for you.
Note that it's |
Thanks! With I think It would be nice to have a way to configure excludes individual features, instead of whole crates. Alternatively, if there's a way to tell hakari not to enable features defined by crates in the current workspace, I think that would work as well. |
Yeah, I think that would be a pretty good addition! This is honestly the first time excluding just a single feature (rather than an entire package) has come up like this. Question: does the platform-specific feature via the |
Awesome, glad to hear! I'm happy to take a stab at implementing it if you can point me in the right direction :)
No, unfortunately - I do want to build this workspace in multiple modes, even on Linux. Enabling the |
A little warning: it's maybe a full day of work. ConfigurationWe probably want to expose this via an optional [traversal-excludes]
workspace-members = [
"my-crate",
{ name = "my-other-crate", features = ["foo", "bar"] }
]
third-party = [
{ package = "foo", version = "1", features = ["feature1", "feature2"] }
] This is likely going to mean moving away from simply deserializing the Updating the core algorithmsFor This needs to be updated to handle excluding individual features as well.
Note that a package with no features left should be removed from the map, like in the example shown here: |
Awesome! I have ~2 hours today to put into it, I'll take a stab and see what progress I can make :) |
What should (alternatively I can just make this a hard error and require people to specify at least one feature) |
I'd make this a hard error. |
@sunshowers I'm sure there's a simple way to do this, but is there a way to tell serde "deserialize this struct, then another struct" without having to manually implement Visitor? I currently have impl<'de> Deserialize<'de> for ThirdPartySummaryWithFeatures {
fn deserialize<D>(d: D) -> Result<Self, D::Error>
where
D: serde::Deserializer<'de> {
let FeatureFields { features } = FeatureFields::deserialize(d)?;
let krate = ThirdPartySummary::deserialize(d)?;
Ok(ThirdPartySummaryWithFeatures { krate, features: require_non_empty(features)? })
}
} which gives an error that I use (I'm making these separate structs because |
actually I think this is just |
Yeah, I think that's serde(flatten). |
You're right, this is trickier 😁 I've plumbed down the individual features to
The same also applies to optional dependencies, although hopefully 🤞 that will use the same logic.
|
Where the |
Feel free to put up whatever you have, I'm happy to finish it up in the next week or so |
I am not sure you want it as-is, it's incomplete and doesn't compile 😅 but here's what I have so far: https://github.com/facebookincubator/cargo-guppy/compare/main...jyn514:specific-features?expand=1 Thanks so much for all your help! This was a lot of fun :D |
Oh, also I think the commented-out code around |
Hi -- I've left Meta and can no longer contribute to this repository. Please file an issue at guppy-rs/guppy. Thanks. |
I have a workspace that looks like this, where
my-crate: feature1 => x/feature2
means "my-crate has a feature namedfeature1
which enablesfeature2
in the dependencyx
":When I run
cargo hakari generate
, it adds a line toworkspace-hack/Cargo.toml
that looks likeI think haraki is running
cargo tree --all-features
or something like that. I want it not to enable that feature; it only builds on linux machines and some of the people on my team use Mac. I don't see an existing way to do this:Would it be possible to add one?
The text was updated successfully, but these errors were encountered: