Skip to main content

Maintain/
Architecture.rs

1//! # Architecture Detection
2//!
3//! Target triple detection and platform support utilities for the
4//! Maintain build orchestrator.
5
6/// Represents a supported target platform.
7#[derive(Debug, Clone, PartialEq, Eq)]
8pub struct TargetArchitecture {
9	/// The full Rust target triple (e.g., "aarch64-apple-darwin").
10	pub Triple:String,
11
12	/// Human-readable platform name.
13	pub Name:String,
14
15	/// Whether this architecture is supported for release builds.
16	pub IsSupported:bool,
17}
18
19impl TargetArchitecture {
20	/// Returns all supported target architectures.
21	pub fn SupportedTargets() -> Vec<Self> {
22		vec![
23			Self {
24				Triple:"aarch64-apple-darwin".to_string(),
25
26				Name:"macOS (Apple Silicon)".to_string(),
27
28				IsSupported:true,
29			},
30			Self {
31				Triple:"x86_64-apple-darwin".to_string(),
32
33				Name:"macOS (Intel)".to_string(),
34
35				IsSupported:true,
36			},
37			Self {
38				Triple:"x86_64-unknown-linux-gnu".to_string(),
39
40				Name:"Linux (x86_64)".to_string(),
41
42				IsSupported:true,
43			},
44			Self {
45				Triple:"x86_64-pc-windows-msvc".to_string(),
46
47				Name:"Windows (x86_64)".to_string(),
48
49				IsSupported:true,
50			},
51		]
52	}
53
54	/// Returns the current host architecture.
55	pub fn Current() -> Self {
56		#[cfg(all(target_arch = "aarch64", target_os = "macos"))]
57		return Self {
58			Triple:"aarch64-apple-darwin".to_string(),
59
60			Name:"macOS (Apple Silicon)".to_string(),
61
62			IsSupported:true,
63		};
64
65		#[cfg(all(target_arch = "x86_64", target_os = "macos"))]
66		return Self {
67			Triple:"x86_64-apple-darwin".to_string(),
68
69			Name:"macOS (Intel)".to_string(),
70
71			IsSupported:true,
72		};
73
74		#[cfg(all(target_arch = "x86_64", target_os = "linux"))]
75		return Self {
76			Triple:"x86_64-unknown-linux-gnu".to_string(),
77
78			Name:"Linux (x86_64)".to_string(),
79
80			IsSupported:true,
81		};
82
83		#[cfg(all(target_arch = "x86_64", target_os = "windows"))]
84		return Self {
85			Triple:"x86_64-pc-windows-msvc".to_string(),
86
87			Name:"Windows (x86_64)".to_string(),
88
89			IsSupported:true,
90		};
91
92		#[cfg(not(any(
93			all(target_arch = "aarch64", target_os = "macos"),
94			all(target_arch = "x86_64", target_os = "macos"),
95			all(target_arch = "x86_64", target_os = "linux"),
96			all(target_arch = "x86_64", target_os = "windows"),
97		)))]
98		return Self { Triple:"unknown".to_string(), Name:"Unknown".to_string(), IsSupported:false };
99	}
100}