Skip to content

Commit

Permalink
linera-version: use CARGO_MANIFEST_DIR instead of PWD (#1837)
Browse files Browse the repository at this point in the history
  • Loading branch information
Twey authored and afck committed Mar 27, 2024
1 parent 950a223 commit 17a522d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
8 changes: 7 additions & 1 deletion linera-version/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,16 @@ fn main() {
wit_hash,
} = {
let mut paths = vec![];
let version_info = VersionInfo::trace_get(&mut paths).unwrap();
let version_info = VersionInfo::trace_get(
std::path::Path::new(&std::env::var("CARGO_MANIFEST_DIR").unwrap()),
&mut paths,
)
.unwrap();

for path in paths {
println!("cargo:rerun-if-changed={}", path.display());
}

version_info
};

Expand Down
6 changes: 3 additions & 3 deletions linera-version/src/version_info/type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -158,12 +158,12 @@ fn get_package_root<'r>(

impl VersionInfo {
pub fn get() -> Result<Self, Error> {
Self::trace_get(&mut vec![])
Self::trace_get(&std::env::current_dir()?, &mut vec![])
}

fn trace_get(paths: &mut Vec<PathBuf>) -> Result<Self, Error> {
fn trace_get(crate_dir: &std::path::Path, paths: &mut Vec<PathBuf>) -> Result<Self, Error> {
let metadata = cargo_metadata::MetadataCommand::new()
.current_dir(env!("PWD"))
.current_dir(crate_dir)
.exec()?;

let crate_version = Pretty::new(
Expand Down

0 comments on commit 17a522d

Please sign in to comment.