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' // 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 } // P2 A/B opt-in. OFF by default, so the plugin flavour and every trace APK nobody asked for // keep the pull shape; the paired two-device A/B (docs/Disaggregated ROADMAP GO/NO-GO items // 3-4) builds one trace APK with it ON and compares it against the OFF build. Either // ./gradlew :app:assembleTraceDebug -Pmobilegl.pipePush=ON // or MOBILEGL_PIPE_PUSH_APK=ON in the environment. def mobileGlPipePush = { (rootProject.findProperty('mobilegl.pipePush') ?: System.getenv('MOBILEGL_PIPE_PUSH_APK') ?: 'OFF') as String } android { namespace 'top.mobilegl.mobilegl' compileSdk 34 defaultConfig { minSdk 26 testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" externalNativeBuild { cmake { arguments "-DMOBILEGL_LOG_ACTIVE_LEVEL=${mobileGlLogActiveLevel()}" } } } 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()}" // P2: the push-shaped library for the paired A/B, same flavour, same // signing, one extra CMake option. See mobileGlPipePush above. arguments "-DMOBILEGL_PIPE_PUSH=${mobileGlPipePush()}" } } } } } externalNativeBuild { cmake { path "CMakeLists.txt" version "3.22.1" } } compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 } ndkVersion '27.3.13750724' }