Converting the gradle setup to modern

This commit is contained in:
Henrik Rydgård 2025-10-22 11:47:01 +02:00
parent b1ff621483
commit 2ee0b00134
6 changed files with 249 additions and 262 deletions

View File

@ -1,240 +0,0 @@
plugins {
id 'com.gladed.androidgitversion' version '0.4.14'
}
apply plugin: 'com.android.application'
androidGitVersion {
codeFormat = "MNNPPBBBB"
format = "%tag%%-count%%-branch%%-dirty%"
prefix = "v" // Only tags beginning with v are considered.
untrackedIsDirty = false
}
dependencies {
// 1.6.1 is the newest version we can use that won't complain about minSdk version,
// and also doesn't collide kotlin versions with com.gladed.androidgitversion. Should probably
// fork and upgrade that.
implementation "androidx.appcompat:appcompat:1.6.1"
// Convenient wrapper around DocumentContract. Might look into writing our own
// to see if there's some performance to squeeze at some point, but doubt it.
implementation "androidx.documentfile:documentfile:1.1.0"
}
android {
flavorDimensions "variant"
namespace = 'org.ppsspp.ppsspp'
signingConfigs {
debug {
storeFile file("debug.keystore")
}
optimized {
storeFile file("debug.keystore")
}
// Set these in a system global (or project local, but not checked in) gradle.properties .
if (project.hasProperty("RELEASE_STORE_FILE")) {
release {
storeFile file(RELEASE_STORE_FILE)
storePassword RELEASE_STORE_PASSWORD
keyAlias RELEASE_KEY_ALIAS
keyPassword RELEASE_KEY_PASSWORD
}
}
}
compileSdk = 36
ndkVersion = "28.2.13676358"
compileOptions {
sourceCompatibility JavaVersion.VERSION_11
targetCompatibility JavaVersion.VERSION_11
}
lint {
baseline = file("lint-baseline.xml")
}
defaultConfig {
applicationId 'org.ppsspp.ppsspp'
if (androidGitVersion.name() != "unknown") {
println "Overriding Android Version Name, Code: " + androidGitVersion.name() + " " + androidGitVersion.code()
versionName androidGitVersion.name()
versionCode androidGitVersion.code()
} else {
println "(not using these:) Android Version Name, Code: " + androidGitVersion.name() + " " + androidGitVersion.code()
}
file("versionname.txt").text = androidGitVersion.name()
file("versioncode.txt").text = androidGitVersion.code().toString()
minSdk = 21
targetSdk = 36
if (project.hasProperty("ANDROID_VERSION_CODE") && project.hasProperty("ANDROID_VERSION_NAME")) {
versionCode = ANDROID_VERSION_CODE
versionName = ANDROID_VERSION_NAME
}
signingConfig = signingConfigs.debug
}
buildTypes {
debug {
minifyEnabled = false
jniDebuggable = true
signingConfig = signingConfigs.debug
}
optimized {
// Debug signed but optimized.
minifyEnabled = false
jniDebuggable = true
signingConfig = android.buildTypes.debug.signingConfig
}
release {
minifyEnabled = false
signingConfig = signingConfigs.release
}
}
externalNativeBuild {
cmake {
path '../CMakeLists.txt'
}
}
packagingOptions {
jniLibs.useLegacyPackaging = true
}
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
res.srcDirs = ['res']
java.srcDirs = ['src']
aidl.srcDirs = ['src']
resources.srcDirs = ['src']
assets.srcDirs = [
'../assets',
]
}
normal {
res.srcDirs = ['normal/res']
}
gold {
res.srcDirs = ['gold/res']
}
vr {
res.srcDirs = ['normal/res']
manifest.srcFile 'VRManifest.xml'
}
legacy {
res.srcDirs = ['legacy/res']
}
}
productFlavors {
normal {
applicationId 'org.ppsspp.ppsspp'
dimension "variant"
externalNativeBuild {
cmake {
// Available arguments listed at https://developer.android.com/ndk/guides/cmake.html
arguments '-DANDROID=true',
'-DANDROID_TOOLCHAIN=clang',
'-DANDROID_CPP_FEATURES=',
'-DANDROID_STL=c++_static'
}
}
ndk {
abiFilters 'armeabi-v7a', 'arm64-v8a', 'x86_64'
}
}
gold {
applicationId 'org.ppsspp.ppssppgold'
dimension "variant"
externalNativeBuild {
cmake {
// Available arguments listed at https://developer.android.com/ndk/guides/cmake.html
arguments '-DANDROID=true',
'-DANDROID_TOOLCHAIN=clang',
'-DANDROID_CPP_FEATURES=',
'-DANDROID_STL=c++_static',
'-DANDROID_ARM_NEON=TRUE',
'-DGOLD=TRUE'
}
}
ndk {
abiFilters 'armeabi-v7a', 'arm64-v8a', 'x86_64'
}
}
legacy {
applicationId 'org.ppsspp.ppsspplegacy'
dimension "variant"
// targetSdk is overridden in androidComponents below.
externalNativeBuild {
cmake {
// Available arguments listed at https://developer.android.com/ndk/guides/cmake.html
arguments '-DANDROID=true',
'-DANDROID_TOOLCHAIN=clang',
'-DANDROID_CPP_FEATURES=',
'-DANDROID_STL=c++_static',
'-DANDROID_LEGACY=TRUE'
}
}
ndk {
//noinspection ChromeOsAbiSupport
abiFilters 'armeabi-v7a', 'arm64-v8a'
}
}
vr {
applicationId 'org.ppsspp.ppssppvr'
dimension "variant"
// targetSdk is overridden in androidComponents below.
externalNativeBuild {
cmake {
// Available arguments listed at https://developer.android.com/ndk/guides/cmake.html
arguments '-DANDROID=true',
'-DANDROID_TOOLCHAIN=clang',
'-DANDROID_CPP_FEATURES=',
'-DANDROID_STL=c++_static',
'-DANDROID_ARM_NEON=TRUE',
'-DOPENXR=TRUE',
'-DANDROID_LEGACY=TRUE'
}
}
ndk {
//noinspection ChromeOsAbiSupport
abiFilters 'arm64-v8a'
}
}
}
buildFeatures {
aidl = true
buildConfig = true
}
}
androidComponents {
beforeVariants(selector().all()) { variantBuilder ->
def needed = variantBuilder.name in [
'normalDebug', // for debugging
'normalOptimized', // for testing/user build
'normalRelease', // for Google Play releases
'goldDebug',
'goldRelease', // for Google Play releases
'vrDebug', // for VR debugging
'vrOptimized', // for VR testing
'vrRelease', // for VR releases
'legacyDebug', // for legacy debugging
'legacyOptimized', // for legacy testing/user build
'legacyRelease', // for buildbot releases
]
variantBuilder.enable = needed
// Override targetSdk for legacy and VR variants
if (variantBuilder.flavorName.contains("legacy")) {
variantBuilder.targetSdk = 29
} else if (variantBuilder.flavorName.contains("vr")) {
variantBuilder.targetSdk = 29
}
}
}
afterEvaluate {
android.sourceSets.main.assets.getSrcDirs().each { println it }
}

