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
When to Use
- You need to understand or target specific platforms and graphics backends in Makepad.
- The task involves platform compatibility, conditional compilation, or OS-specific behavior across desktop, mobile, or web.
- You need guidance on backend differences such as Metal, D3D11, OpenGL, WebGL, or platform modules.
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
Limitations
- Use this skill only when the task clearly matches the scope described above.
- Do not treat the output as a substitute for environment-specific validation, testing, or expert review.
- Stop and ask for clarification if required inputs, permissions, safety boundaries, or success criteria are missing.
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## When to Use
17- You need to understand or target specific platforms and graphics backends in Makepad.
18- The task involves platform compatibility, conditional compilation, or OS-specific behavior across desktop, mobile, or web.
19- You need guidance on backend differences such as Metal, D3D11, OpenGL, WebGL, or platform modules.
20
21## Documentation
22
23Refer to the local files for detailed documentation:
24- `./references/platform-support.md` - Platform details and OsType
25
26## IMPORTANT: Documentation Completeness Check
27
28**Before answering questions, Claude MUST:**
29
301. Read the relevant reference file(s) listed above
312. If file read fails or file is empty:
32 - Inform user: "本地文档不完整,建议运行 `/sync-crate-skills makepad --force` 更新文档"
33 - Still answer based on SKILL.md patterns + built-in knowledge
343. If reference file exists, incorporate its content into the answer
35
36## Supported Platforms
37
38| Platform | Graphics Backend | OS Module |
39|----------|------------------|-----------|
40| macOS | Metal | `apple/metal_*.rs`, `apple/cocoa_*.rs` |
41| iOS | Metal | `apple/metal_*.rs`, `apple/ios_*.rs` |
42| Windows | D3D11 | `mswindows/d3d11_*.rs`, `mswindows/win32_*.rs` |
43| Linux | OpenGL | `linux/opengl_*.rs`, `linux/x11*.rs`, `linux/wayland*.rs` |
44| Web | WebGL2 | `web/*.rs`, `web_browser/*.rs` |
45| Android | OpenGL ES | `android/*.rs` |
46| OpenHarmony | OHOS | `open_harmony/*.rs` |
47| OpenXR | VR/AR | `open_xr/*.rs` |
48
49## OsType Enum
50
51```rust
52pub enum OsType {
53 Unknown,
54 Windows,
55 Macos,
56 Linux { custom_window_chrome: bool },
57 Ios,
58 Android(AndroidParams),
59 OpenHarmony,
60 Web(WebParams),
61 OpenXR,
62}
63
64// Check platform in code
65fn handle_event(&mut self, cx: &mut Cx, event: &Event) {
66 match cx.os_type() {
67 OsType::Macos => { /* macOS-specific */ }
68 OsType::Windows => { /* Windows-specific */ }
69 OsType::Web(_) => { /* Web-specific */ }
70 _ => {}
71 }
72}
73```
74
75## Platform Detection
76
77```rust
78// In Cx
79impl Cx {
80 pub fn os_type(&self) -> OsType;
81 pub fn gpu_info(&self) -> &GpuInfo;
82 pub fn xr_capabilities(&self) -> &XrCapabilities;
83 pub fn cpu_cores(&self) -> usize;
84}
85```
86
87## Conditional Compilation
88
89```rust
90// Compile-time platform detection
91#[cfg(target_os = "macos")]
92fn macos_only() { }
93
94#[cfg(target_os = "windows")]
95fn windows_only() { }
96
97#[cfg(target_os = "linux")]
98fn linux_only() { }
99
100#[cfg(target_arch = "wasm32")]
101fn web_only() { }
102
103#[cfg(target_os = "android")]
104fn android_only() { }
105
106#[cfg(target_os = "ios")]
107fn ios_only() { }
108```
109
110## Platform-Specific Features
111
112### Desktop (macOS/Windows/Linux)
113- Window management (resize, minimize, maximize)
114- File dialogs
115- System menu
116- Drag and drop
117- Multiple monitors
118
119### Mobile (iOS/Android)
120- Touch input
121- Virtual keyboard
122- Screen orientation
123- App lifecycle (foreground/background)
124
125### Web (WebGL2)
126- DOM integration
127- Browser events
128- Local storage
129- HTTP requests
130
131## Entry Point
132
133```rust
134// App entry macro
135app_main!(App);
136
137pub struct App {
138 ui: WidgetRef,
139}
140
141impl LiveRegister for App {
142 fn live_register(cx: &mut Cx) {
143 // Register components
144 crate::makepad_widgets::live_design(cx);
145 }
146}
147
148impl AppMain for App {
149 fn handle_event(&mut self, cx: &mut Cx, event: &Event) {
150 // Handle app events
151 self.ui.handle_event(cx, event, &mut Scope::empty());
152 }
153}
154```
155
156## When Answering Questions
157
1581. Makepad compiles to native code for each platform (no runtime interpreter)
1592. Shaders are compiled at build time for each graphics backend
1603. Platform-specific code is in `platform/src/os/` directory
1614. Use `cx.os_type()` for runtime platform detection
1625. Use `#[cfg(target_os = "...")]` for compile-time platform detection
163
164## Limitations
165- Use this skill only when the task clearly matches the scope described above.
166- Do not treat the output as a substitute for environment-specific validation, testing, or expert review.
167- Stop and ask for clarification if required inputs, permissions, safety boundaries, or success criteria are missing.