-
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
Pass environment variables to dependencies. #97
Comments
What sort of variables were you thinking of passing? I'd rather give more variables by default than add custom ones, but I could see both happening. |
In my case it would be for building C libraries. The user could pass environment variable to my shell script that cargo runs when it runs the (The build command that I'm referring to is called "The build Field" on http://crates.io/manifest.html). |
As an example, gl-rs uses environment variables during the library build phase. |
Do you have an idea of what specific environment variables you'd want to put in |
I'd like to use environment variables to tell my build script what libraries to build. I could see them being used to configure almost any project that has a build script generating native code. |
I'm not understanding the cargo-specific functionality you want here. Why would cargo pass different environment variables than, for example, |
I'd want the users of my library to be able to set environment variables for my projects via Cargo. Different libraries would have different environment variables used in their build scripts, so I don't see the reason to have them set for everything. |
Another use case would be to inform a library that it should expect a dependency to be either statically or dynamically linked. Right now, (as far as I understand), if a library uses |
@alexcrichton and I are planning on solving this problem through a syntax extension. More to come! |
I've started working on said syntax extension here: https://github.com/alexcrichton/link-config |
Closes rust-lang#97 Closes rust-lang#601 (this is an equivalent solution for that problem)
As pointed in #633, it's currently not possible for a package to reexport the feature of another package due to the limitations of how features are defined. This commit adds support for this ability by allowing features of the form `foo/bar` in the `features` section of the manifest. This form indicates that the dependency `foo` should have its `bar` feature enabled. Additionally, it is not required that `foo` is an optional dependency. This does not allow features of the form `foo/bar` in a `[dependencies]` features section as dependencies shouldn't be enabling features for other dependencies. At the same time, this passes through features to build commands to solve a few more issues. Closes #97 Closes #601 (this is an equivalent solution for that problem) Closes #633 Closes #674
I found a use case, the rust-ffmpeg-sys has a custom build.rs which allows you to pass a environment variable 'FFMPEG_DIR' to specify the path to the pre-compiled header/lib of FFMPEG. |
@ccll note that this is a super old issue, dependencies today can pass env vars to each other |
@alexcrichton Thanks for the tip, but it doesn't look like what I want. What I want is to set env vars for |
Correct yeah, that feature is covered by #3544 |
@alexcrichton I'm afraid it's still not quite the same feature. #3544 only eliminate the mandatory requirements on 'links' key, but still not solving the control flow direction, right? Am I correct on understanding DEP_name_key and #3544 ? |
@ccll functionality like that is typically exposed through features on crates, rather than programmatic access to env vars I believe. |
@alexcrichton 'feature' works like a Boolean flag, but sometimes a String value is needed. I think this is a very valid use case, especially in code involving FFI with existing C library. |
Ah yes that's currently not supported, but if you'd like to open an issue that'd be great! |
@alexcrichton How about re-opening this issue? No? |
Mind opening a new one? This one's got a fair bit of semi-unlreated discussion now unfortunately :( |
@alexcrichton Sure, moved to #4121 . |
…ine-applicability Filter by machine applicability
For cargo's
build
scripts, it would be handy to be able to pass arguments to them via environment variables.Usage would look something like:
The text was updated successfully, but these errors were encountered: