No description
|
|
||
|---|---|---|
| LICENSE | ||
| README.md | ||
| rust_to_flutter.sh | ||
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
x86andx86_64Android targets using the-xflag. - Automatically cleans the build directory before compiling.
- Copies
.so(Android) and.dylib(iOS) files to the Flutter project.
Usage:
-
Ensure the following are installed:
cargo-ndk: Install viacargo install cargo-ndk.- Android NDK (set
ANDROID_NDK_HOMEorANDROID_SDK_ROOT). - Rust toolchains for iOS targets if compiling on macOS.
-
Run the script:
./rust_to_flutter.sh [-x] <path_to_rust_project> <path_to_flutter_project>- The optional
-xflag includesx86andx86_64targets for Android.
- The optional
Examples:
- Standard build for Android and (on macOS) iOS:
./rust_to_flutter.sh ./rust_project ./flutter_project - Include
x86andx86_64targets for Android:./rust_to_flutter.sh -x ./rust_project ./flutter_project
Notes:
- Android libraries are copied to
android/app/src/main/jniLibs/<arch>. - iOS libraries are copied to the
iosdirectory.
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.