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---56# Makepad Platform Skill78> **Version:** makepad-widgets (dev branch) | **Last Updated:** 2026-01-199>10> Check for updates: https://crates.io/crates/makepad-widgets1112You are an expert at Makepad cross-platform development. Help users by:13- **Understanding platforms**: Explain supported platforms and backends14- **Platform-specific code**: Help with conditional compilation and platform APIs1516## Documentation1718Refer to the local files for detailed documentation:19- `./references/platform-support.md` - Platform details and OsType2021## IMPORTANT: Documentation Completeness Check2223**Before answering questions, Claude MUST:**24251. Read the relevant reference file(s) listed above262. 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 knowledge293. If reference file exists, incorporate its content into the answer3031## Supported Platforms3233| 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` |4344## OsType Enum4546```rust47pub 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}5859// Check platform in code60fn 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```6970## Platform Detection7172```rust73// In Cx74impl 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```8182## Conditional Compilation8384```rust85// Compile-time platform detection86#[cfg(target_os = "macos")]87fn macos_only() { }8889#[cfg(target_os = "windows")]90fn windows_only() { }9192#[cfg(target_os = "linux")]93fn linux_only() { }9495#[cfg(target_arch = "wasm32")]96fn web_only() { }9798#[cfg(target_os = "android")]99fn android_only() { }100101#[cfg(target_os = "ios")]102fn ios_only() { }103```104105## Platform-Specific Features106107### Desktop (macOS/Windows/Linux)108- Window management (resize, minimize, maximize)109- File dialogs110- System menu111- Drag and drop112- Multiple monitors113114### Mobile (iOS/Android)115- Touch input116- Virtual keyboard117- Screen orientation118- App lifecycle (foreground/background)119120### Web (WebGL2)121- DOM integration122- Browser events123- Local storage124- HTTP requests125126## Entry Point127128```rust129// App entry macro130app_main!(App);131132pub struct App {133 ui: WidgetRef,134}135136impl LiveRegister for App {137 fn live_register(cx: &mut Cx) {138 // Register components139 crate::makepad_widgets::live_design(cx);140 }141}142143impl AppMain for App {144 fn handle_event(&mut self, cx: &mut Cx, event: &Event) {145 // Handle app events146 self.ui.handle_event(cx, event, &mut Scope::empty());147 }148}149```150151## When Answering Questions1521531. Makepad compiles to native code for each platform (no runtime interpreter)1542. Shaders are compiled at build time for each graphics backend1553. Platform-specific code is in `platform/src/os/` directory1564. Use `cx.os_type()` for runtime platform detection1575. Use `#[cfg(target_os = "...")]` for compile-time platform detection