Skip to content

Commit

Permalink
Cargo: Fix CI after refactorings
Browse files Browse the repository at this point in the history
  • Loading branch information
xFrednet committed Jul 11, 2023
1 parent a7c4b11 commit ed7783b
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions cargo-marker/src/backend/lints/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,16 @@ const DYNAMIC_LIB_FILE_ENDING: &str = "dylib";
#[cfg(target_os = "windows")]
const DYNAMIC_LIB_FILE_ENDING: &str = "dll";

/// A list of file endings which are expected to be inside the lint crate dir.
/// It's assumed that these can be safely removed.
const ARTIFACT_ENDINGS: &[&str] = &[
DYNAMIC_LIB_FILE_ENDING,
#[cfg(target_os = "windows")]
"exp",
#[cfg(target_os = "windows")]
"lib",
];

pub fn build_lints(sources: &[LintCrateSource], config: &Config) -> Result<Vec<LintCrate>, ExitStatus> {
// By default Cargo doesn't provide the path of the compiled lint crate.
// As a work around, we use the `--out-dir` option to make cargo copy all
Expand Down Expand Up @@ -61,10 +71,10 @@ fn clear_lints_dir(lints_dir: &Path) -> Result<(), ExitStatus> {
// Delete all files
match std::fs::read_dir(lints_dir) {
Ok(dir) => {
let ending = OsStr::new(DYNAMIC_LIB_FILE_ENDING);
let endings: Vec<_> = ARTIFACT_ENDINGS.iter().map(OsStr::new).collect();
for file in dir {
let file = file.unwrap().path();
if file.extension() == Some(ending) {
if file.extension().map_or(false, |ending| endings.contains(&ending)) {
std::fs::remove_file(file).map_err(|_| ExitStatus::LintCrateBuildFail)?;
} else {
eprintln!(
Expand Down

0 comments on commit ed7783b

Please sign in to comment.