compiler_llvm_builder/
target_env.rs

1//!
2//! The target environments to build LLVM.
3//!
4
5///
6/// The list of target environments used as constants.
7///
8#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
9pub enum TargetEnv {
10    /// The GNU target environment.
11    GNU,
12    /// The MUSL target environment.
13    MUSL,
14}
15
16impl std::str::FromStr for TargetEnv {
17    type Err = String;
18
19    fn from_str(value: &str) -> Result<Self, Self::Err> {
20        match value {
21            "gnu" => Ok(Self::GNU),
22            "musl" => Ok(Self::MUSL),
23            value => Err(format!("Unsupported target environment: `{}`", value)),
24        }
25    }
26}
27
28impl std::fmt::Display for TargetEnv {
29    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
30        match self {
31            Self::GNU => write!(f, "gnu"),
32            Self::MUSL => write!(f, "musl"),
33        }
34    }
35}