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