Skip to content

Commit

Permalink
Fix detect_compiler_family.c not being created (#1072)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jake-Shadle authored May 19, 2024
1 parent 61b81c8 commit 8f6d07f
Showing 1 changed file with 22 additions and 6 deletions.
28 changes: 22 additions & 6 deletions src/tool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,12 +110,28 @@ impl Tool {
cargo_output: &CargoOutput,
out_dir: Option<&Path>,
) -> Result<ToolFamily, Error> {
let tmp = NamedTempfile::new(
&out_dir
.map(Cow::Borrowed)
.unwrap_or_else(|| Cow::Owned(env::temp_dir())),
"detect_compiler_family.c",
)?;
let out_dir = out_dir
.map(Cow::Borrowed)
.unwrap_or_else(|| Cow::Owned(env::temp_dir()));

// Ensure all the parent directories exist otherwise temp file creation
// will fail
std::fs::create_dir_all(&out_dir).map_err(|err| Error {
kind: ErrorKind::IOError,
message: format!("failed to create OUT_DIR '{}': {}", out_dir.display(), err)
.into(),
})?;

let tmp =
NamedTempfile::new(&out_dir, "detect_compiler_family.c").map_err(|err| Error {
kind: ErrorKind::IOError,
message: format!(
"failed to create detect_compiler_family.c temp file in '{}': {}",
out_dir.display(),
err
)
.into(),
})?;
tmp.file()
.write_all(include_bytes!("detect_compiler_family.c"))?;

Expand Down

0 comments on commit 8f6d07f

Please sign in to comment.