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

Nightly target-specific feature selection not supported #234

Closed
dae opened this issue Oct 8, 2020 · 5 comments
Closed

Nightly target-specific feature selection not supported #234

dae opened this issue Oct 8, 2020 · 5 comments

Comments

@dae
Copy link
Contributor

dae commented Oct 8, 2020

Hi there,

Is my understanding correct that currently the only way to select specific features from a crate is to manually edit the generated remote/.BUILD.bazel file, removing the unwanted features from the list? I currently am using a Cargo.toml file that specifies different features for different platforms, and am wondering whether such a thing can be accomplished with Bazel now that #212 has landed.

@UebelAndre
Copy link
Collaborator

Hey, does the additional_flags field help you here?
https://github.com/google/cargo-raze/blob/master/examples/remote/complicated_cargo_library/Cargo.toml#L23-L26

I struggle to find a way to specify only specify a feature for a specific platform with just --cfg flags though. Maybe this is a lack of functionality on raze? Can you elaborate more on what you're trying to do and potentially provide some example? 😄 🙏

Also, There should be no reason to hand edit generated files. Definitely interested in cases where you feel that's necessary.

@UebelAndre
Copy link
Collaborator

Maybe rust-lang/cargo#1197 would also be relevant here?

@dae
Copy link
Contributor Author

dae commented Oct 8, 2020

Sorry for the noise - this looks to be mostly a misunderstanding on my part. The Rust code I use is compiled into a Python module, and the Python distribution rules require that openssl is statically linked on Linux. Thinking it would be better to continue to use the system library on macOS, I had updated my Cargo.toml file to be:

[target.'cfg(linux)'.dependencies.reqwest]
version = "0.10"
features = ["json", "socks", "stream", "native-tls-vendored"]

[target.'cfg(not(linux))'.dependencies.reqwest]
version = "0.10"
features = ["json", "socks", "stream"]

This resulted in the Linux build statically linking openssl, and we were using the nightly compiler at the time for other reasons, so I had thought the problem solved. Re-reading that link above, I realize that I had neglected to enable itarget, and so had probably just been vendoring on all platforms instead. Whoops.

I now see that for simple feature lists not gated by platform, cargo raze is adjusting the crate_features argument to match what is in Cargo.toml. So the only issue here is that cargo raze doesn't support the nightly target-specific resolution rules that are off by default, and that's probably a niche enough feature that it's not worth worrying about at the moment.

@dae dae closed this as completed Oct 8, 2020
@dae dae changed the title Selecting features Nightly target-specific feature selection not supported Oct 8, 2020
@UebelAndre
Copy link
Collaborator

You could leave this open as a feature request 😄

@dae
Copy link
Contributor Author

dae commented Oct 9, 2020

Didn't want to clutter up the tracker with something nobody else may ever ask for :-) If someone else finds this and has the same issue, I can open it again.

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

No branches or pull requests

2 participants