Skip to content

Commit

Permalink
PR comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Diane Huxley committed Aug 15, 2024
1 parent d7558e4 commit 367b6d4
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Justfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ setup:
source bin/activate-hermit
git submodule update --init --recursive
if [[ "$(cargo 2>&1)" == *"rustup could not choose a version of cargo to run"* ]]; then
rustup default 1.78.0
rustup default 1.80.0
rustup target add aarch64-apple-darwin
fi

Expand Down
19 changes: 19 additions & 0 deletions crates/web5/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
use std::process::Command;
use std::env;

fn main() {
// Execute the `git rev-parse HEAD` command to get the current commit hash
let output = Command::new("git")
.args(&["rev-parse", "HEAD"])
.output()
.expect("Failed to execute git command");

// Convert the output to a string
let git_hash = String::from_utf8(output.stdout).expect("Invalid UTF-8 sequence");

// Remove the newline character from the commit hash
let git_hash_trimmed = git_hash.trim();

// Pass the commit hash to the compiler as an environment variable
println!("cargo:rustc-env=WEB5_GIT_COMMIT_HASH={}", git_hash_trimmed);
}
4 changes: 2 additions & 2 deletions crates/web5/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@ pub(crate) mod logging {
($msg:expr, $($arg:tt)*) => {
if let Some(ref level) = *$crate::LOG_LEVEL {
if level == "DEBUG" {
println!("[DEBUG] {}", format!($msg, $($arg)*));
println!("[DEBUG] {}:{}", env!("GIT_COMMIT_HASH"), format!($msg, $($arg)*));
}
}
};
($closure:expr) => {
if let Some(ref level) = *$crate::LOG_LEVEL {
if level == "DEBUG" {
let msg = $closure();
println!("[DEBUG] {}", msg);
println!("[DEBUG] {}:{}", env!("GIT_COMMIT_HASH"), msg);
}
}
};
Expand Down

0 comments on commit 367b6d4

Please sign in to comment.