-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Build a crate with specific variables #6373
Comments
openssl-rust may demonstrate a way to do this |
How do |
|
The lack of such a feature (or something similar) is a major pain in the rear for me currently. I'd like to let users of my hazptr crate define some compile time parameters for performance fine tuning. Since this crate would likely only be used by other libraries, setting a global environmental variable upon invocation of cargo (e.g. I've tried to do this through build scripts but failed, since apparently you can not affect environment variables through build scripts across crate boundaries. |
I need this feature too! Also, I'm interested in implementing this. Can I take this? Here are more details to implement this. If there is any suggestion, comment, please.
|
you can use the following in your build.rs main function: println!("cargo:rerun-if-env-changed=YOUR_ENV"); |
@yaa110 EDIT: There was a typo. It works well in Windows too. |
https://internals.rust-lang.org/t/pre-rfc-mutually-excusive-global-features/19618 might be an option for this. |
So I was thinking about this earlier. Then I saw this issue. [features]
default = ["tls:rustls"]
[features.tls]
options = ["native", "rustls"]
rustls = ["actix-web/rustls-0_21", "dep:rustls", "rustls-pemfile", "lettre/tokio1-rustls-tls"]
native-tls = ["lettre/tokio1-native-tls", "openssl", "actix-web/openssl"]
required = true # An Option must be selected It would be seen as more of "features with options" cargo build --features tls:rustls And to use them in creates [dependencies]
my_crate = {version: "0.1.0", features = ["tls:rustls"]} |
#2980 is the issue for mutually exclusive features. The big problem with is is feature unification (if two packages set different values, what do you do?). This is why the above proposal shifts the problem of mutually exclusive features into being "global features", bypassing unification. |
Thinking more on this, is there enough distinction from #2980 to keep this open or should we close in favor of that one? |
Agree that #2980 could be a way to resolve this. Some of the use cases of this can also be fixed by #6373 (comment), e.g. Starting from Rust 1.56, Close this in favor of #2980. Please let us know if we overlooked something. |
Describe the problem you are trying to solve
During the build of nginx crate, I want to let users specify the version of Nginx when they use this crate as a dependency.
Describe the solution you'd like
The text was updated successfully, but these errors were encountered: