|
| 1 | +# RustDesk Guide |
| 2 | + |
| 3 | +This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. |
| 4 | + |
| 5 | +## Development Commands |
| 6 | + |
| 7 | +### Build Commands |
| 8 | +- `cargo run` - Build and run the desktop application (requires libsciter library) |
| 9 | +- `python3 build.py --flutter` - Build Flutter version (desktop) |
| 10 | +- `python3 build.py --flutter --release` - Build Flutter version in release mode |
| 11 | +- `python3 build.py --hwcodec` - Build with hardware codec support |
| 12 | +- `python3 build.py --vram` - Build with VRAM feature (Windows only) |
| 13 | +- `cargo build --release` - Build Rust binary in release mode |
| 14 | +- `cargo build --features hwcodec` - Build with specific features |
| 15 | + |
| 16 | +### Flutter Mobile Commands |
| 17 | +- `cd flutter && flutter build android` - Build Android APK |
| 18 | +- `cd flutter && flutter build ios` - Build iOS app |
| 19 | +- `cd flutter && flutter run` - Run Flutter app in development mode |
| 20 | +- `cd flutter && flutter test` - Run Flutter tests |
| 21 | + |
| 22 | +### Testing |
| 23 | +- `cargo test` - Run Rust tests |
| 24 | +- `cd flutter && flutter test` - Run Flutter tests |
| 25 | + |
| 26 | +### Platform-Specific Build Scripts |
| 27 | +- `flutter/build_android.sh` - Android build script |
| 28 | +- `flutter/build_ios.sh` - iOS build script |
| 29 | +- `flutter/build_fdroid.sh` - F-Droid build script |
| 30 | + |
| 31 | +## Project Architecture |
| 32 | + |
| 33 | +### Directory Structure |
| 34 | +- **`src/`** - Main Rust application code |
| 35 | + - `src/ui/` - Legacy Sciter UI (deprecated, use Flutter instead) |
| 36 | + - `src/server/` - Audio/clipboard/input/video services and network connections |
| 37 | + - `src/client.rs` - Peer connection handling |
| 38 | + - `src/platform/` - Platform-specific code |
| 39 | +- **`flutter/`** - Flutter UI code for desktop and mobile |
| 40 | +- **`libs/`** - Core libraries |
| 41 | + - `libs/hbb_common/` - Video codec, config, network wrapper, protobuf, file transfer utilities |
| 42 | + - `libs/scrap/` - Screen capture functionality |
| 43 | + - `libs/enigo/` - Platform-specific keyboard/mouse control |
| 44 | + - `libs/clipboard/` - Cross-platform clipboard implementation |
| 45 | + |
| 46 | +### Key Components |
| 47 | +- **Remote Desktop Protocol**: Custom protocol implemented in `src/rendezvous_mediator.rs` for communicating with rustdesk-server |
| 48 | +- **Screen Capture**: Platform-specific screen capture in `libs/scrap/` |
| 49 | +- **Input Handling**: Cross-platform input simulation in `libs/enigo/` |
| 50 | +- **Audio/Video Services**: Real-time audio/video streaming in `src/server/` |
| 51 | +- **File Transfer**: Secure file transfer implementation in `libs/hbb_common/` |
| 52 | + |
| 53 | +### UI Architecture |
| 54 | +- **Legacy UI**: Sciter-based (deprecated) - files in `src/ui/` |
| 55 | +- **Modern UI**: Flutter-based - files in `flutter/` |
| 56 | + - Desktop: `flutter/lib/desktop/` |
| 57 | + - Mobile: `flutter/lib/mobile/` |
| 58 | + - Shared: `flutter/lib/common/` and `flutter/lib/models/` |
| 59 | + |
| 60 | +## Important Build Notes |
| 61 | + |
| 62 | +### Dependencies |
| 63 | +- Requires vcpkg for C++ dependencies: `libvpx`, `libyuv`, `opus`, `aom` |
| 64 | +- Set `VCPKG_ROOT` environment variable |
| 65 | +- Download appropriate Sciter library for legacy UI support |
| 66 | + |
| 67 | +### Ignore Patterns |
| 68 | +When working with files, ignore these directories: |
| 69 | +- `target/` - Rust build artifacts |
| 70 | +- `flutter/build/` - Flutter build output |
| 71 | +- `flutter/.dart_tool/` - Flutter tooling files |
| 72 | + |
| 73 | +### Cross-Platform Considerations |
| 74 | +- Windows builds require additional DLLs and virtual display drivers |
| 75 | +- macOS builds need proper signing and notarization for distribution |
| 76 | +- Linux builds support multiple package formats (deb, rpm, AppImage) |
| 77 | +- Mobile builds require platform-specific toolchains (Android SDK, Xcode) |
| 78 | + |
| 79 | +### Feature Flags |
| 80 | +- `hwcodec` - Hardware video encoding/decoding |
| 81 | +- `vram` - VRAM optimization (Windows only) |
| 82 | +- `flutter` - Enable Flutter UI |
| 83 | +- `unix-file-copy-paste` - Unix file clipboard support |
| 84 | +- `screencapturekit` - macOS ScreenCaptureKit (macOS only) |
| 85 | + |
| 86 | +### Config |
| 87 | +All configurations or options are under `libs/hbb_common/src/config.rs` file, 4 types: |
| 88 | +- Settings |
| 89 | +- Local |
| 90 | +- Display |
| 91 | +- Built-in |
| 92 | + |
| 93 | +## Rust Rules |
| 94 | + |
| 95 | +- In Rust code, do not introduce `unwrap()` or `expect()`. |
| 96 | +- Allowed exceptions: |
| 97 | +- Tests may use `unwrap()` or `expect()` when it keeps the test focused and readable. |
| 98 | +- Lock acquisition may use `unwrap()` only when the locking API makes that the practical option and the failure mode is poison handling rather than normal control flow. |
| 99 | +- Outside those exceptions, propagate errors, handle them explicitly, or use safer fallbacks instead of `unwrap()` and `expect()`. |
| 100 | + |
| 101 | +## Editing Hygiene |
| 102 | + |
| 103 | +- Do not introduce formatting-only changes. |
| 104 | +- Do not run repository-wide formatters or reflow unrelated code unless the |
| 105 | + user explicitly asks for formatting. |
| 106 | +- Keep diffs limited to semantic changes required for the task. |
0 commit comments