zhanghandong/makepad-skills
Overview
This skill guides Makepad cross-platform development and platform support decisions. It explains supported OS targets, graphics backends, runtime and compile-time detection, and where to place platform-specific code. Use it to design conditional code paths, pick correct backends, and handle platform features consistently.
How this skill works
The skill inspects the declared OsType enum, platform modules, and available backends (Metal, D3D11, OpenGL, WebGL2, OpenGL ES, OHOS, OpenXR). It explains runtime checks via cx.os_type() and gpu/xr/cpu info and shows compile-time gates using #[cfg(target_os = "...")] and #[cfg(target_arch = "wasm32")]. It maps features (windowing, input, lifecycle) to desktop, mobile, and web modules so you know which files and APIs to touch.
When to use it
- Choosing graphics backend per platform (Metal, D3D11, OpenGL, WebGL2, OpenGL ES)
- Adding platform-specific code or files under platform/src/os/
- Implementing runtime behavior differences with cx.os_type()
- Guarding code at compile time with #[cfg(...)]
- Handling input, lifecycle, or windowing differences across desktop/mobile/web
Best practices
- Use cx.os_type() for runtime branching to keep single binary logic where needed
- Prefer #[cfg(...)] for OS-specific code to avoid unused compilation on other targets
- Keep platform modules organized (apple/, mswindows/, linux/, web/, android/, open_harmony/, open_xr/) and mirror API differences there
- Compile shaders per backend at build time; do not assume runtime shader compilation
- Query gpu_info(), xr_capabilities(), and cpu_cores() early to adapt behavior and performance settings
Example use cases
- Detect macOS to enable Metal-specific features in apple/metal_*.rs and apple/cocoa_*.rs
- Use #[cfg(target_arch = "wasm32")] to include web_browser/*.rs and web/*.rs only for WebAssembly builds
- Handle touch and virtual keyboard only on mobile platforms (android/*.rs, ios modules)
- Switch to D3D11 path and mswindows/d3d11_*.rs implementations for Windows builds
- Query cx.gpu_info() to choose rendering quality or fallbacks at startup
FAQ
Call cx.os_type() and match on OsType (e.g., OsType::Macos, OsType::Web(_)) to branch behavior.
How do I compile platform-specific code?
Use Rust conditional compilation attributes like #[cfg(target_os = "macos")] or #[cfg(target_arch = "wasm32")] to include code only on those targets.
Where are platform implementations located?
Platform-specific sources live under platform/src/os/ with modules like apple/, mswindows/, linux/, web/, android/, open_harmony/, and open_xr/.
10 skills
This skill helps you understand Makepad platform support across macOS, Windows, Linux, Web, and mobile backends and use conditional compilation effectively.
This skill helps you write and explain Makepad DSL with inheritance, overriding, and live-reload patterns for efficient UI definitions.
This skill helps you implement Makepad animation patterns, generating code and answering questions about states, transitions, and timelines for dynamic UI.
This skill helps you integrate Matrix SDK with Makepad applications, enabling real-time timelines, room management, and UI-driven async operations.
This skill helps you author and execute dynamic Splash scripts for AI-assisted UI, async tasks, and rapid prototyping.
This skill helps you build cross-platform AI chat interfaces with Makepad using MolyKit, offering ready-made widgets, BotClient, and SSE streaming.
This skill guides structuring Makepad apps with Robius patterns, enabling async backend integration, signal-driven UI updates, and Tokio-runtime orchestration.
This skill helps you generate and explain Makepad shader code, focusing on Sdf2d, gradients, and advanced drawing patterns for widgets.
This skill helps you handle Makepad events and actions, enabling widget-to-parent communication and robust event flow.
This skill helps you configure and render crisp text with Makepad fonts, layouts, and SDF-based GPU rendering.