#![allow(clippy::missing_errors_doc)]
pub mod arduino;
mod detect;
mod parse;
pub mod parse_archiver;
pub mod parse_linker;
pub mod parse_msvc;
mod parse_rustc;
pub mod parse_rustfmt;
pub mod response_file;
pub mod strict_paths;
#[cfg(test)]
mod tests;
use crate::core::NormalizedPath;
use std::sync::Arc;
pub use detect::detect_family;
pub use parse::parse_invocation;
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum CompilerFamily {
Gcc,
Clang,
Msvc,
Rustc,
Rustfmt,
}
impl CompilerFamily {
#[must_use]
pub fn supports_depfile(&self) -> bool {
matches!(self, CompilerFamily::Gcc | CompilerFamily::Clang)
}
#[must_use]
pub fn pch_extension(&self) -> Option<&'static str> {
match self {
CompilerFamily::Gcc => Some("gch"),
CompilerFamily::Clang => Some("pch"),
CompilerFamily::Msvc | CompilerFamily::Rustc | CompilerFamily::Rustfmt => None,
}
}
#[must_use]
pub fn is_formatter(&self) -> bool {
matches!(self, CompilerFamily::Rustfmt)
}
#[must_use]
pub fn needs_system_include_discovery(&self) -> bool {
matches!(
self,
CompilerFamily::Gcc | CompilerFamily::Clang | CompilerFamily::Msvc,
)
}
}
#[derive(Debug, Clone)]
pub enum ParsedInvocation {
Cacheable(CacheableCompilation),
MultiFile {
compilations: Vec<CacheableCompilation>,
original_args: Arc<[String]>,
source_indices: Vec<usize>,
},
NonCacheable {
reason: String,
},
}
#[derive(Debug, Clone)]
pub struct CacheableCompilation {
pub compiler: NormalizedPath,
pub family: CompilerFamily,
pub source_file: NormalizedPath,
pub output_file: NormalizedPath,
pub original_args: Arc<[String]>,
pub unknown_flags: Vec<String>,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub(crate) enum SourceMode {
Normal,
Header,
HeaderUnit,
Module,
}
impl SourceMode {
pub(crate) fn implies_compilation(self) -> bool {
matches!(self, SourceMode::Header | SourceMode::HeaderUnit)
}
}