gdext_gen/features/
arch.rs

1//! Module for the [`Architecture`] a `Godot` game using `Rust GDExtension` can be released for and their representations as `Godot` and `Rust` targets.
2
3/// Architecture to compile the `Godot` game and the `Rust GDExtension` for.
4#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
5pub enum Architecture {
6    /// MacOS universal library using [`Architecture::Arm64`] and [`Architecture::X86_64`], or a generic architecture for the rest.
7    Generic,
8    /// The i868 architecture.
9    X86_32,
10    /// The x86_64 architecture.
11    X86_64,
12    /// The Arm32v7 architecture.
13    Armv7,
14    /// The AArch64 architecture.
15    Arm64,
16    /// The Risc-V 64 architecture.
17    Rv64,
18    /// The WebAssembly architecture.
19    Wasm32,
20}
21
22impl Architecture {
23    /// Gets the name of the [`Architecture`] used in `Rust` target triples.
24    ///
25    /// # Returns
26    ///
27    /// The name of the [`Architecture`] for the `Rust` target triple.
28    pub fn get_rust_name(&self) -> &'static str {
29        match self {
30            Self::Generic => "",
31            Self::X86_32 => "i686",
32            Self::X86_64 => "x86_64",
33            Self::Armv7 => "armv7",
34            Self::Arm64 => "aarch64",
35            Self::Rv64 => "riscv64gc",
36            Self::Wasm32 => "wasm32",
37        }
38    }
39
40    /// Gets the name of the [`Architecture`] used in `Godot` targets.
41    ///
42    /// # Returns
43    ///
44    /// The name of the [`Architecture`] for the `Godot` target.
45    pub fn get_godot_name(&self) -> &'static str {
46        match self {
47            Self::Generic => "",
48            Self::X86_32 => "x86_32",
49            Self::X86_64 => "x86_64",
50            Self::Armv7 => "arm_32",
51            Self::Arm64 => "arm_64",
52            Self::Rv64 => "rv_64",
53            Self::Wasm32 => "wasm32",
54        }
55    }
56}