Files
MobileGL/build.gradle
T

120 lines
4.7 KiB
Groovy

apply plugin: 'com.android.library'
def mobileGlLogActiveLevel = {
(rootProject.findProperty('mobilegl.logLevel') ?: System.getenv('MOBILEGL_LOG_ACTIVE_LEVEL') ?: 'MOBILEGL_LOG_LEVEL_INFO') as String
}
def standalonePluginBuild = rootProject.name == 'MobileGLPlugin'
// Match the standalone app's declared ABI set. The library module otherwise
// configures unrelated NDK ABIs even when the app only packages these two.
// Embedded FCL builds retain their own ABI policy.
def mobileGlAbiFilters = {
def value = (rootProject.findProperty('mobilegl.abis') ?: System.getenv('MOBILEGL_ABIS') ?: 'arm64-v8a') as String
value.equalsIgnoreCase('all') ? ['arm64-v8a', 'x86_64'] : value.split(',').collect { it.trim() }.findAll { it }
}
// P0 spike A opt-in. OFF by default: the spike binary is dead weight in every trace APK
// that is not running the spike, and a flavour that silently carries an extra executable
// is exactly the kind of thing nobody notices until it ships. Turn it on for the spike
// build only, with either
// ./gradlew :app:assembleTraceDebug -Pmobilegl.buildServerSpike=ON
// or MOBILEGL_BUILD_SERVER_SPIKE=ON in the environment.
def mobileGlBuildServerSpike = {
(rootProject.findProperty('mobilegl.buildServerSpike') ?: System.getenv('MOBILEGL_BUILD_SERVER_SPIKE') ?: 'OFF') as String
}
// Shared native shape for BOTH plugin and trace APKs. Defaults keep existing
// callers on pull; disaggregated CI explicitly selects all three switches.
def mobileGlPipePush = {
(rootProject.findProperty('mobilegl.pipePush') ?: System.getenv('MOBILEGL_PIPE_PUSH_APK') ?: 'OFF') as String
}
def mobileGlBuildDisaggregated = {
(rootProject.findProperty('mobilegl.buildDisaggregated') ?: System.getenv('MOBILEGL_BUILD_DISAGGREGATED') ?: 'OFF') as String
}
def mobileGlBuildDisaggregatedInproc = {
(rootProject.findProperty('mobilegl.buildDisaggregatedInproc') ?: System.getenv('MOBILEGL_BUILD_DISAGGREGATED_INPROC') ?: mobileGlBuildDisaggregated()) as String
}
android {
namespace 'top.mobilegl.mobilegl'
compileSdk 34
defaultConfig {
minSdk 26
if (standalonePluginBuild) {
ndk {
abiFilters.addAll(mobileGlAbiFilters())
}
}
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
externalNativeBuild {
cmake {
arguments "-DMOBILEGL_LOG_ACTIVE_LEVEL=${mobileGlLogActiveLevel()}"
arguments '-DCMAKE_EXPORT_COMPILE_COMMANDS=ON'
arguments "-DMOBILEGL_PIPE_PUSH=${mobileGlPipePush()}"
arguments "-DMOBILEGL_BUILD_DISAGGREGATED=${mobileGlBuildDisaggregated()}"
arguments "-DMOBILEGL_BUILD_DISAGGREGATED_INPROC=${mobileGlBuildDisaggregatedInproc()}"
}
}
}
buildTypes {
release {
minifyEnabled false
}
proguard {
minifyEnabled true
initWith debug
}
fordebug {
debuggable true
// Keep the APK debuggable (simpleperf --app, JDWP) but build the
// native library like a release: AGP maps debuggable build types to
// CMAKE_BUILD_TYPE=Debug, which compiles MobileGL at -O0 and makes
// every performance measurement on this flavor meaningless.
externalNativeBuild {
cmake {
arguments "-DCMAKE_BUILD_TYPE=RelWithDebInfo"
}
}
}
}
if (standalonePluginBuild) {
flavorDimensions 'profile'
productFlavors {
plugin {
dimension 'profile'
}
trace {
dimension 'profile'
externalNativeBuild {
cmake {
arguments '-DMOBILEGL_TRACE_ANGLE_VARIANTS=ON'
// P0 spike A: the second native executable that proves an APK
// can ship one and exec it from nativeLibraryDir. Off unless
// asked for, and only offered here - the shipping plugin
// flavour cannot turn it on at all, so no released artifact can
// grow a binary nothing loads. See mobileGlBuildServerSpike
// above for the two ways to enable it.
arguments "-DMOBILEGL_BUILD_SERVER_SPIKE=${mobileGlBuildServerSpike()}"
}
}
}
}
}
externalNativeBuild {
cmake {
path "CMakeLists.txt"
version "3.22.1"
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
ndkVersion '27.3.13750724'
}