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

c2rust-transpile: only delete compile_commands.json if it was a temp file #1079

Merged
merged 1 commit into from
Apr 29, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion c2rust/src/bin/c2rust-transpile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,8 @@ fn main() {
tcfg.emit_modules = true
};

let mut created_temp_compile_commands = false;

let compile_commands = if args.compile_commands.len() == 1
&& args.compile_commands[0].extension() == Some(std::ffi::OsStr::new("json"))
{
Expand All @@ -244,6 +246,7 @@ fn main() {
Exactly one compile_commands.json file should be provided, or a list of source files, but not both.");
} else {
// Handle as a list of source files
created_temp_compile_commands = true;
c2rust_transpile::create_temp_compile_commands(&args.compile_commands)
};

Expand All @@ -256,7 +259,7 @@ fn main() {
c2rust_transpile::transpile(tcfg, &compile_commands, &extra_args);

// Remove the temporary compile_commands.json if it was created
if args.compile_commands.len() > 0 {
if created_temp_compile_commands {
std::fs::remove_file(&compile_commands)
.expect("Failed to remove temporary compile_commands.json");
}
Expand Down
Loading