mirror of
https://github.com/rust-lang/cargo.git
synced 2025-09-28 11:20:36 +00:00
Delete rmeta files for rlibs during cargo clean
This commit is contained in:
parent
8f032b3bd4
commit
c2152f0805
@ -2,7 +2,7 @@ use std::collections::HashMap;
|
||||
use std::fs;
|
||||
use std::path::Path;
|
||||
|
||||
use crate::core::compiler::UnitInterner;
|
||||
use crate::core::compiler::{UnitInterner, FileFlavor};
|
||||
use crate::core::compiler::{BuildConfig, BuildContext, CompileMode, Context, Kind};
|
||||
use crate::core::profiles::UnitFor;
|
||||
use crate::core::Workspace;
|
||||
@ -119,6 +119,9 @@ pub fn clean(ws: &Workspace<'_>, opts: &CleanOptions<'_>) -> CargoResult<()> {
|
||||
if let Some(ref dst) = output.hardlink {
|
||||
rm_rf(dst, config)?;
|
||||
}
|
||||
if let FileFlavor::Linkable { rmeta } = &output.flavor {
|
||||
rm_rf(rmeta, config)?;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -294,3 +294,26 @@ fn clean_verbose() {
|
||||
.run();
|
||||
p.cargo("build").run();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn clean_remove_rlib_rmeta() {
|
||||
let p = project()
|
||||
.file(
|
||||
"Cargo.toml",
|
||||
r#"
|
||||
[package]
|
||||
name = "foo"
|
||||
version = "0.0.1"
|
||||
"#,
|
||||
)
|
||||
.file("src/lib.rs", "")
|
||||
.build();
|
||||
|
||||
p.cargo("build").run();
|
||||
assert!(p.target_debug_dir().join("libfoo.rlib").exists());
|
||||
let rmeta = p.glob("target/debug/deps/*.rmeta").next().unwrap().unwrap();
|
||||
assert!(rmeta.exists());
|
||||
p.cargo("clean -p foo").run();
|
||||
assert!(!p.target_debug_dir().join("libfoo.rlib").exists());
|
||||
assert!(!rmeta.exists());
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user