2023-05-30 23:50:09 -04:00
|
|
|
// SPDX-FileCopyrightText: 2023 yuzu Emulator Project
|
|
|
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
|
2023-06-04 02:06:38 -04:00
|
|
|
import android.annotation.SuppressLint
|
2023-06-13 19:04:42 -04:00
|
|
|
import kotlin.collections.setOf
|
2023-06-11 19:26:36 -04:00
|
|
|
import org.jetbrains.kotlin.konan.properties.Properties
|
2023-06-13 19:04:42 -04:00
|
|
|
import org.jlleitschuh.gradle.ktlint.reporter.ReporterType
|
2023-06-04 02:06:38 -04:00
|
|
|
|
2023-04-19 00:53:59 -04:00
|
|
|
plugins {
|
|
|
|
id("com.android.application")
|
|
|
|
id("org.jetbrains.kotlin.android")
|
|
|
|
id("kotlin-parcelize")
|
2023-05-02 05:58:03 -04:00
|
|
|
kotlin("plugin.serialization") version "1.8.21"
|
2023-06-11 19:54:54 -04:00
|
|
|
id("androidx.navigation.safeargs.kotlin")
|
2023-06-13 19:04:42 -04:00
|
|
|
id("org.jlleitschuh.gradle.ktlint") version "11.4.0"
|
2023-04-19 00:53:59 -04: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"
|
|
|
|
|
|
|
|
compileSdkVersion = "android-33"
|
|
|
|
ndkVersion = "25.2.9519653"
|
|
|
|
|
|
|
|
buildFeatures {
|
|
|
|
viewBinding = true
|
|
|
|
}
|
|
|
|
|
|
|
|
compileOptions {
|
2023-05-04 04:07:44 -04:00
|
|
|
sourceCompatibility = JavaVersion.VERSION_17
|
|
|
|
targetCompatibility = JavaVersion.VERSION_17
|
2023-04-19 00:53:59 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
kotlinOptions {
|
2023-05-04 04:07:44 -04:00
|
|
|
jvmTarget = "17"
|
2023-04-19 00:53:59 -04:00
|
|
|
}
|
|
|
|
|
2023-06-04 02:06:38 -04:00
|
|
|
packaging {
|
2023-05-29 19:05:39 -04:00
|
|
|
// This is necessary for libadrenotools custom driver loading
|
|
|
|
jniLibs.useLegacyPackaging = true
|
|
|
|
}
|
|
|
|
|
2023-04-19 00:53:59 -04:00
|
|
|
defaultConfig {
|
|
|
|
// TODO If this is ever modified, change application_id in strings.xml
|
|
|
|
applicationId = "org.yuzu.yuzu_emu"
|
2023-04-19 13:37:09 -04:00
|
|
|
minSdk = 30
|
2023-04-19 00:53:59 -04:00
|
|
|
targetSdk = 33
|
2023-05-27 17:13:46 -04:00
|
|
|
versionName = getGitVersion()
|
2023-04-19 00:53:59 -04:00
|
|
|
|
2023-06-11 19:26:36 -04:00
|
|
|
// If you want to use autoVersion for the versionCode, create a property in local.properties
|
|
|
|
// named "autoVersioned" and set it to "true"
|
|
|
|
val properties = Properties()
|
|
|
|
val versionProperty = try {
|
|
|
|
properties.load(project.rootProject.file("local.properties").inputStream())
|
|
|
|
properties.getProperty("autoVersioned") ?: ""
|
|
|
|
} catch (e: Exception) { "" }
|
|
|
|
|
|
|
|
versionCode = if (versionProperty == "true") {
|
|
|
|
autoVersion
|
|
|
|
} else {
|
|
|
|
1
|
|
|
|
}
|
|
|
|
|
2023-04-19 00:53:59 -04:00
|
|
|
ndk {
|
2023-06-04 02:06:38 -04:00
|
|
|
@SuppressLint("ChromeOsAbiSupport")
|
2023-05-28 20:24:48 -04:00
|
|
|
abiFilters += listOf("arm64-v8a")
|
2023-04-19 00:53:59 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
buildConfigField("String", "GIT_HASH", "\"${getGitHash()}\"")
|
|
|
|
buildConfigField("String", "BRANCH", "\"${getBranch()}\"")
|
|
|
|
}
|
|
|
|
|
|
|
|
// Define build types, which are orthogonal to product flavors.
|
|
|
|
buildTypes {
|
|
|
|
|
|
|
|
// Signed by release key, allowing for upload to Play Store.
|
|
|
|
release {
|
2023-06-11 02:16:45 -04:00
|
|
|
resValue("string", "app_name_suffixed", "yuzu")
|
2023-04-19 00:53:59 -04:00
|
|
|
signingConfig = signingConfigs.getByName("debug")
|
2023-05-13 12:39:28 -04:00
|
|
|
isMinifyEnabled = true
|
|
|
|
isDebuggable = false
|
|
|
|
proguardFiles(
|
|
|
|
getDefaultProguardFile("proguard-android.txt"),
|
|
|
|
"proguard-rules.pro"
|
|
|
|
)
|
2023-04-19 00:53:59 -04: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-06-11 02:16:45 -04:00
|
|
|
resValue("string", "app_name_suffixed", "yuzu Debug Release")
|
2023-04-19 00:53:59 -04:00
|
|
|
signingConfig = signingConfigs.getByName("debug")
|
2023-05-13 12:39:28 -04:00
|
|
|
isMinifyEnabled = true
|
2023-04-19 00:53:59 -04:00
|
|
|
isDebuggable = true
|
2023-05-15 17:37:09 -04:00
|
|
|
proguardFiles(
|
|
|
|
getDefaultProguardFile("proguard-android.txt"),
|
|
|
|
"proguard-rules.pro"
|
|
|
|
)
|
2023-06-11 02:16:45 -04:00
|
|
|
versionNameSuffix = "-relWithDebInfo"
|
|
|
|
applicationIdSuffix = ".relWithDebInfo"
|
2023-04-19 00:53:59 -04: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 {
|
2023-06-11 02:16:45 -04:00
|
|
|
resValue("string", "app_name_suffixed", "yuzu Debug")
|
2023-04-19 00:53:59 -04:00
|
|
|
isDebuggable = true
|
|
|
|
isJniDebuggable = true
|
2023-05-13 12:39:28 -04:00
|
|
|
versionNameSuffix = "-debug"
|
2023-06-11 02:16:45 -04:00
|
|
|
applicationIdSuffix = ".debug"
|
2023-04-19 00:53:59 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
flavorDimensions.add("version")
|
|
|
|
productFlavors {
|
|
|
|
create("mainline") {
|
|
|
|
dimension = "version"
|
2023-05-08 04:49:32 -04:00
|
|
|
buildConfigField("Boolean", "PREMIUM", "false")
|
|
|
|
}
|
|
|
|
|
|
|
|
create("ea") {
|
|
|
|
dimension = "version"
|
|
|
|
buildConfigField("Boolean", "PREMIUM", "true")
|
2023-05-13 12:39:28 -04:00
|
|
|
applicationIdSuffix = ".ea"
|
2023-04-19 00:53:59 -04: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 11:18:13 -04:00
|
|
|
"-DYUZU_USE_BUNDLED_FFMPEG=ON",
|
|
|
|
"-DYUZU_ENABLE_LTO=ON"
|
2023-04-19 00:53:59 -04:00
|
|
|
)
|
|
|
|
|
|
|
|
abiFilters("arm64-v8a", "x86_64")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-06-13 19:04:42 -04:00
|
|
|
tasks.getByPath("preBuild").dependsOn("ktlintCheck")
|
|
|
|
|
|
|
|
ktlint {
|
2023-06-16 16:32:08 -04:00
|
|
|
version.set("0.47.1")
|
2023-06-13 19:04:42 -04:00
|
|
|
android.set(true)
|
|
|
|
ignoreFailures.set(false)
|
|
|
|
disabledRules.set(
|
|
|
|
setOf(
|
|
|
|
"no-wildcard-imports",
|
2023-06-16 16:31:49 -04:00
|
|
|
"package-name",
|
|
|
|
"import-ordering"
|
2023-06-13 19:04:42 -04:00
|
|
|
)
|
|
|
|
)
|
|
|
|
reporters {
|
|
|
|
reporter(ReporterType.CHECKSTYLE)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-04-19 00:53:59 -04:00
|
|
|
dependencies {
|
2023-05-22 18:00:34 -04:00
|
|
|
implementation("androidx.core:core-ktx:1.10.1")
|
2023-04-19 00:53:59 -04:00
|
|
|
implementation("androidx.appcompat:appcompat:1.6.1")
|
2023-04-19 00:57:20 -04:00
|
|
|
implementation("androidx.recyclerview:recyclerview:1.3.0")
|
2023-04-19 00:53:59 -04:00
|
|
|
implementation("androidx.constraintlayout:constraintlayout:2.1.4")
|
2023-06-11 02:17:29 -04:00
|
|
|
implementation("androidx.fragment:fragment-ktx:1.6.0")
|
2023-04-19 00:53:59 -04:00
|
|
|
implementation("androidx.documentfile:documentfile:1.0.1")
|
2023-05-22 18:00:34 -04:00
|
|
|
implementation("com.google.android.material:material:1.9.0")
|
2023-04-19 00:53:59 -04:00
|
|
|
implementation("androidx.preference:preference:1.2.0")
|
2023-04-19 00:57:20 -04:00
|
|
|
implementation("androidx.lifecycle:lifecycle-viewmodel-ktx:2.6.1")
|
2023-04-19 00:53:59 -04:00
|
|
|
implementation("io.coil-kt:coil:2.2.2")
|
2023-05-04 04:13:16 -04:00
|
|
|
implementation("androidx.core:core-splashscreen:1.0.1")
|
2023-06-11 02:17:29 -04:00
|
|
|
implementation("androidx.window:window:1.1.0")
|
2023-04-19 00:53:59 -04:00
|
|
|
implementation("org.ini4j:ini4j:0.5.4")
|
|
|
|
implementation("androidx.constraintlayout:constraintlayout:2.1.4")
|
|
|
|
implementation("androidx.swiperefreshlayout:swiperefreshlayout:1.1.0")
|
2023-06-11 02:17:29 -04:00
|
|
|
implementation("androidx.navigation:navigation-fragment-ktx:2.6.0")
|
|
|
|
implementation("androidx.navigation:navigation-ui-ktx:2.6.0")
|
2023-04-05 20:26:53 -04:00
|
|
|
implementation("info.debatty:java-string-similarity:2.0.0")
|
2023-05-02 05:58:03 -04:00
|
|
|
implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.5.0")
|
2023-04-19 00:53:59 -04:00
|
|
|
}
|
|
|
|
|
2023-05-27 17:13:46 -04:00
|
|
|
fun getGitVersion(): String {
|
2023-04-19 00:53:59 -04:00
|
|
|
var versionName = "0.0"
|
|
|
|
|
|
|
|
try {
|
|
|
|
versionName = ProcessBuilder("git", "describe", "--always", "--long")
|
|
|
|
.directory(project.rootDir)
|
|
|
|
.redirectOutput(ProcessBuilder.Redirect.PIPE)
|
|
|
|
.redirectError(ProcessBuilder.Redirect.PIPE)
|
|
|
|
.start().inputStream.bufferedReader().use { it.readText() }
|
|
|
|
.trim()
|
|
|
|
.replace(Regex("(-0)?-[^-]+$"), "")
|
|
|
|
} catch (e: Exception) {
|
|
|
|
logger.error("Cannot find git, defaulting to dummy version number")
|
|
|
|
}
|
|
|
|
|
|
|
|
if (System.getenv("GITHUB_ACTIONS") != null) {
|
|
|
|
val gitTag = System.getenv("GIT_TAG_NAME")
|
|
|
|
versionName = gitTag ?: versionName
|
|
|
|
}
|
|
|
|
|
|
|
|
return versionName
|
|
|
|
}
|
|
|
|
|
|
|
|
fun getGitHash(): String {
|
|
|
|
try {
|
2023-05-01 16:58:33 -04:00
|
|
|
val processBuilder = ProcessBuilder("git", "rev-parse", "--short", "HEAD")
|
2023-04-19 00:53:59 -04:00
|
|
|
processBuilder.directory(project.rootDir)
|
|
|
|
val process = processBuilder.start()
|
|
|
|
val inputStream = process.inputStream
|
|
|
|
val errorStream = process.errorStream
|
|
|
|
process.waitFor()
|
|
|
|
|
|
|
|
return if (process.exitValue() == 0) {
|
|
|
|
inputStream.bufferedReader()
|
|
|
|
.use { it.readText().trim() } // return the value of gitHash
|
|
|
|
} else {
|
|
|
|
val errorMessage = errorStream.bufferedReader().use { it.readText().trim() }
|
|
|
|
logger.error("Error running git command: $errorMessage")
|
|
|
|
"dummy-hash" // return a dummy hash value in case of an error
|
|
|
|
}
|
|
|
|
} catch (e: Exception) {
|
|
|
|
logger.error("$e: Cannot find git, defaulting to dummy build hash")
|
|
|
|
return "dummy-hash" // return a dummy hash value in case of an error
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fun getBranch(): String {
|
|
|
|
try {
|
|
|
|
val processBuilder = ProcessBuilder("git", "rev-parse", "--abbrev-ref", "HEAD")
|
|
|
|
processBuilder.directory(project.rootDir)
|
|
|
|
val process = processBuilder.start()
|
|
|
|
val inputStream = process.inputStream
|
|
|
|
val errorStream = process.errorStream
|
|
|
|
process.waitFor()
|
|
|
|
|
|
|
|
return if (process.exitValue() == 0) {
|
|
|
|
inputStream.bufferedReader()
|
|
|
|
.use { it.readText().trim() } // return the value of gitHash
|
|
|
|
} else {
|
|
|
|
val errorMessage = errorStream.bufferedReader().use { it.readText().trim() }
|
|
|
|
logger.error("Error running git command: $errorMessage")
|
|
|
|
"dummy-hash" // return a dummy hash value in case of an error
|
|
|
|
}
|
|
|
|
} catch (e: Exception) {
|
|
|
|
logger.error("$e: Cannot find git, defaulting to dummy build hash")
|
|
|
|
return "dummy-hash" // return a dummy hash value in case of an error
|
|
|
|
}
|
|
|
|
}
|