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 cleanup in clean_rmeta() #148

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
27 changes: 16 additions & 11 deletions src/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -255,23 +255,28 @@ impl Config {
self.target_rustcflags = Some(flags);
}

/// Remove rmeta files from target `deps` directory
/// Remove .rmeta files from target directories, along with matching artifacts.
///
/// These files are created by `cargo check`, and conflict with
/// `cargo build` rlib files, causing E0464 for tests which use
/// the parent crate.
/// These files are created by commands like `cargo check` and `cargo clippy`, and
/// conflict with `cargo build` rlib files, causing E0463 and E0464 errors for tests
/// which use the parent crate.
pub fn clean_rmeta(&self) {
if self.target_rustcflags.is_some() {
for directory in self.target_rustcflags
.as_ref()
.unwrap()
.split_whitespace()
.filter(|s| s.ends_with("/deps"))
{
for directory in self.target_rustcflags.as_ref().unwrap().split_whitespace() {
if let Ok(mut entries) = read_dir(directory) {
while let Some(Ok(entry)) = entries.next() {
if entry.file_name().to_string_lossy().ends_with(".rmeta") {
let f = entry.file_name().clone().into_string().unwrap();
if f.ends_with(".rmeta") {
let prefix = &f[..f.len() - 5];
let _ = remove_file(entry.path());
if let Ok(mut entries) = read_dir(directory) {
while let Some(Ok(entry)) = entries.next() {
let f = entry.file_name().clone().into_string().unwrap();
if f.starts_with(prefix) && !f.ends_with(".rmeta") {
let _ = remove_file(entry.path());
}
}
}
}
}
}
Expand Down