mirror of
https://github.com/MobileGL-Dev/MobileGL
synced 2026-09-07 19:58:32 +09:00
major*100 + minor collides for multiple releases in the same month, and Android refuses to install a package whose versionCode is not strictly greater than the installed one. Encode as year*1_000_000 + month*10_000 + monthly-revision (commits since the month start), so every build upgrades cleanly; the month weight dwarfs the per-month reset on rollover. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
187 lines
6.2 KiB
Groovy
187 lines
6.2 KiB
Groovy
plugins {
|
|
id 'com.android.application'
|
|
}
|
|
|
|
def mobileGlEnvString = { backendType ->
|
|
[
|
|
LIBGL_ES : '3',
|
|
POJAV_RENDERER : 'opengles3',
|
|
MOBILEGL_BACKEND_TYPE: backendType,
|
|
].collect { key, value -> "${key}=${value}" }.join(':')
|
|
}
|
|
def signingStoreFile = file('../keystore.jks')
|
|
def signingStorePassword = System.getenv('SIGNING_STORE_PASSWORD')
|
|
def signingKeyAlias = System.getenv('SIGNING_KEY_ALIAS')
|
|
def signingKeyPassword = System.getenv('SIGNING_KEY_PASSWORD')
|
|
def releaseSigningReady = signingStoreFile.exists()
|
|
&& signingStorePassword
|
|
&& signingKeyAlias
|
|
&& signingKeyPassword
|
|
def debuggableRelease = (findProperty('mobilegl.debuggableRelease') ?: 'false').toString().toBoolean()
|
|
def mobileGlCmakeCompilerLauncher = {
|
|
(findProperty('mobilegl.cmakeCompilerLauncher') ?: System.getenv('MOBILEGL_CMAKE_COMPILER_LAUNCHER') ?: '').toString().trim()
|
|
}
|
|
def mobileGlAbiFilters = {
|
|
def abiList = (findProperty('mobilegl.abis') ?: System.getenv('MOBILEGL_ABIS') ?: 'arm64-v8a') as String
|
|
if (abiList.equalsIgnoreCase('all')) {
|
|
return ['arm64-v8a', 'x86_64']
|
|
}
|
|
abiList
|
|
.split(',')
|
|
.collect { it.trim() }
|
|
.findAll { !it.isEmpty() }
|
|
}
|
|
|
|
// Calendar versioning: major = two-digit year, minor = month. The build
|
|
// identifier is the short commit hash, giving version names like 26.07.4e558ee.
|
|
def mobileGlVersionMajor = 26
|
|
def mobileGlVersionMinor = 7
|
|
def mobileGlGitShortHash = {
|
|
try {
|
|
def proc = ['git', 'rev-parse', '--short=7', 'HEAD'].execute(null, rootDir)
|
|
proc.waitFor()
|
|
def hash = proc.in.text.trim()
|
|
(proc.exitValue() == 0 && hash) ? hash : 'nogit'
|
|
} catch (Exception ignored) {
|
|
'nogit'
|
|
}
|
|
}()
|
|
// Monthly revision: commits reachable from HEAD since the start of the
|
|
// version's month. Multiple releases in one month (calendar versioning ships
|
|
// several per month) each get a strictly larger versionCode; a new month
|
|
// bumps the minor and dwarfs any reset via the *10000 weight.
|
|
def mobileGlMonthlyRevision = {
|
|
try {
|
|
def since = String.format('%d-%02d-01T00:00:00', 2000 + mobileGlVersionMajor, mobileGlVersionMinor)
|
|
def proc = ['git', 'rev-list', '--count', "--since=${since}", 'HEAD'].execute(null, rootDir)
|
|
proc.waitFor()
|
|
def n = proc.in.text.trim()
|
|
(proc.exitValue() == 0 && n) ? n.toInteger() : 0
|
|
} catch (Exception ignored) {
|
|
0
|
|
}
|
|
}()
|
|
|
|
android {
|
|
namespace 'top.mobilegl.plugin'
|
|
compileSdk 34
|
|
ndkVersion '27.3.13750724'
|
|
|
|
defaultConfig {
|
|
minSdk 26
|
|
targetSdk 34
|
|
// year*1_000_000 + month*10_000 + monthly revision keeps versionCode
|
|
// strictly increasing across releases (monotonic within a month and
|
|
// across month/year rollovers), so every build is an installable
|
|
// upgrade. Max ~99_129999, well under Android's 2_100_000_000 ceiling.
|
|
versionCode mobileGlVersionMajor * 1000000 + mobileGlVersionMinor * 10000 + mobileGlMonthlyRevision
|
|
versionName String.format('%d.%02d.%s', mobileGlVersionMajor, mobileGlVersionMinor, mobileGlGitShortHash)
|
|
|
|
ndk {
|
|
def abiFiltersOverride = mobileGlAbiFilters()
|
|
if (!abiFiltersOverride.isEmpty()) {
|
|
abiFilters(*abiFiltersOverride)
|
|
}
|
|
}
|
|
externalNativeBuild {
|
|
cmake {
|
|
def compilerLauncher = mobileGlCmakeCompilerLauncher()
|
|
if (!compilerLauncher.isEmpty()) {
|
|
arguments "-DCMAKE_C_COMPILER_LAUNCHER=${compilerLauncher}",
|
|
"-DCMAKE_CXX_COMPILER_LAUNCHER=${compilerLauncher}"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
flavorDimensions 'backend', 'profile'
|
|
|
|
productFlavors {
|
|
espryt {
|
|
dimension 'backend'
|
|
applicationId 'top.mobilegl.plugin.espryt'
|
|
def env = mobileGlEnvString('DirectGLES')
|
|
resValue 'string', 'mobilegl_default_backend', 'DirectGLES'
|
|
manifestPlaceholders = [
|
|
appLabel: 'MobileGL Espryt',
|
|
des : 'MobileGL Espryt',
|
|
renderer: 'MobileGL Espryt:libMobileGL.so:/libMobileGL.so',
|
|
boatEnv : env,
|
|
pojavEnv: env,
|
|
]
|
|
}
|
|
magma {
|
|
dimension 'backend'
|
|
applicationId 'top.mobilegl.plugin.magma'
|
|
def env = mobileGlEnvString('DirectVulkan')
|
|
resValue 'string', 'mobilegl_default_backend', 'DirectVulkan'
|
|
manifestPlaceholders = [
|
|
appLabel: 'MobileGL Magma',
|
|
des : 'MobileGL Magma',
|
|
renderer: 'MobileGL Magma:libMobileGL.so:/libMobileGL.so',
|
|
boatEnv : env,
|
|
pojavEnv: env,
|
|
]
|
|
}
|
|
plugin {
|
|
dimension 'profile'
|
|
}
|
|
trace {
|
|
dimension 'profile'
|
|
applicationIdSuffix '.trace'
|
|
versionNameSuffix '-trace'
|
|
}
|
|
}
|
|
|
|
if (releaseSigningReady) {
|
|
signingConfigs {
|
|
release {
|
|
storeFile signingStoreFile
|
|
storePassword signingStorePassword
|
|
keyAlias signingKeyAlias
|
|
keyPassword signingKeyPassword
|
|
}
|
|
}
|
|
}
|
|
|
|
buildTypes {
|
|
release {
|
|
debuggable debuggableRelease
|
|
minifyEnabled false
|
|
if (releaseSigningReady) {
|
|
signingConfig signingConfigs.release
|
|
}
|
|
}
|
|
}
|
|
|
|
externalNativeBuild {
|
|
cmake {
|
|
path file('src/trace/cpp/CMakeLists.txt')
|
|
version '3.22.1'
|
|
}
|
|
}
|
|
|
|
packaging {
|
|
jniLibs {
|
|
useLegacyPackaging true
|
|
excludes += ['**/libSPIRV-Tools-shared.so']
|
|
}
|
|
}
|
|
}
|
|
|
|
android.applicationVariants.configureEach { variant ->
|
|
variant.outputs.configureEach {
|
|
outputFileName = "MobileGL-${variant.flavorName.capitalize()}-${variant.buildType.name}.apk"
|
|
}
|
|
}
|
|
|
|
androidComponents {
|
|
onVariants(selector().withFlavor('profile', 'plugin')) { variant ->
|
|
variant.packaging.jniLibs.excludes.add('**/libtrace_replay_runner.so')
|
|
}
|
|
}
|
|
|
|
dependencies {
|
|
implementation project(':MobileGL')
|
|
}
|