-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: attempt to use runtime variable in cross
- Loading branch information
1 parent
8abbf66
commit c817a1f
Showing
3 changed files
with
37 additions
and
3 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,5 +12,5 @@ pre-build = [ | |
|
||
[build.env] | ||
volumes = [ | ||
"GIT_DIR=../.git" | ||
"GIT_DIR=./../.git" | ||
] |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,15 @@ | ||
fn main() { | ||
// Built uses the `MANIFEST_DIR` environment variable to find the location of `Cargo.toml` and | ||
// `.git`. When building from PWD=$BOLT_REPO/bolt-sidecar, the `.git` directory won't be | ||
// found, therefore the git commit info will be missing from the build-time information. | ||
// | ||
// To work around this, we also attempt to read the commit hash from the `.git/FETCH_HEAD` file | ||
// and make it available as an environment variable at runtime. | ||
|
||
// make the commit hash available as an environment variable at runtime | ||
if let Ok(commit_hash) = std::fs::read_to_string("../.git/FETCH_HEAD") { | ||
println!("cargo:rustc-env=GIT_COMMIT_HASH={}", commit_hash.trim()); | ||
} | ||
|
||
built::write_built_file().expect("Failed to acquire build-time information"); | ||
} |
This file contains 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