2023-05-31 05:50:09 +02:00
|
|
|
// SPDX-FileCopyrightText: 2023 yuzu Emulator Project
|
|
|
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
|
2023-06-04 08:06:38 +02:00
|
|
|
import android.annotation.SuppressLint
|
2023-06-14 01:04:42 +02:00
|
|
|
import kotlin.collections.setOf
|
|
|
|
import org.jlleitschuh.gradle.ktlint.reporter.ReporterType
|
2024-01-17 21:12:30 +01:00
|
|
|
import com.github.triplet.gradle.androidpublisher.ReleaseStatus
|
2023-06-04 08:06:38 +02:00
|
|
|
|
2023-04-19 06:53:59 +02:00
|
|
|
plugins {
|
|
|
|
id("com.android.application")
|
|
|
|
id("org.jetbrains.kotlin.android")
|
|
|
|
id("kotlin-parcelize")
|
2023-12-24 01:01:22 +01:00
|
|
|
kotlin("plugin.serialization") version "1.9.20"
|
2023-06-12 01:54:54 +02:00
|
|
|
id("androidx.navigation.safeargs.kotlin")
|
2023-06-14 01:04:42 +02:00
|
|
|
id("org.jlleitschuh.gradle.ktlint") version "11.4.0"
|
2024-01-17 21:12:30 +01:00
|
|
|
id("com.github.triplet.play") version "3.8.6"
|
2023-04-19 06:53:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Use the number of seconds/10 since Jan 1 2016 as the versionCode.
|
|
|
|
* This lets us upload a new build at most every 10 seconds for the
|
|
|
|
* next 680 years.
|
|
|
|
*/
|
|
|
|
val autoVersion = (((System.currentTimeMillis() / 1000) - 1451606400) / 10).toInt()
|
|
|
|
|
|
|
|
@Suppress("UnstableApiUsage")
|
|
|
|
android {
|
|
|
|
namespace = "org.yuzu.yuzu_emu"
|
|
|
|
|
2023-06-28 22:15:18 +02:00
|
|
|
compileSdkVersion = "android-34"
|
2023-10-12 05:06:14 +02:00
|
|
|
ndkVersion = "26.1.10909125"
|
2023-04-19 06:53:59 +02:00
|
|
|
|
|
|
|
buildFeatures {
|
|
|
|
viewBinding = true
|
|
|
|
}
|
|
|
|
|
|
|
|
compileOptions {
|
2023-05-04 10:07:44 +02:00
|
|
|
sourceCompatibility = JavaVersion.VERSION_17
|
|
|
|
targetCompatibility = JavaVersion.VERSION_17
|
2023-04-19 06:53:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
kotlinOptions {
|
2023-05-04 10:07:44 +02:00
|
|
|
jvmTarget = "17"
|
2023-04-19 06:53:59 +02:00
|
|
|
}
|
|
|
|
|
2023-06-04 08:06:38 +02:00
|
|
|
packaging {
|
2023-05-30 01:05:39 +02:00
|
|
|
// This is necessary for libadrenotools custom driver loading
|
|
|
|
jniLibs.useLegacyPackaging = true
|
|
|
|
}
|
|
|
|
|
2023-11-01 01:29:16 +01:00
|
|
|
androidResources {
|
|
|
|
generateLocaleConfig = true
|
|
|
|
}
|
|
|
|
|
2023-04-19 06:53:59 +02:00
|
|
|
defaultConfig {
|
|
|
|
// TODO If this is ever modified, change application_id in strings.xml
|
|
|
|
applicationId = "org.yuzu.yuzu_emu"
|
2023-04-19 19:37:09 +02:00
|
|
|
minSdk = 30
|
2023-06-28 22:15:18 +02:00
|
|
|
targetSdk = 34
|
2023-05-27 23:13:46 +02:00
|
|
|
versionName = getGitVersion()
|
2023-04-19 06:53:59 +02:00
|
|
|
|
2024-01-17 21:12:30 +01:00
|
|
|
versionCode = if (System.getenv("AUTO_VERSIONED") == "true") {
|
2023-06-12 01:26:36 +02:00
|
|
|
autoVersion
|
|
|
|
} else {
|
|
|
|
1
|
|
|
|
}
|
|
|
|
|
2023-04-19 06:53:59 +02:00
|
|
|
ndk {
|
2023-06-04 08:06:38 +02:00
|
|
|
@SuppressLint("ChromeOsAbiSupport")
|
2023-05-29 02:24:48 +02:00
|
|
|
abiFilters += listOf("arm64-v8a")
|
2023-04-19 06:53:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
buildConfigField("String", "GIT_HASH", "\"${getGitHash()}\"")
|
|
|
|
buildConfigField("String", "BRANCH", "\"${getBranch()}\"")
|
|
|
|
}
|
|
|
|
|
2023-09-17 07:22:16 +02:00
|
|
|
val keystoreFile = System.getenv("ANDROID_KEYSTORE_FILE")
|
2024-01-22 03:57:24 +01:00
|
|
|
signingConfigs {
|
|
|
|
if (keystoreFile != null) {
|
2023-09-17 07:22:16 +02:00
|
|
|
create("release") {
|
|
|
|
storeFile = file(keystoreFile)
|
|
|
|
storePassword = System.getenv("ANDROID_KEYSTORE_PASS")
|
|
|
|
keyAlias = System.getenv("ANDROID_KEY_ALIAS")
|
|
|
|
keyPassword = System.getenv("ANDROID_KEYSTORE_PASS")
|
|
|
|
}
|
|
|
|
}
|
2024-01-22 03:57:24 +01:00
|
|
|
create("default") {
|
|
|
|
storeFile = file("$projectDir/debug.keystore")
|
|
|
|
storePassword = "android"
|
|
|
|
keyAlias = "androiddebugkey"
|
|
|
|
keyPassword = "android"
|
|
|
|
}
|
2023-09-17 07:22:16 +02:00
|
|
|
}
|
|
|
|
|
2023-04-19 06:53:59 +02:00
|
|
|
// Define build types, which are orthogonal to product flavors.
|
|
|
|
buildTypes {
|
|
|
|
|
|
|
|
// Signed by release key, allowing for upload to Play Store.
|
|
|
|
release {
|
2023-09-17 07:22:16 +02:00
|
|
|
signingConfig = if (keystoreFile != null) {
|
|
|
|
signingConfigs.getByName("release")
|
|
|
|
} else {
|
2024-01-22 03:57:24 +01:00
|
|
|
signingConfigs.getByName("default")
|
2023-09-17 07:22:16 +02:00
|
|
|
}
|
|
|
|
|
2023-06-11 08:16:45 +02:00
|
|
|
resValue("string", "app_name_suffixed", "yuzu")
|
2023-05-13 18:39:28 +02:00
|
|
|
isMinifyEnabled = true
|
|
|
|
isDebuggable = false
|
|
|
|
proguardFiles(
|
|
|
|
getDefaultProguardFile("proguard-android.txt"),
|
|
|
|
"proguard-rules.pro"
|
|
|
|
)
|
2023-04-19 06:53:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// builds a release build that doesn't need signing
|
|
|
|
// Attaches 'debug' suffix to version and package name, allowing installation alongside the release build.
|
|
|
|
register("relWithDebInfo") {
|
2023-08-23 16:12:39 +02:00
|
|
|
isDefault = true
|
2023-06-11 08:16:45 +02:00
|
|
|
resValue("string", "app_name_suffixed", "yuzu Debug Release")
|
2024-01-22 03:57:24 +01:00
|
|
|
signingConfig = signingConfigs.getByName("default")
|
2023-05-13 18:39:28 +02:00
|
|
|
isMinifyEnabled = true
|
2023-04-19 06:53:59 +02:00
|
|
|
isDebuggable = true
|
2023-05-15 23:37:09 +02:00
|
|
|
proguardFiles(
|
|
|
|
getDefaultProguardFile("proguard-android.txt"),
|
|
|
|
"proguard-rules.pro"
|
|
|
|
)
|
2023-06-11 08:16:45 +02:00
|
|
|
versionNameSuffix = "-relWithDebInfo"
|
|
|
|
applicationIdSuffix = ".relWithDebInfo"
|
2023-04-19 06:53:59 +02:00
|
|
|
isJniDebuggable = true
|
|
|
|
}
|
|
|
|
|
|
|
|
// Signed by debug key disallowing distribution on Play Store.
|
|
|
|
// Attaches 'debug' suffix to version and package name, allowing installation alongside the release build.
|
|
|
|
debug {
|
2024-01-22 03:57:24 +01:00
|
|
|
signingConfig = signingConfigs.getByName("default")
|
2023-06-11 08:16:45 +02:00
|
|
|
resValue("string", "app_name_suffixed", "yuzu Debug")
|
2023-04-19 06:53:59 +02:00
|
|
|
isDebuggable = true
|
|
|
|
isJniDebuggable = true
|
2023-05-13 18:39:28 +02:00
|
|
|
versionNameSuffix = "-debug"
|
2023-06-11 08:16:45 +02:00
|
|
|
applicationIdSuffix = ".debug"
|
2023-04-19 06:53:59 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
flavorDimensions.add("version")
|
|
|
|
productFlavors {
|
|
|
|
create("mainline") {
|
2023-08-23 16:12:39 +02:00
|
|
|
isDefault = true
|
2023-04-19 06:53:59 +02:00
|
|
|
dimension = "version"
|
2023-05-08 10:49:32 +02:00
|
|
|
buildConfigField("Boolean", "PREMIUM", "false")
|
|
|
|
}
|
|
|
|
|
|
|
|
create("ea") {
|
|
|
|
dimension = "version"
|
|
|
|
buildConfigField("Boolean", "PREMIUM", "true")
|
2023-05-13 18:39:28 +02:00
|
|
|
applicationIdSuffix = ".ea"
|
2023-04-19 06:53:59 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
externalNativeBuild {
|
|
|
|
cmake {
|
|
|
|
version = "3.22.1"
|
|
|
|
path = file("../../../CMakeLists.txt")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
defaultConfig {
|
|
|
|
externalNativeBuild {
|
|
|
|
cmake {
|
|
|
|
arguments(
|
|
|
|
"-DENABLE_QT=0", // Don't use QT
|
|
|
|
"-DENABLE_SDL2=0", // Don't use SDL
|
|
|
|
"-DENABLE_WEB_SERVICE=0", // Don't use telemetry
|
|
|
|
"-DBUNDLE_SPEEX=ON",
|
|
|
|
"-DANDROID_ARM_NEON=true", // cryptopp requires Neon to work
|
|
|
|
"-DYUZU_USE_BUNDLED_VCPKG=ON",
|
2023-04-24 17:18:13 +02:00
|
|
|
"-DYUZU_USE_BUNDLED_FFMPEG=ON",
|
2023-11-30 20:05:02 +01:00
|
|
|
"-DYUZU_ENABLE_LTO=ON",
|
|
|
|
"-DCMAKE_EXPORT_COMPILE_COMMANDS=ON"
|
2023-04-19 06:53:59 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
abiFilters("arm64-v8a", "x86_64")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-08-21 23:31:13 +02:00
|
|
|
tasks.create<Delete>("ktlintReset") {
|
|
|
|
delete(File(buildDir.path + File.separator + "intermediates/ktLint"))
|
|
|
|
}
|
|
|
|
|
2024-01-12 03:53:11 +01:00
|
|
|
val showFormatHelp = {
|
|
|
|
logger.lifecycle(
|
|
|
|
"If this check fails, please try running \"gradlew ktlintFormat\" for automatic " +
|
|
|
|
"codestyle fixes"
|
|
|
|
)
|
|
|
|
}
|
|
|
|
tasks.getByPath("ktlintKotlinScriptCheck").doFirst { showFormatHelp.invoke() }
|
|
|
|
tasks.getByPath("ktlintMainSourceSetCheck").doFirst { showFormatHelp.invoke() }
|
2023-08-21 23:31:13 +02:00
|
|
|
tasks.getByPath("loadKtlintReporters").dependsOn("ktlintReset")
|
2023-06-14 01:04:42 +02:00
|
|
|
|
|
|
|
ktlint {
|
2023-06-16 22:32:08 +02:00
|
|
|
version.set("0.47.1")
|
2023-06-14 01:04:42 +02:00
|
|
|
android.set(true)
|
|
|
|
ignoreFailures.set(false)
|
|
|
|
disabledRules.set(
|
|
|
|
setOf(
|
|
|
|
"no-wildcard-imports",
|
2023-06-16 22:31:49 +02:00
|
|
|
"package-name",
|
|
|
|
"import-ordering"
|
2023-06-14 01:04:42 +02:00
|
|
|
)
|
|
|
|
)
|
|
|
|
reporters {
|
|
|
|
reporter(ReporterType.CHECKSTYLE)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-01-17 21:12:30 +01:00
|
|
|
play {
|
|
|
|
val keyPath = System.getenv("SERVICE_ACCOUNT_KEY_PATH")
|
|
|
|
if (keyPath != null) {
|
|
|
|
serviceAccountCredentials.set(File(keyPath))
|
|
|
|
}
|
|
|
|
track.set(System.getenv("STORE_TRACK") ?: "internal")
|
|
|
|
releaseStatus.set(ReleaseStatus.COMPLETED)
|
|
|
|
}
|
|
|
|
|
2023-04-19 06:53:59 +02:00
|
|
|
dependencies {
|
2023-10-12 05:08:21 +02:00
|
|
|
implementation("androidx.core:core-ktx:1.12.0")
|
2023-04-19 06:53:59 +02:00
|
|
|
implementation("androidx.appcompat:appcompat:1.6.1")
|
2023-10-12 05:08:21 +02:00
|
|
|
implementation("androidx.recyclerview:recyclerview:1.3.1")
|
2023-04-19 06:53:59 +02:00
|
|
|
implementation("androidx.constraintlayout:constraintlayout:2.1.4")
|
2023-10-12 05:08:21 +02:00
|
|
|
implementation("androidx.fragment:fragment-ktx:1.6.1")
|
2023-04-19 06:53:59 +02:00
|
|
|
implementation("androidx.documentfile:documentfile:1.0.1")
|
2023-05-23 00:00:34 +02:00
|
|
|
implementation("com.google.android.material:material:1.9.0")
|
2023-10-12 05:08:21 +02:00
|
|
|
implementation("androidx.preference:preference-ktx:1.2.1")
|
|
|
|
implementation("androidx.lifecycle:lifecycle-viewmodel-ktx:2.6.2")
|
2023-04-19 06:53:59 +02:00
|
|
|
implementation("io.coil-kt:coil:2.2.2")
|
2023-05-04 10:13:16 +02:00
|
|
|
implementation("androidx.core:core-splashscreen:1.0.1")
|
2023-09-21 23:36:14 +02:00
|
|
|
implementation("androidx.window:window:1.2.0-beta03")
|
2023-04-19 06:53:59 +02:00
|
|
|
implementation("androidx.constraintlayout:constraintlayout:2.1.4")
|
|
|
|
implementation("androidx.swiperefreshlayout:swiperefreshlayout:1.1.0")
|
2023-10-12 05:08:21 +02:00
|
|
|
implementation("androidx.navigation:navigation-fragment-ktx:2.7.4")
|
|
|
|
implementation("androidx.navigation:navigation-ui-ktx:2.7.4")
|
2023-04-06 02:26:53 +02:00
|
|
|
implementation("info.debatty:java-string-similarity:2.0.0")
|
2023-05-02 11:58:03 +02:00
|
|
|
implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.5.0")
|
2023-04-19 06:53:59 +02:00
|
|
|
}
|
|
|
|
|
2024-01-14 00:06:33 +01:00
|
|
|
fun runGitCommand(command: List<String>): String {
|
|
|
|
return try {
|
|
|
|
ProcessBuilder(command)
|
2023-04-19 06:53:59 +02:00
|
|
|
.directory(project.rootDir)
|
|
|
|
.redirectOutput(ProcessBuilder.Redirect.PIPE)
|
|
|
|
.redirectError(ProcessBuilder.Redirect.PIPE)
|
|
|
|
.start().inputStream.bufferedReader().use { it.readText() }
|
|
|
|
.trim()
|
|
|
|
} catch (e: Exception) {
|
2024-01-14 00:06:33 +01:00
|
|
|
logger.error("Cannot find git")
|
|
|
|
""
|
2023-04-19 06:53:59 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-01-14 00:06:33 +01:00
|
|
|
fun getGitVersion(): String {
|
2024-01-17 21:12:30 +01:00
|
|
|
val gitVersion = runGitCommand(listOf("git", "describe", "--always", "--long"))
|
2024-01-14 00:06:33 +01:00
|
|
|
val versionName = if (System.getenv("GITHUB_ACTIONS") != null) {
|
2024-01-17 21:12:30 +01:00
|
|
|
System.getenv("GIT_TAG_NAME") ?: gitVersion
|
2024-01-14 00:06:33 +01:00
|
|
|
} else {
|
2024-01-17 21:12:30 +01:00
|
|
|
gitVersion
|
2023-04-19 06:53:59 +02:00
|
|
|
}
|
2024-01-17 21:12:30 +01:00
|
|
|
return versionName.replace(Regex("(-0)?-[^-]+$"), "").ifEmpty { "0.0" }
|
2023-04-19 06:53:59 +02:00
|
|
|
}
|
|
|
|
|
2024-01-14 00:06:33 +01:00
|
|
|
fun getGitHash(): String =
|
|
|
|
runGitCommand(listOf("git", "rev-parse", "--short", "HEAD")).ifEmpty { "dummy-hash" }
|
|
|
|
|
|
|
|
fun getBranch(): String =
|
|
|
|
runGitCommand(listOf("git", "rev-parse", "--abbrev-ref", "HEAD")).ifEmpty { "dummy-hash" }
|