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 平台支持9metadata:10 source: https://skillmd.com/skills/jorcan/makepad-platform11---1213# Makepad Platform Skill1415> **Version:** makepad-widgets (dev branch) | **Last Updated:** 2026-01-1916>17> Check for updates: https://crates.io/crates/makepad-widgets1819You are an expert at Makepad cross-platform development. Help users by:20- **Understanding platforms**: Explain supported platforms and backends21- **Platform-specific code**: Help with conditional compilation and platform APIs2223## Documentation2425Refer to the local files for detailed documentation:26- `./references/platform-support.md` - Platform details and OsType2728## IMPORTANT: Documentation Completeness Check2930**Before answering questions, Claude MUST:**31321. Read the relevant reference file(s) listed above332. If file read fails or file is empty:34 - Inform user: "本地文档不完整,建议运行 `/sync-crate-skills makepad --force` 更新文档"35 - Still answer based on SKILL.md patterns + built-in knowledge363. If reference file exists, incorporate its content into the answer3738## Supported Platforms3940| Platform | Graphics Backend | OS Module |41|----------|------------------|-----------|42| macOS | Metal | `apple/metal_*.rs`, `apple/cocoa_*.rs` |43| iOS | Metal | `apple/metal_*.rs`, `apple/ios_*.rs` |44| Windows | D3D11 | `mswindows/d3d11_*.rs`, `mswindows/win32_*.rs` |45| Linux | OpenGL | `linux/opengl_*.rs`, `linux/x11*.rs`, `linux/wayland*.rs` |46| Web | WebGL2 | `web/*.rs`, `web_browser/*.rs` |47| Android | OpenGL ES | `android/*.rs` |48| OpenHarmony | OHOS | `open_harmony/*.rs` |49| OpenXR | VR/AR | `open_xr/*.rs` |5051## OsType Enum5253```rust54pub enum OsType {55 Unknown,56 Windows,57 Macos,58 Linux { custom_window_chrome: bool },59 Ios,60 Android(AndroidParams),61 OpenHarmony,62 Web(WebParams),63 OpenXR,64}6566// Check platform in code67fn handle_event(&mut self, cx: &mut Cx, event: &Event) {68 match cx.os_type() {69 OsType::Macos => { /* macOS-specific */ }70 OsType::Windows => { /* Windows-specific */ }71 OsType::Web(_) => { /* Web-specific */ }72 _ => {}73 }74}75```7677## Platform Detection7879```rust80// In Cx81impl Cx {82 pub fn os_type(&self) -> OsType;83 pub fn gpu_info(&self) -> &GpuInfo;84 pub fn xr_capabilities(&self) -> &XrCapabilities;85 pub fn cpu_cores(&self) -> usize;86}87```8889## Conditional Compilation9091```rust92// Compile-time platform detection93#[cfg(target_os = "macos")]94fn macos_only() { }9596#[cfg(target_os = "windows")]97fn windows_only() { }9899#[cfg(target_os = "linux")]100fn linux_only() { }101102#[cfg(target_arch = "wasm32")]103fn web_only() { }104105#[cfg(target_os = "android")]106fn android_only() { }107108#[cfg(target_os = "ios")]109fn ios_only() { }110```111112## Platform-Specific Features113114### Desktop (macOS/Windows/Linux)115- Window management (resize, minimize, maximize)116- File dialogs117- System menu118- Drag and drop119- Multiple monitors120121### Mobile (iOS/Android)122- Touch input123- Virtual keyboard124- Screen orientation125- App lifecycle (foreground/background)126127### Web (WebGL2)128- DOM integration129- Browser events130- Local storage131- HTTP requests132133## Entry Point134135```rust136// App entry macro137app_main!(App);138139pub struct App {140 ui: WidgetRef,141}142143impl LiveRegister for App {144 fn live_register(cx: &mut Cx) {145 // Register components146 crate::makepad_widgets::live_design(cx);147 }148}149150impl AppMain for App {151 fn handle_event(&mut self, cx: &mut Cx, event: &Event) {152 // Handle app events153 self.ui.handle_event(cx, event, &mut Scope::empty());154 }155}156```157158## When Answering Questions1591601. Makepad compiles to native code for each platform (no runtime interpreter)1612. Shaders are compiled at build time for each graphics backend1623. Platform-specific code is in `platform/src/os/` directory1634. Use `cx.os_type()` for runtime platform detection1645. Use `#[cfg(target_os = "...")]` for compile-time platform detection