1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
//!
//! The ZKsync LLVM builder platforms.
//!

pub mod aarch64_linux_gnu;
pub mod aarch64_linux_musl;
pub mod aarch64_macos;
pub mod shared;
pub mod x86_64_linux_gnu;
pub mod x86_64_linux_musl;
pub mod x86_64_macos;
pub mod x86_64_windows_gnu;

use std::str::FromStr;

///
/// The list of platforms used as constants.
///
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub enum Platform {
    /// The native X86 platform.
    X86,
    /// The native AArch64 platform.
    AArch64,
    /// The EraVM back end developed by Matter Labs.
    EraVM,
    /// The EVM back end developed by Matter Labs.
    EVM,
}

impl FromStr for Platform {
    type Err = String;

    fn from_str(value: &str) -> Result<Self, Self::Err> {
        match value {
            "EraVM" => Ok(Self::EraVM),
            "EVM" => Ok(Self::EVM),
            value => Err(format!("Unsupported platform: `{}`", value)),
        }
    }
}

impl std::fmt::Display for Platform {
    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
        match self {
            Self::X86 => write!(f, "X86"),
            Self::AArch64 => write!(f, "AArch64"),
            Self::EraVM => write!(f, "EraVM"),
            Self::EVM => write!(f, "EVM"),
        }
    }
}