Skip to content

Cross compilation support

Based on !37 (merged) and !40 (merged). Fixes #35 (closed).

  • Add RustTarget handling all target-specific operations.
  • Add BuiltInCargoProfile and CustomCargoProfile to customize Cargo profiles to use.
  • Add CargoPackage handling all operations on the Cargo package manifest.
  • Make BuildCrateTask depend on all Rust source files (even the ones of the dependencies cached in ~/.cargo)
  • Calculate the list of RustTarget based on the project's target and sourceSet configuration.
  • Add abstract task CargoTask which automatically tries to invoke cargo in the default installation path.
    • Make tasks inherit CargoTask
  • Create multiple BuildCrateTasks based on the generated RustTargets.
    • Detect ABI filter from android {} block and create CargoBuildTasks accordingly
    • Detect native targets and generate CargoBuildTasks accordingly
  • Create BuildCrateTask both for debug and release variants.
  • Make Jar tasks depend on build tasks for libraries published via the maven-publish plugin
  • Populate environment variables for each target
    • CC_aarch64-linux-android, CXX_aarch64-linux-android, etc., for Android
  • Pre-build operations
    • Read environment variables from Xcode and select variants for macOS and iOS
  • Post-build operations
    • Copy NDK libraries like libaaudio.so, ...
    • Copy resulting .so files to directories pointed by sourceSets.jniLibs on Android
    • Support both MinGW and MSVC on Windows (Does the current implementation correctly handle this? Kotlin/Native should not be able to link Rust static library targeting x86_64-pc-windows-msvc...)
    • Modify Dylib search paths (the ones found with otool -L) for macOS JVM (Also required for Android Compose Preview) Not required
  • Add example multiplatform app
    • Android (Compose)
    • iOS & macOS (SwiftUI)
    • Windows
    • macOS (AppKit)
    • Linux (GTK 4)
    • Java Swing
  • Support customized target name (e.g. jvm("desktop"))
  • Add unit tests for the Gradle plugin features
  • Automatically detect whether Rust toolchains are installed via rustup target list and install otherwise
  • Configure CI/CD

Issues

  • Kotlin/Native MinGW is not linkable to Rust MinGW (lld-link: warning: ignoring unknown argument: -exclude-symbols:___chkstk_ms)
  • Changes in ndkLibraries don't copy the new libraries to the final build result, even though FindDynamicLibraryTask re-runs
Edited by Chanjung Kim

Merge request reports