revive_llvm_builder/platforms/
mod.rs

1//! The revive LLVM builder platforms.
2
3pub mod aarch64_linux_gnu;
4pub mod aarch64_linux_musl;
5pub mod aarch64_macos;
6pub mod shared;
7pub mod wasm32_emscripten;
8pub mod x86_64_linux_gnu;
9pub mod x86_64_linux_musl;
10pub mod x86_64_macos;
11pub mod x86_64_windows_msvc;
12
13use std::str::FromStr;
14
15/// The list of platforms used as constants.
16#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
17pub enum Platform {
18    /// The native X86 platform.
19    X86,
20    /// The native AArch64 platform.
21    AArch64,
22    /// The PolkaVM RISC-V platform.
23    PolkaVM,
24}
25
26impl FromStr for Platform {
27    type Err = String;
28
29    fn from_str(value: &str) -> Result<Self, Self::Err> {
30        match value {
31            "PolkaVM" => Ok(Self::PolkaVM),
32            value => Err(format!("Unsupported platform: `{value}`")),
33        }
34    }
35}
36
37impl std::fmt::Display for Platform {
38    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
39        match self {
40            Self::X86 => write!(f, "X86"),
41            Self::AArch64 => write!(f, "AArch64"),
42            Self::PolkaVM => write!(f, "RISCV"),
43        }
44    }
45}