https://github.com/randogoth/rust-to-flutter
bash script to cross compile a Rust library to mobile targets and copy the binaries into the correct Flutter directories
https://github.com/randogoth/rust-to-flutter
cargo cross-compilation flutter ndk rename rust
Last synced: 7 months ago
JSON representation
bash script to cross compile a Rust library to mobile targets and copy the binaries into the correct Flutter directories
- Host: GitHub
- URL: https://github.com/randogoth/rust-to-flutter
- Owner: randogoth
- License: cc0-1.0
- Created: 2025-01-11T10:29:13.000Z (9 months ago)
- Default Branch: main
- Last Pushed: 2025-01-19T19:05:15.000Z (9 months ago)
- Last Synced: 2025-01-19T20:19:48.533Z (9 months ago)
- Topics: cargo, cross-compilation, flutter, ndk, rename, rust
- Language: Shell
- Homepage:
- Size: 16.6 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
### Rust to Flutter Build Script
This script compiles a Rust library for both Android and iOS and copies the generated libraries to the appropriate Flutter project directories.
#### Features:
- Installs missing cross-compilation targets.
- Compiles Rust for Android.
- Conditionally compiles Rust for iOS if running on macOS.
- Optionally includes `x86` and `x86_64` Android/iOS targets using the `-x` flag.
- Automatically cleans the build directory before compiling.
- Copies `.so` (Android) and `.dylib` (iOS) files to the Flutter project.#### Usage:
1. Ensure the following are installed:
- `cargo-ndk`: Install via `cargo install cargo-ndk`.
- Android NDK (set `ANDROID_NDK_HOME` or `ANDROID_SDK_ROOT`).
- Rust toolchains for iOS targets if compiling on macOS.2. Run the script:
```bash
./rust_to_flutter.sh [-x]
```- The optional `-x` flag includes `x86` and `x86_64` targets for Android.
#### Examples:
- Standard build for Android and (on macOS) iOS:
```bash
./rust_to_flutter.sh ./rust_project ./flutter_project
```
- Include `x86` and `x86_64` targets for Android:
```bash
./rust_to_flutter.sh -x ./rust_project ./flutter_project
```#### Notes:
- Android libraries are copied to `android/app/src/main/jniLibs/`.
- iOS libraries are copied to the `ios` directory.#### Additional Information:
- iOS compilation is skipped automatically if the script is not running on macOS.
- The script checks for missing Rust cross-compilation targets and installs them as needed.