-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathArchitecture.rs
More file actions
100 lines (75 loc) · 2.25 KB
/
Architecture.rs
File metadata and controls
100 lines (75 loc) · 2.25 KB
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
//! # Architecture Detection
//!
//! Target triple detection and platform support utilities for the
//! Maintain build orchestrator.
/// Represents a supported target platform.
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct TargetArchitecture {
/// The full Rust target triple (e.g., "aarch64-apple-darwin").
pub Triple:String,
/// Human-readable platform name.
pub Name:String,
/// Whether this architecture is supported for release builds.
pub IsSupported:bool,
}
impl TargetArchitecture {
/// Returns all supported target architectures.
pub fn SupportedTargets() -> Vec<Self> {
vec![
Self {
Triple:"aarch64-apple-darwin".to_string(),
Name:"macOS (Apple Silicon)".to_string(),
IsSupported:true,
},
Self {
Triple:"x86_64-apple-darwin".to_string(),
Name:"macOS (Intel)".to_string(),
IsSupported:true,
},
Self {
Triple:"x86_64-unknown-linux-gnu".to_string(),
Name:"Linux (x86_64)".to_string(),
IsSupported:true,
},
Self {
Triple:"x86_64-pc-windows-msvc".to_string(),
Name:"Windows (x86_64)".to_string(),
IsSupported:true,
},
]
}
/// Returns the current host architecture.
pub fn Current() -> Self {
#[cfg(all(target_arch = "aarch64", target_os = "macos"))]
return Self {
Triple:"aarch64-apple-darwin".to_string(),
Name:"macOS (Apple Silicon)".to_string(),
IsSupported:true,
};
#[cfg(all(target_arch = "x86_64", target_os = "macos"))]
return Self {
Triple:"x86_64-apple-darwin".to_string(),
Name:"macOS (Intel)".to_string(),
IsSupported:true,
};
#[cfg(all(target_arch = "x86_64", target_os = "linux"))]
return Self {
Triple:"x86_64-unknown-linux-gnu".to_string(),
Name:"Linux (x86_64)".to_string(),
IsSupported:true,
};
#[cfg(all(target_arch = "x86_64", target_os = "windows"))]
return Self {
Triple:"x86_64-pc-windows-msvc".to_string(),
Name:"Windows (x86_64)".to_string(),
IsSupported:true,
};
#[cfg(not(any(
all(target_arch = "aarch64", target_os = "macos"),
all(target_arch = "x86_64", target_os = "macos"),
all(target_arch = "x86_64", target_os = "linux"),
all(target_arch = "x86_64", target_os = "windows"),
)))]
return Self { Triple:"unknown".to_string(), Name:"Unknown".to_string(), IsSupported:false };
}
}