revive_llvm_builder/
llvm_project.rs

1//! The LLVM projects to enable during the build.
2
3/// The list of LLVM projects used as constants.
4#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
5pub enum LLVMProject {
6    /// The Clang compiler.
7    CLANG,
8    /// LLD, the LLVM linker.
9    LLD,
10    /// The LLVM debugger.
11    LLDB,
12    /// The MLIR compiler.
13    MLIR,
14}
15
16impl std::str::FromStr for LLVMProject {
17    type Err = String;
18
19    fn from_str(value: &str) -> Result<Self, Self::Err> {
20        match value.to_lowercase().as_str() {
21            "clang" => Ok(Self::CLANG),
22            "lld" => Ok(Self::LLD),
23            "lldb" => Ok(Self::LLDB),
24            "mlir" => Ok(Self::MLIR),
25            value => Err(format!("Unsupported LLVM project to enable: `{value}`")),
26        }
27    }
28}
29
30impl std::fmt::Display for LLVMProject {
31    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
32        match self {
33            Self::CLANG => write!(f, "clang"),
34            Self::LLD => write!(f, "lld"),
35            Self::LLDB => write!(f, "lldb"),
36            Self::MLIR => write!(f, "mlir"),
37        }
38    }
39}