// This script accepts the following parameters: // // filament_dist_dir // Path to the Filament distribution/install directory for Android // (produced by make/ninja install). This directory must contain lib/arm64-v8a/ etc. // // filament_tools_dir // Path to the Filament distribution/install directory for desktop. // This directory must contain bin/matc. // // filament_supports_vulkan // When set, support for Vulkan will be enabled. // // filament_skip_samples // Exclude samples from the project. Useful to speed up compilation. // // filament_abis // List of supported ABIs to build as a comma separated list. Available options are: // arm64-v8a, armeabi-v7a, x86_64, x86, all // Defaults to all. // // Example: // ./gradlew -Pfilament_dist_dir=../dist-android-release assembleRelease -Pfilament_abis=x86 buildscript { def filamentPath = file("../out/android-release/filament").absolutePath if (project.hasProperty("filament_dist_dir")) { filamentPath = file(project.property("filament_dist_dir")).absolutePath } def hasVulkan = project.hasProperty("filament_supports_vulkan") def abis = ["arm64-v8a", "armeabi-v7a", "x86_64", "x86"] if (project.hasProperty("filament_abis")) { def newAbis = project.property("filament_abis").split(',') if (!newAbis.contains("all")) { abis = newAbis } } // Our minSdkVersion is 19. ext.versions = [ 'minSdk': 19, 'targetSdk': 29, 'compileSdk': 29, 'kotlin': '1.3.71', 'buildTools': '29.0.3', 'ndk': '21.0.6113669' ] ext.deps = [ 'androidx': [ 'annotations': "androidx.annotation:annotation:1.1.0", 'core': "androidx.core:core:1.1.0", ], 'kotlin': "org.jetbrains.kotlin:kotlin-stdlib-jdk8:${versions.kotlin}" ] dependencies { classpath 'com.android.tools.build:gradle:3.6.2' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:${versions.kotlin}" } ext.cmakeArgs = [ "-DANDROID_PIE=ON", "-DANDROID_PLATFORM=21", "-DANDROID_STL=c++_static", "-DFILAMENT_DIST_DIR=${filamentPath}".toString(), "-DFILAMENT_SUPPORTS_VULKAN=${hasVulkan ? 'ON' : 'OFF'}".toString() ] ext.cppFlags = [ "-std=c++14", "-Wno-unused-command-line-argument", // Required to support API levels below 23 "-Wl,--hash-style=both", "-fno-stack-protector", "-fno-exceptions", "-fno-unwind-tables", "-fno-asynchronous-unwind-tables", "-fno-rtti", "-ffast-math", "-ffp-contract=fast", "-fvisibility-inlines-hidden", "-fvisibility=hidden", "-fomit-frame-pointer", "-ffunction-sections", "-fdata-sections", "-Wl,--gc-sections", "-Wl,-Bsymbolic-functions", ] ext.abis = abis repositories { mavenCentral() google() jcenter() } } subprojects { group = GROUP version = VERSION_NAME repositories { mavenCentral() google() jcenter() } if (!name.startsWith("sample")) { apply plugin: 'com.android.library' android { buildToolsVersion versions.buildTools compileSdkVersion versions.compileSdk ndkVersion versions.ndk defaultConfig { minSdkVersion versions.minSdk targetSdkVersion versions.targetSdk externalNativeBuild { cmake { arguments.addAll(rootProject.ext.cmakeArgs) cppFlags.addAll(rootProject.ext.cppFlags) } } ndk { abiFilters(*rootProject.ext.abis) } } externalNativeBuild { cmake { path "CMakeLists.txt" } } sourceSets { main { jni.srcDirs "src/main/cpp" } } compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 } } } } gradle.taskGraph.whenReady { gradle.taskGraph.allTasks.each { it.onlyIf { !it.project.ext.has('isSample') || !project.hasProperty('filament_skip_samples') } } }