Skip to content
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

Merged
merged 1 commit into from Mar 1, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/main.rs
Expand Up @@ -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"));
Copy link
Contributor

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?

Copy link
Contributor Author

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

Copy link
Contributor

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.

Copy link
Contributor Author

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


let args = match Args::parse(env::args().skip(1).collect()) {
Err(message) => exit_with_error(&message, 1),
Expand Down