Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

improvement: add option --no-default-features and --features #92

Merged
merged 9 commits into from
Apr 1, 2024

Conversation

uncomfyhalomacro
Copy link
Contributor

This is still not tested if it works.

Changes not documented

  • Used flag description from cargo build:
     -F, --features <FEATURES>  Space or comma separated list of features to activate
     --all-features             Activate all available features
     --no-default-features      Do not activate the `default` feature

Reference issues/prs: #91

This is still not tested if it works.

Signed-off-by: Soc Virnyl Estela <[email protected]>
Copy link
Member

@cgwalters cgwalters left a comment

Choose a reason for hiding this comment

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

Thanks for working on this! Just some nits.

As far as a test case, the Rust tests in this project only test vendoring our own code, which doesn't have any features. However, if you look at the Github action flow, we test vendoring nushell, protobuf and netavark and at least nushell definitely has features.

Looks like in the current code wasi is optional so we could test with adding that as a feature?

src/main.rs Outdated Show resolved Hide resolved
src/main.rs Outdated Show resolved Hide resolved
src/main.rs Outdated Show resolved Hide resolved
src/main.rs Outdated Show resolved Hide resolved
src/main.rs Outdated Show resolved Hide resolved
…ng> and bool, respectively

Signed-off-by: Soc Virnyl Estela <[email protected]>
this is to test new options: no-default-features and features

Signed-off-by: Soc Virnyl Estela <[email protected]>
@@ -312,6 +327,8 @@ impl VendorFilter {
let args_unset = args.platform.is_none()
&& args.tier.is_none()
&& args.all_features.is_none()
&& !args.no_default_features
Copy link
Member

Choose a reason for hiding this comment

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

I guess in retrospect, we're inconsistent now with the Option<bool> for all_features...I don't remember why I did that now. The logic here is checking for "was the argument provided", but there's no way to do e.g. cargo vendor --all-features=false - you can only provide a single bit, so there's no distinguishing between "option unset" and "option set to false".

So we can do a followup cleanup to drop that Option too I think.

Copy link
Member

@cgwalters cgwalters left a comment

Choose a reason for hiding this comment

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

Thanks!

@cgwalters
Copy link
Member

Oh hmm, unit tests aren't happy

called Result::unwrap() on an Err value: Error("missing field no-default-features", line: 0, column: 0)

Ah I bet we need a #[serde(default)] for the new value in struct VendorFilter. Which I guess is an argument to just be consistent and use Option<bool> there too for now (I don't have a strong opinion). I think not having the Option in the clap bits is right at least though.

Args
  - `features` is just a Vec<String> so default is always empty
  - `no_default_features` is bool but set with default_value_t of false

VendorFilter
  - `features` is just a Vec<String> set to default which is empty? and skip serializing if Vec is empty
  - `no_default_features` is set to default. default is always false for bool

Signed-off-by: Soc Virnyl Estela <[email protected]>
@uncomfyhalomacro uncomfyhalomacro force-pushed the 20240329-feature-flags branch from 529751f to b5a90e2 Compare April 1, 2024 00:17
@uncomfyhalomacro
Copy link
Contributor Author

I will attempt doing a cleanup with all features too. just a small quick change.

@uncomfyhalomacro uncomfyhalomacro force-pushed the 20240329-feature-flags branch from 10af33e to 55e8f06 Compare April 1, 2024 05:10
…d. enabling them as features.

we replace also `true` directory as `vendor`. I was confused of this at first... but it seems
`true` was used as to set all-features to true instead of it being an output directory

currently, to set `all-features` and `no-default-features`, you just have to add the flag
without any parameters. removing the flags will just auto set it to false.

Signed-off-by: Soc Virnyl Estela <[email protected]>
Copy link
Member

@cgwalters cgwalters left a comment

Choose a reason for hiding this comment

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

Thanks!

@@ -96,14 +96,14 @@ jobs:
# For netavark
- run: sudo apt install protobuf-compiler
- run: |
mkdir -p .cargo && cargo-vendor-filterer --platform x86_64-unknown-linux-gnu --all-features true > .cargo/config.toml
rm -rfv true
Copy link
Member

Choose a reason for hiding this comment

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

Heh wow yes, that was a confusing thing before...

@cgwalters cgwalters enabled auto-merge April 1, 2024 11:56
@cgwalters cgwalters merged commit 2b7fbc5 into coreos:main Apr 1, 2024
6 checks passed
@cgwalters
Copy link
Member

(Note to all of us, I had to update the branch protection rules for the nushell version, I think we can simplify this in the future by dropping the version from the job name)

@cgwalters
Copy link
Member

@uncomfyhalomacro can you review #93 ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants