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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
use TokenStream;
use quote;
use ;
/// Procedural macro to generate platform registration code.
///
/// This macro adds a `register_platform()` method to a struct that registers it
/// with the global platform registry. The macro requires a `compat_string` parameter
/// that specifies the device tree compatibility string(s) the platform supports.
///
/// The macro also generates a `COMPAT_STRING` constant that contains the compatibility string.
///
/// **Important**: Each platform MUST define an `is_available()` function that returns `bool`.
/// - For built-in platforms (in `platforms` dir): `pub fn is_available() -> bool { true }`
/// - For softeners (in `softeners` dir): Custom logic checking if dependencies exist
///
/// # Arguments
///
/// * `compat_string` - Comma-separated device tree compatibility strings
///
/// # Generated Code
///
/// The macro generates:
/// ```rust,ignore
/// impl YourStruct {
/// #[doc(hidden)]
/// pub fn register_platform() {
/// crate::platforms::platform::register_platform(
/// "compat_string",
/// || Box::new(Self::new()),
/// Self::is_available
/// );
/// }
///
/// pub const COMPAT_STRING: &'static str = "compat_string";
/// }
/// ```
///
/// # Usage
///
/// Built-in platform (always available):
/// ```rust,ignore
/// #[platform(compat_string = "xlnx-sys")]
/// pub struct XilinxSysPlatform { }
///
/// impl XilinxSysPlatform {
/// pub fn new() -> Self { Self }
///
/// pub fn is_available() -> bool {
/// true // Always available
/// }
/// }
/// ```
///
/// Softener with custom availability:
/// ```rust,ignore
/// #[platform(compat_string = "xlnx,dfx-mgr")]
/// pub struct MyPlatform { }
///
/// impl MyPlatform {
/// pub fn new() -> Self { Self }
///
/// pub fn is_available(&self) -> bool {
/// // Check if required binary exists
/// std::path::Path::new("/usr/bin/dfx-mgr-client").exists()
/// }
/// }
/// ```