compiler_llvm_builder/
llvm_project.rs

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