This repository was archived by the owner on Dec 29, 2022. It is now read-only.
Set missing env vars from Cargo in a compilation step#337
Merged
nrc merged 1 commit intorust-lang:masterfrom Jun 4, 2017
Merged
Set missing env vars from Cargo in a compilation step#337nrc merged 1 commit intorust-lang:masterfrom
nrc merged 1 commit intorust-lang:masterfrom
Conversation
nrc
reviewed
Jun 4, 2017
src/build.rs
Outdated
| } | ||
| } | ||
| // Compilation may depend on env vars which Cargo sets during compile-time | ||
| for (k, v) in cmd.get_envs() { |
Member
There was a problem hiding this comment.
You could use envs to set all the env vars at once without a for loop
Contributor
Author
There was a problem hiding this comment.
Would
cmd_dep_info.envs(cmd.get_envs()
.iter()
.map(|(k, v)| (k, v.unwrap_or(OsString::from("")))));
inline be better?
I wanted to retain a value Option and couldn't think of a clean way to do it, but on a second thought providing a default value seems reasonable in this case.
EDIT: That actually doesn't work and I'm not sure how to do it cleanly 😞
Member
There was a problem hiding this comment.
Something like cmd_dep_info.envs(cmd.get_envs().iter().filter_map(|k, v| v.map(|v| (k, v)))) I think
Contributor
Author
There was a problem hiding this comment.
Thanks for suggestion, didn't know how I could use filter_map with Option being one of tuple vars
Contributor
Author
|
@nrc just pushed the change to use |
Member
|
Thanks! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #290. Although this seems to fix the issue with missing env vars causing compilation failures in some projects, there may be a better way of doing that in the long-term by not having to call rustc to get dep-info, judging from the comment in code.