Skip to content

Commit d9d1f35

Browse files
committed
trigger rebuild if project has main.rs (but broken for other binary targets)
1 parent 3306d20 commit d9d1f35

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

src/utils/extern_args.rs

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,19 +64,30 @@ impl ExternArgs {
6464
let try_path: PathBuf = [&proj_root.to_string_lossy(), "src", fname]
6565
.iter()
6666
.collect();
67-
touch(&try_path)?;
68-
break;
69-
// file should be closed when f goes out of scope at bottom of this loop
67+
if try_path.exists() {
68+
touch(&try_path)?;
69+
self.run_cargo(proj_root)?;
70+
return Ok(self);
71+
// file should be closed when f goes out of scope at bottom of this loop
72+
}
7073
}
74+
bail!("Couldn't find source target in project {:?}", proj_root)
75+
}
7176

77+
fn run_cargo(&mut self, proj_root: &Path) -> Result<&Self> {
7278
let mut cmd = Command::new("cargo");
7379
cmd.current_dir(&proj_root).arg("build").arg("--verbose");
7480

7581
info!("running {:?}", cmd);
7682
let output = cmd.output()?;
7783

7884
if !output.status.success() {
79-
bail!("Exit status {} from {:?}", output.status, cmd);
85+
bail!(
86+
"Exit status {} from {:?}\nMessage:\n{:?}",
87+
output.status,
88+
cmd,
89+
std::string::String::from_utf8_lossy(&output.stderr)
90+
);
8091
}
8192

8293
let cmd_resp: &str = std::str::from_utf8(&output.stderr)?;

0 commit comments

Comments
 (0)