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: |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: critical10source: community11date_added: "2026-09-04"12metadata:13 source: https://skillmd.com/skills/francostino/makepad-platform14---1516# Makepad Platform Skill1718> **Version:** makepad-widgets (dev branch) | **Last Updated:** 2026-01-1919>20> Check for updates: https://crates.io/crates/makepad-widgets2122You are an expert at Makepad cross-platform development. Help users by:23- **Understanding platforms**: Explain supported platforms and backends24- **Platform-specific code**: Help with conditional compilation and platform APIs2526## When to Use27- You need to understand or target specific platforms and graphics backends in Makepad.28- The task involves platform compatibility, conditional compilation, or OS-specific behavior across desktop, mobile, or web.29- You need guidance on backend differences such as Metal, D3D11, OpenGL, WebGL, or platform modules.3031## Documentation3233Refer to the local files for detailed documentation:34- `./references/platform-support.md` - Platform details and OsType3536## IMPORTANT: Documentation Completeness Check3738**Before answering questions, Claude MUST:**39401. Read the relevant reference file(s) listed above412. If file read fails or file is empty:42 - Inform user: "本地文档不完整,建议运行 `/sync-crate-skills makepad --force` 更新文档"43 - Still answer based on SKILL.md patterns + built-in knowledge443. If reference file exists, incorporate its content into the answer4546## Supported Platforms4748| Platform | Graphics Backend | OS Module |49|----------|------------------|-----------|50| macOS | Metal | `apple/metal_*.rs`, `apple/cocoa_*.rs` |51| iOS | Metal | `apple/metal_*.rs`, `apple/ios_*.rs` |52| Windows | D3D11 | `mswindows/d3d11_*.rs`, `mswindows/win32_*.rs` |53| Linux | OpenGL | `linux/opengl_*.rs`, `linux/x11*.rs`, `linux/wayland*.rs` |54| Web | WebGL2 | `web/*.rs`, `web_browser/*.rs` |55| Android | OpenGL ES | `android/*.rs` |56| OpenHarmony | OHOS | `open_harmony/*.rs` |57| OpenXR | VR/AR | `open_xr/*.rs` |5859## OsType Enum6061```rust62pub enum OsType {63 Unknown,64 Windows,65 Macos,66 Linux { custom_window_chrome: bool },67 Ios,68 Android(AndroidParams),69 OpenHarmony,70 Web(WebParams),71 OpenXR,72}7374// Check platform in code75fn handle_event(&mut self, cx: &mut Cx, event: &Event) {76 match cx.os_type() {77 OsType::Macos => { /* macOS-specific */ }78 OsType::Windows => { /* Windows-specific */ }79 OsType::Web(_) => { /* Web-specific */ }80 _ => {}81 }82}83```8485## Platform Detection8687```rust88// In Cx89impl Cx {90 pub fn os_type(&self) -> OsType;91 pub fn gpu_info(&self) -> &GpuInfo;92 pub fn xr_capabilities(&self) -> &XrCapabilities;93 pub fn cpu_cores(&self) -> usize;94}95```9697## Conditional Compilation9899```rust100// Compile-time platform detection101#[cfg(target_os = "macos")]102fn macos_only() { }103104#[cfg(target_os = "windows")]105fn windows_only() { }106107#[cfg(target_os = "linux")]108fn linux_only() { }109110#[cfg(target_arch = "wasm32")]111fn web_only() { }112113#[cfg(target_os = "android")]114fn android_only() { }115116#[cfg(target_os = "ios")]117fn ios_only() { }118```119120## Platform-Specific Features121122### Desktop (macOS/Windows/Linux)123- Window management (resize, minimize, maximize)124- File dialogs125- System menu126- Drag and drop127- Multiple monitors128129### Mobile (iOS/Android)130- Touch input131- Virtual keyboard132- Screen orientation133- App lifecycle (foreground/background)134135### Web (WebGL2)136- DOM integration137- Browser events138- Local storage139- HTTP requests140141## Entry Point142143```rust144// App entry macro145app_main!(App);146147pub struct App {148 ui: WidgetRef,149}150151impl LiveRegister for App {152 fn live_register(cx: &mut Cx) {153 // Register components154 crate::makepad_widgets::live_design(cx);155 }156}157158impl AppMain for App {159 fn handle_event(&mut self, cx: &mut Cx, event: &Event) {160 // Handle app events161 self.ui.handle_event(cx, event, &mut Scope::empty());162 }163}164```165166## When Answering Questions1671681. Makepad compiles to native code for each platform (no runtime interpreter)1692. Shaders are compiled at build time for each graphics backend1703. Platform-specific code is in `platform/src/os/` directory1714. Use `cx.os_type()` for runtime platform detection1725. Use `#[cfg(target_os = "...")]` for compile-time platform detection173174## Limitations175- Use this skill only when the task clearly matches the scope described above.176- Do not treat the output as a substitute for environment-specific validation, testing, or expert review.177- Stop and ask for clarification if required inputs, permissions, safety boundaries, or success criteria are missing.