226
android/build.gradle.kts Normal file
View File

@ -0,0 +1,226 @@
plugins {
id("com.android.application")
id("com.gladed.androidgitversion")
id("org.jetbrains.kotlin.android")
}
// Kotlin DSL syntax for configuring the extension
configure<com.gladed.androidgitversion.AndroidGitVersionExtension> {
codeFormat = "MNNPPBBBB"
format = "%tag%%-count%%-branch%%-dirty%"
prefix = "v" // Only tags beginning with v are considered.
untrackedIsDirty = false
}
dependencies {
// 1.6.1 is the newest version we can use that won't complain about minSdk version,
// and also doesn't collide kotlin versions with com.gladed.androidgitversion.
// Will replace with a different plugin soon.
implementation("androidx.appcompat:appcompat:1.6.1")
implementation("androidx.documentfile:documentfile:1.1.0")
}
android {
flavorDimensions.add("variant")
namespace = "org.ppsspp.ppsspp"
signingConfigs {
getByName("debug") {
storeFile = file("debug.keystore")
}
create("optimized") {
storeFile = file("debug.keystore")
}
if (project.hasProperty("RELEASE_STORE_FILE")) {
create("release") {
storeFile = file(project.property("RELEASE_STORE_FILE") as String)
storePassword = project.property("RELEASE_STORE_PASSWORD") as String
keyAlias = project.property("RELEASE_KEY_ALIAS") as String
keyPassword = project.property("RELEASE_KEY_PASSWORD") as String
}
}
}
compileSdk = 36
ndkVersion = "28.2.13676358"
compileOptions {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
}
lint {
baseline = file("lint-baseline.xml")
}
defaultConfig {
applicationId = "org.ppsspp.ppsspp"
// Access the git version info via the extension
val gitVersion = extensions.getByType<com.gladed.androidgitversion.AndroidGitVersionExtension>()
if (gitVersion.name() != "unknown") {
println("Overriding Android Version Name, Code: " + gitVersion.name() + " " + gitVersion.code())
versionName = gitVersion.name()
versionCode = gitVersion.code()
} else {
println("(not using these:) Android Version Name, Code: " + gitVersion.name() + " " + gitVersion.code())
}
file("versionname.txt").writeText(gitVersion.name())
file("versioncode.txt").writeText(gitVersion.code().toString())
minSdk = 21
targetSdk = 36
if (project.hasProperty("ANDROID_VERSION_CODE") && project.hasProperty("ANDROID_VERSION_NAME")) {
versionCode = (project.property("ANDROID_VERSION_CODE") as String).toInt()
versionName = project.property("ANDROID_VERSION_NAME") as String
}
}
buildTypes {
getByName("debug") {
isMinifyEnabled = false
isJniDebuggable = true
signingConfig = signingConfigs.getByName("debug")
}
create("optimized") {
isMinifyEnabled = false
isJniDebuggable = true
signingConfig = signingConfigs.getByName("debug")
}
getByName("release") {
isMinifyEnabled = false
signingConfig = signingConfigs.getByName("release")
}
}
externalNativeBuild {
cmake {
path = file("../CMakeLists.txt")
}
}
packaging {
jniLibs.useLegacyPackaging = true
}
sourceSets {
getByName("main") {
manifest.srcFile("AndroidManifest.xml")
res.setSrcDirs(listOf("res"))
java.setSrcDirs(listOf("src"))
aidl.setSrcDirs(listOf("src"))
resources.setSrcDirs(listOf("src"))
assets.setSrcDirs(listOf("../assets"))
}
create("normal") {
res.setSrcDirs(listOf("normal/res"))
}
create("gold") {
res.setSrcDirs(listOf("gold/res"))
}
create("vr") {
res.setSrcDirs(listOf("normal/res"))
manifest.srcFile("VRManifest.xml")
}
create("legacy") {
res.setSrcDirs(listOf("legacy/res"))
}
}
productFlavors {
create("normal") {
applicationId = "org.ppsspp.ppsspp"
dimension = "variant"
externalNativeBuild {
cmake {
// **FIXED**: Using simple "listOf"
arguments.addAll(listOf(
"-DANDROID=true",
"-DANDROID_PLATFORM=android-21",
"-DANDROID_TOOLCHAIN=clang",
"-DANDROID_CPP_FEATURES=",
"-DANDROID_STL=c++_static"
))
}
}
ndk {
abiFilters.addAll(listOf("armeabi-v7a", "arm64-v8a", "x86_64"))
}
}
create("gold") {
applicationId = "org.ppsspp.ppssppgold"
dimension = "variant"
externalNativeBuild {
cmake {
arguments.addAll(listOf(
"-DANDROID=true",
"-DANDROID_PLATFORM=android-21",
"-DANDROID_TOOLCHAIN=clang",
"-DANDROID_CPP_FEATURES=",
"-DANDROID_STL=c++_static",
"-DGOLD=TRUE"
))
}
}
ndk {
abiFilters.addAll(listOf("armeabi-v7a", "arm64-v8a", "x86_64"))
}
}
create("legacy") {
applicationId = "org.ppsspp.ppsspplegacy"
dimension = "variant"
targetSdk = 29 // To avoid scoped storage, which is the point of the legacy APK
externalNativeBuild {
cmake {
arguments.addAll(listOf(
"-DANDROID=true",
"-DANDROID_PLATFORM=android-21",
"-DANDROID_TOOLCHAIN=clang",
"-DANDROID_CPP_FEATURES=",
"-DANDROID_STL=c++_static",
"-DANDROID_LEGACY=TRUE"
))
}
}
ndk {
abiFilters.addAll(listOf("armeabi-v7a", "arm64-v8a"))
}
}
create("vr") {
applicationId = "org.ppsspp.ppssppvr"
dimension = "variant"
targetSdk = 29 // To avoid scoped storage, which doesn't work properly on Oculus
externalNativeBuild {
cmake {
arguments.addAll(listOf(
"-DANDROID=true",
"-DANDROID_PLATFORM=android-21",
"-DANDROID_TOOLCHAIN=clang",
"-DANDROID_CPP_FEATURES=",
"-DANDROID_STL=c++_static",
"-DOPENXR=TRUE",
"-DANDROID_LEGACY=TRUE"
))
}
}
ndk {
abiFilters.addAll(listOf("arm64-v8a"))
}
}
}
buildFeatures {
aidl = true
buildConfig = true
}
}
androidComponents {
beforeVariants(selector().all()) { variantBuilder ->
// **FIXED**: Using simple "setOf"
val enabledVariants = setOf(
"normalDebug", "normalOptimized", "normalRelease",
"goldDebug", "goldRelease",
"vrDebug", "vrOptimized", "vrRelease",
"legacyDebug", "legacyOptimized", "legacyRelease"
)
variantBuilder.enable = variantBuilder.name in enabledVariants
}
}
afterEvaluate {
android.sourceSets.getByName("main").assets.srcDirs.forEach {
println(it)
}
}

View File

@ -1,21 +0,0 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:8.13.0'
}
}
allprojects {
repositories {
google()
mavenCentral()
}
// The below can be used to show more deprecated stuff in the build output.
// tasks.withType(JavaCompile).configureEach {
// options.compilerArgs << "-Xlint:deprecation"
// }
}

5
build.gradle.kts Normal file
View File

@ -0,0 +1,5 @@
plugins {
id("com.android.application") version "8.13.0" apply false
id("org.jetbrains.kotlin.android") version "2.0.21" apply false
id("com.gladed.androidgitversion") version "0.4.14" apply false
}

View File

@ -1 +0,0 @@
include ':android'

18
settings.gradle.kts Normal file
View File

@ -0,0 +1,18 @@
pluginManagement {
repositories {
google()
mavenCentral()
gradlePluginPortal()
}
}
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
google()
mavenCentral()
}
}
rootProject.name = "PPSSPP"
include(":android")