Skip to content

Commit

Permalink
fix: remove build-data dependency
Browse files Browse the repository at this point in the history
Simplifies getting the information we actually need, without using another dependency.

Ref #1035
  • Loading branch information
dignifiedquire authored Jun 28, 2023
1 parent dbd7bfb commit 26e9937
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 93 deletions.
98 changes: 11 additions & 87 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion deny.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ license-files = [
[advisories]
ignore = [
"RUSTSEC-2020-0168", # mach is unmaintained
"RUSTSEC-2020-0071", # time advisory, see #1035
]

[sources]
Expand Down
2 changes: 1 addition & 1 deletion iroh-net/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ tokio = { version = "1", features = ["io-util", "sync", "rt", "net", "fs", "macr
tracing-subscriber = { version = "0.3", features = ["env-filter"] }

[build-dependencies]
build-data = "0.1.3"
duct = "0.13.6"

[features]
default = ["metrics"]
Expand Down
27 changes: 23 additions & 4 deletions iroh-net/build.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,25 @@
use std::io;

use duct::cmd;

fn main() {
build_data::set_GIT_COMMIT();
build_data::set_RUSTC_VERSION();
build_data::set_SOURCE_TIMESTAMP();
build_data::no_debug_rebuilds();
// Git commit
println!("cargo:rustc-env=GIT_COMMIT={}", get_git_commit().unwrap());

// Rustc version
println!(
"cargo:rustc-env=RUSTC_VERSION={}",
get_rustc_version().unwrap()
);
}

fn get_git_commit() -> std::io::Result<String> {
cmd!("git", "rev-parse", "HEAD").read()
}

fn get_rustc_version() -> io::Result<String> {
let rustc_var = std::env::var_os("RUSTC")
.filter(|s| !s.is_empty())
.ok_or_else(|| io::Error::new(io::ErrorKind::Other, "RUSTC env var is not set"))?;
cmd!(rustc_var, "--version").read()
}
1 change: 1 addition & 0 deletions iroh-net/src/hp/hostinfo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ mod tests {
let info = Hostinfo::default();
println!("{:#?}", info);

assert!(!info.git_commit.is_empty());
assert!(!info.rust_version.is_empty());
}
}

0 comments on commit 26e9937

Please sign in to comment.