28 lines
923 B
Groovy
28 lines
923 B
Groovy
// This file handles building the Rust library for Android
|
|
|
|
def cargoNdkVersion = "3.4.0"
|
|
|
|
// Task to ensure cargo-ndk is installed
|
|
task installCargoNdk(type: Exec) {
|
|
commandLine 'cargo', 'install', 'cargo-ndk', '--version', cargoNdkVersion
|
|
ignoreExitValue true
|
|
}
|
|
|
|
// Task to build the Rust library for all Android architectures
|
|
task buildRustAndroid(type: Exec, dependsOn: installCargoNdk) {
|
|
workingDir '../../rust' // Updated path - go up two levels
|
|
commandLine 'cargo', 'ndk',
|
|
'-t', 'arm64-v8a',
|
|
'-t', 'armeabi-v7a',
|
|
'-t', 'x86_64',
|
|
'-o', '../android/app/src/main/jniLibs',
|
|
'build', '--release'
|
|
}
|
|
|
|
// Hook into the Android build process
|
|
afterEvaluate {
|
|
android.applicationVariants.all { variant ->
|
|
def variantName = variant.name.capitalize()
|
|
tasks["merge${variantName}NativeLibs"].dependsOn buildRustAndroid
|
|
}
|
|
} |