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

Better error messages in build.rs #2173

Merged
merged 2 commits into from
May 22, 2023
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
13 changes: 12 additions & 1 deletion crates/re_build_build_info/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,10 @@ pub fn export_env_vars() {

fn rerun_if_changed(path: &str) {
// Make sure the file exists, otherwise we'll be rebuilding all the time.
assert!(std::path::Path::new(path).exists(), "Failed to find {path}");
assert!(
std::path::Path::new(path).exists(),
"Failed to find {path:?}"
);
println!("cargo:rerun-if-changed={path}");
}

Expand All @@ -96,6 +99,14 @@ fn run_command(cmd: &str, args: &[&str]) -> anyhow::Result<String> {
.args(args)
.output()
.with_context(|| format!("running '{cmd}'"))?;

anyhow::ensure!(
output.status.success(),
"Failed to run '{cmd} {args:?}':\n{}\n{}\n",
String::from_utf8_lossy(&output.stdout),
String::from_utf8_lossy(&output.stderr),
);

Ok(String::from_utf8(output.stdout)?.trim().to_owned())
}

Expand Down