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: |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: unknown10source: community11metadata:12 source: https://skillmd.com/skills/nimoqup046-collab/makepad-platform13---1415# Makepad Platform Skill1617> **Version:** makepad-widgets (dev branch) | **Last Updated:** 2026-01-1918>19> Check for updates: https://crates.io/crates/makepad-widgets2021You are an expert at Makepad cross-platform development. Help users by:22- **Understanding platforms**: Explain supported platforms and backends23- **Platform-specific code**: Help with conditional compilation and platform APIs2425## Documentation2627Refer to the local files for detailed documentation:28- `./references/platform-support.md` - Platform details and OsType2930## IMPORTANT: Documentation Completeness Check3132**Before answering questions, Claude MUST:**33341. Read the relevant reference file(s) listed above352. If file read fails or file is empty:36 - Inform user: "本地文档不完整,建议运行 `/sync-crate-skills makepad --force` 更新文档"37 - Still answer based on SKILL.md patterns + built-in knowledge383. If reference file exists, incorporate its content into the answer3940## Supported Platforms4142| Platform | Graphics Backend | OS Module |43|----------|------------------|-----------|44| macOS | Metal | `apple/metal_*.rs`, `apple/cocoa_*.rs` |45| iOS | Metal | `apple/metal_*.rs`, `apple/ios_*.rs` |46| Windows | D3D11 | `mswindows/d3d11_*.rs`, `mswindows/win32_*.rs` |47| Linux | OpenGL | `linux/opengl_*.rs`, `linux/x11*.rs`, `linux/wayland*.rs` |48| Web | WebGL2 | `web/*.rs`, `web_browser/*.rs` |49| Android | OpenGL ES | `android/*.rs` |50| OpenHarmony | OHOS | `open_harmony/*.rs` |51| OpenXR | VR/AR | `open_xr/*.rs` |5253## OsType Enum5455```rust56pub enum OsType {57 Unknown,58 Windows,59 Macos,60 Linux { custom_window_chrome: bool },61 Ios,62 Android(AndroidParams),63 OpenHarmony,64 Web(WebParams),65 OpenXR,66}6768// Check platform in code69fn handle_event(&mut self, cx: &mut Cx, event: &Event) {70 match cx.os_type() {71 OsType::Macos => { /* macOS-specific */ }72 OsType::Windows => { /* Windows-specific */ }73 OsType::Web(_) => { /* Web-specific */ }74 _ => {}75 }76}77```7879## Platform Detection8081```rust82// In Cx83impl Cx {84 pub fn os_type(&self) -> OsType;85 pub fn gpu_info(&self) -> &GpuInfo;86 pub fn xr_capabilities(&self) -> &XrCapabilities;87 pub fn cpu_cores(&self) -> usize;88}89```9091## Conditional Compilation9293```rust94// Compile-time platform detection95#[cfg(target_os = "macos")]96fn macos_only() { }9798#[cfg(target_os = "windows")]99fn windows_only() { }100101#[cfg(target_os = "linux")]102fn linux_only() { }103104#[cfg(target_arch = "wasm32")]105fn web_only() { }106107#[cfg(target_os = "android")]108fn android_only() { }109110#[cfg(target_os = "ios")]111fn ios_only() { }112```113114## Platform-Specific Features115116### Desktop (macOS/Windows/Linux)117- Window management (resize, minimize, maximize)118- File dialogs119- System menu120- Drag and drop121- Multiple monitors122123### Mobile (iOS/Android)124- Touch input125- Virtual keyboard126- Screen orientation127- App lifecycle (foreground/background)128129### Web (WebGL2)130- DOM integration131- Browser events132- Local storage133- HTTP requests134135## Entry Point136137```rust138// App entry macro139app_main!(App);140141pub struct App {142 ui: WidgetRef,143}144145impl LiveRegister for App {146 fn live_register(cx: &mut Cx) {147 // Register components148 crate::makepad_widgets::live_design(cx);149 }150}151152impl AppMain for App {153 fn handle_event(&mut self, cx: &mut Cx, event: &Event) {154 // Handle app events155 self.ui.handle_event(cx, event, &mut Scope::empty());156 }157}158```159160## When Answering Questions1611621. Makepad compiles to native code for each platform (no runtime interpreter)1632. Shaders are compiled at build time for each graphics backend1643. Platform-specific code is in `platform/src/os/` directory1654. Use `cx.os_type()` for runtime platform detection1665. Use `#[cfg(target_os = "...")]` for compile-time platform detection