From 61929a540553ccc42f744989242212f539745d5e Mon Sep 17 00:00:00 2001 From: Flux Date: Tue, 21 Jan 2025 17:07:27 +0200 Subject: [PATCH] Update README.md --- README.md | 34 ++++++++++++++++++++++++---------- 1 file changed, 24 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 818f389..600b84e 100644 --- a/README.md +++ b/README.md @@ -1,28 +1,42 @@ +### 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 +- 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 targets using the `-x` flag. - Automatically cleans the build directory before compiling. -- Copies `.so` (Android) and `.a` (iOS) files to the Flutter project. +- Copies `.so` (Android) and `.dylib` (iOS) files to the Flutter project. #### Usage: 1. Ensure the following are installed: - - `cargo-ndk`: `cargo install cargo-ndk` - - Android NDK (set `ANDROID_NDK_HOME` or `ANDROID_SDK_ROOT`) - - Rust toolchains for iOS targets if compiling on macOS + - `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 + ./rust_to_flutter.sh [-x] ``` -#### Example: -```bash -./rust_to_flutter.sh ./rust_project ./flutter_project -``` + - 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.