-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Pass the crate environment to proc macros #6820
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -51,6 +51,9 @@ pub struct ExpansionTask { | |
pub attributes: Option<Subtree>, | ||
|
||
pub lib: PathBuf, | ||
|
||
/// Environment variables to set during macro expansion. | ||
pub env: Vec<(String, String)>, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would In analysis, we need to use Here, the consumre is external process, so OsString might be better? But mostly, this is irrelevant. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, that's true. But they come from There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, in similar cases I generally prefer to shape the interface to the shape of the external world, rather than to the shape of an internal impl. It's less confusing to have some explicit glue code, than for two things share identical inteface by accident. |
||
} | ||
|
||
#[derive(Clone, Eq, PartialEq, Debug, Default, Serialize, Deserialize)] | ||
|
@@ -251,6 +254,7 @@ mod tests { | |
macro_name: Default::default(), | ||
attributes: None, | ||
lib: Default::default(), | ||
env: Default::default(), | ||
}; | ||
|
||
let json = serde_json::to_string(&task).unwrap(); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm, yeah, I think this makes sense -- proc macro can observe compile-time env variables.