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
Resolve Mainframer version during build. #195
Conversation
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.
Nice
@vanniktech appreciate your interest and reviews 😽 |
@@ -14,7 +14,7 @@ use std::time::Instant; | |||
use time::*; | |||
|
|||
fn main() { | |||
println!(":: Mainframer v2.1.0\n"); | |||
println!(":: Mainframer v{}\n", env!("CARGO_PKG_VERSION")); |
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.
How does it even work though? When runtime is packaged as a binary it exports environment variables itself?
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.
env!
is a macro that compiler executes at build time, CARGO_PKG_VERSION
is an environment variable provided by cargo
to rustc
during the build, so as a result we get version inlined into the code and binary
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.
These native folks will steal your soul eventually, you know. Avoid blood-involved rituals at all costs.
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.
lol, will try
btw Kotlin might get macros support eventually
Part of #192.
Docs: https://doc.rust-lang.org/cargo/reference/environment-variables.html
Thanks @pepyakin for the link!