// Top-level build file where you can add configuration options common to all sub-projects/modules. plugins { id 'com.android.application' version '8.0.1' apply false id 'com.android.library' version '8.0.1' apply false } // Utility methods ext.getTargetDir = { boolean debug, String arch -> def basePath = project.rootDir.getParentFile().getParentFile().getParentFile().absolutePath return basePath + '/target/android/' + getSubTargetDir(debug, arch) } ext.getNativeTargetDir = { boolean debug, String arch -> def basePath = project.rootDir.getParentFile().getParentFile().getParentFile().absolutePath return basePath + '/target/' + getSubTargetDir(debug, arch) } ext.getSubTargetDir = { boolean debug, String arch -> return getRustTarget(arch) + '/' + (debug ? 'debug' : 'release') } ext.getJniLibsPath = { boolean debug, String arch -> return getTargetDir(debug, arch) + '/jniLibs' } ext.getRustTarget = { String arch -> switch (arch.toLowerCase()) { case 'armv7' : return 'armv7-linux-androideabi' case 'arm64' : return 'aarch64-linux-android' case 'x86' : return 'i686-linux-android' default: throw new GradleException("Invalid target architecture " + arch) } } ext.getNDKAbi = { String arch -> switch (arch.toLowerCase()) { case 'armv7' : return 'armeabi-v7a' case 'arm64' : return 'arm64-v8a' case 'x86' : return 'x86' default: throw new GradleException("Invalid target architecture " + arch) } } ext.getNdkDir = { -> // Read environment variable used in rust build system String ndkRoot = System.getenv('ANDROID_NDK_ROOT') if (ndkRoot == null) { // Fallback to ndkDir in local.properties def rootDir = project.rootDir def localProperties = new File(rootDir, "local.properties") Properties properties = new Properties() localProperties.withInputStream { instr -> properties.load(instr) } ndkRoot = properties.getProperty('ndk.dir') } def ndkDir = ndkRoot != null ? new File(ndkRoot) : null if (!ndkDir || !ndkDir.exists()) { throw new GradleException("Please set a valid ANDROID_NDK_ROOT environment variable" + "or ndk.dir path in local.properties file"); } return ndkDir.absolutePath }