Makepad Platform Skill
Version: makepad-widgets (dev branch) | Last Updated: 2026-01-19
Check for updates: https://crates.io/crates/makepad-widgets
You are an expert at Makepad cross-platform development. Help users by:
- Understanding platforms: Explain supported platforms and backends
- Platform-specific code: Help with conditional compilation and platform APIs
Documentation
Refer to the local files for detailed documentation:
./references/platform-support.md - Platform details and OsType
IMPORTANT: Documentation Completeness Check
Before answering questions, Claude MUST:
- Read the relevant reference file(s) listed above
- If file read fails or file is empty:
- Inform user: "本地文档不完整,建议运行
/sync-crate-skills makepad --force 更新文档"
- Still answer based on SKILL.md patterns + built-in knowledge
- If reference file exists, incorporate its content into the answer
Supported Platforms
| Platform |
Graphics Backend |
OS Module |
| macOS |
Metal |
apple/metal_*.rs, apple/cocoa_*.rs |
| iOS |
Metal |
apple/metal_*.rs, apple/ios_*.rs |
| Windows |
D3D11 |
mswindows/d3d11_*.rs, mswindows/win32_*.rs |
| Linux |
OpenGL |
linux/opengl_*.rs, linux/x11*.rs, linux/wayland*.rs |
| Web |
WebGL2 |
web/*.rs, web_browser/*.rs |
| Android |
OpenGL ES |
android/*.rs |
| OpenHarmony |
OHOS |
open_harmony/*.rs |
| OpenXR |
VR/AR |
open_xr/*.rs |
OsType Enum
pub enum OsType {
Unknown,
Windows,
Macos,
Linux { custom_window_chrome: bool },
Ios,
Android(AndroidParams),
OpenHarmony,
Web(WebParams),
OpenXR,
}
// Check platform in code
fn handle_event(&mut self, cx: &mut Cx, event: &Event) {
match cx.os_type() {
OsType::Macos => { /* macOS-specific */ }
OsType::Windows => { /* Windows-specific */ }
OsType::Web(_) => { /* Web-specific */ }
_ => {}
}
}
Platform Detection
// In Cx
impl Cx {
pub fn os_type(&self) -> OsType;
pub fn gpu_info(&self) -> &GpuInfo;
pub fn xr_capabilities(&self) -> &XrCapabilities;
pub fn cpu_cores(&self) -> usize;
}
Conditional Compilation
// Compile-time platform detection
#[cfg(target_os = "macos")]
fn macos_only() { }
#[cfg(target_os = "windows")]
fn windows_only() { }
#[cfg(target_os = "linux")]
fn linux_only() { }
#[cfg(target_arch = "wasm32")]
fn web_only() { }
#[cfg(target_os = "android")]
fn android_only() { }
#[cfg(target_os = "ios")]
fn ios_only() { }
Platform-Specific Features
Desktop (macOS/Windows/Linux)
- Window management (resize, minimize, maximize)
- File dialogs
- System menu
- Drag and drop
- Multiple monitors
Mobile (iOS/Android)
- Touch input
- Virtual keyboard
- Screen orientation
- App lifecycle (foreground/background)
Web (WebGL2)
- DOM integration
- Browser events
- Local storage
- HTTP requests
Entry Point
// App entry macro
app_main!(App);
pub struct App {
ui: WidgetRef,
}
impl LiveRegister for App {
fn live_register(cx: &mut Cx) {
// Register components
crate::makepad_widgets::live_design(cx);
}
}
impl AppMain for App {
fn handle_event(&mut self, cx: &mut Cx, event: &Event) {
// Handle app events
self.ui.handle_event(cx, event, &mut Scope::empty());
}
}
When Answering Questions
- Makepad compiles to native code for each platform (no runtime interpreter)
- Shaders are compiled at build time for each graphics backend
- Platform-specific code is in
platform/src/os/ directory
- Use
cx.os_type() for runtime platform detection
- Use
#[cfg(target_os = "...")] for compile-time platform detection
1---2name: makepad-platform3description: CRITICAL: Use for Makepad cross-platform support. Triggers on: makepad platform, makepad os, makepad macos, makepad windows, makepad linux, makepad android, makepad ios, makepad web, makepad wasm, makepad metal, makepad d3d11, makepad opengl, makepad webgl, OsType, CxOs, makepad 跨平台, makepad 平台支持4---5
6# Makepad Platform Skill
7
8> **Version:** makepad-widgets (dev branch) | **Last Updated:** 2026-01-19
9>
10> Check for updates: https://crates.io/crates/makepad-widgets
11
12You are an expert at Makepad cross-platform development. Help users by:
13- **Understanding platforms**: Explain supported platforms and backends
14- **Platform-specific code**: Help with conditional compilation and platform APIs
15
16## Documentation
17
18Refer to the local files for detailed documentation:
19- `./references/platform-support.md` - Platform details and OsType
20
21## IMPORTANT: Documentation Completeness Check
22
23**Before answering questions, Claude MUST:**
24
251. Read the relevant reference file(s) listed above
262. If file read fails or file is empty:
27 - Inform user: "本地文档不完整,建议运行 `/sync-crate-skills makepad --force` 更新文档"
28 - Still answer based on SKILL.md patterns + built-in knowledge
293. If reference file exists, incorporate its content into the answer
30
31## Supported Platforms
32
33| Platform | Graphics Backend | OS Module |
34|----------|------------------|-----------|
35| macOS | Metal | `apple/metal_*.rs`, `apple/cocoa_*.rs` |
36| iOS | Metal | `apple/metal_*.rs`, `apple/ios_*.rs` |
37| Windows | D3D11 | `mswindows/d3d11_*.rs`, `mswindows/win32_*.rs` |
38| Linux | OpenGL | `linux/opengl_*.rs`, `linux/x11*.rs`, `linux/wayland*.rs` |
39| Web | WebGL2 | `web/*.rs`, `web_browser/*.rs` |
40| Android | OpenGL ES | `android/*.rs` |
41| OpenHarmony | OHOS | `open_harmony/*.rs` |
42| OpenXR | VR/AR | `open_xr/*.rs` |
43
44## OsType Enum
45
46```rust
47pub enum OsType {
48 Unknown,
49 Windows,
50 Macos,
51 Linux { custom_window_chrome: bool },
52 Ios,
53 Android(AndroidParams),
54 OpenHarmony,
55 Web(WebParams),
56 OpenXR,
57}
58
59// Check platform in code
60fn handle_event(&mut self, cx: &mut Cx, event: &Event) {
61 match cx.os_type() {
62 OsType::Macos => { /* macOS-specific */ }
63 OsType::Windows => { /* Windows-specific */ }
64 OsType::Web(_) => { /* Web-specific */ }
65 _ => {}
66 }
67}
68```
69
70## Platform Detection
71
72```rust
73// In Cx
74impl Cx {
75 pub fn os_type(&self) -> OsType;
76 pub fn gpu_info(&self) -> &GpuInfo;
77 pub fn xr_capabilities(&self) -> &XrCapabilities;
78 pub fn cpu_cores(&self) -> usize;
79}
80```
81
82## Conditional Compilation
83
84```rust
85// Compile-time platform detection
86#[cfg(target_os = "macos")]
87fn macos_only() { }
88
89#[cfg(target_os = "windows")]
90fn windows_only() { }
91
92#[cfg(target_os = "linux")]
93fn linux_only() { }
94
95#[cfg(target_arch = "wasm32")]
96fn web_only() { }
97
98#[cfg(target_os = "android")]
99fn android_only() { }
100
101#[cfg(target_os = "ios")]
102fn ios_only() { }
103```
104
105## Platform-Specific Features
106
107### Desktop (macOS/Windows/Linux)
108- Window management (resize, minimize, maximize)
109- File dialogs
110- System menu
111- Drag and drop
112- Multiple monitors
113
114### Mobile (iOS/Android)
115- Touch input
116- Virtual keyboard
117- Screen orientation
118- App lifecycle (foreground/background)
119
120### Web (WebGL2)
121- DOM integration
122- Browser events
123- Local storage
124- HTTP requests
125
126## Entry Point
127
128```rust
129// App entry macro
130app_main!(App);
131
132pub struct App {
133 ui: WidgetRef,
134}
135
136impl LiveRegister for App {
137 fn live_register(cx: &mut Cx) {
138 // Register components
139 crate::makepad_widgets::live_design(cx);
140 }
141}
142
143impl AppMain for App {
144 fn handle_event(&mut self, cx: &mut Cx, event: &Event) {
145 // Handle app events
146 self.ui.handle_event(cx, event, &mut Scope::empty());
147 }
148}
149```
150
151## When Answering Questions
152
1531. Makepad compiles to native code for each platform (no runtime interpreter)
1542. Shaders are compiled at build time for each graphics backend
1553. Platform-specific code is in `platform/src/os/` directory
1564. Use `cx.os_type()` for runtime platform detection
1575. Use `#[cfg(target_os = "...")]` for compile-time platform detection