summaryrefslogtreecommitdiff
path: root/src/android/app/build.gradle.kts
diff options
context:
space:
mode:
Diffstat (limited to 'src/android/app/build.gradle.kts')
-rw-r--r--src/android/app/build.gradle.kts248
1 files changed, 248 insertions, 0 deletions
diff --git a/src/android/app/build.gradle.kts b/src/android/app/build.gradle.kts
new file mode 100644
index 000000000..06f22fabe
--- /dev/null
+++ b/src/android/app/build.gradle.kts
@@ -0,0 +1,248 @@
1// SPDX-FileCopyrightText: 2023 yuzu Emulator Project
2// SPDX-License-Identifier: GPL-3.0-or-later
3
4import android.annotation.SuppressLint
5
6plugins {
7 id("com.android.application")
8 id("org.jetbrains.kotlin.android")
9 id("kotlin-parcelize")
10 kotlin("plugin.serialization") version "1.8.21"
11}
12
13/**
14 * Use the number of seconds/10 since Jan 1 2016 as the versionCode.
15 * This lets us upload a new build at most every 10 seconds for the
16 * next 680 years.
17 */
18val autoVersion = (((System.currentTimeMillis() / 1000) - 1451606400) / 10).toInt()
19
20@Suppress("UnstableApiUsage")
21android {
22 namespace = "org.yuzu.yuzu_emu"
23
24 compileSdkVersion = "android-33"
25 ndkVersion = "25.2.9519653"
26
27 buildFeatures {
28 viewBinding = true
29 }
30
31 compileOptions {
32 sourceCompatibility = JavaVersion.VERSION_17
33 targetCompatibility = JavaVersion.VERSION_17
34 }
35
36 kotlinOptions {
37 jvmTarget = "17"
38 }
39
40 packaging {
41 // This is necessary for libadrenotools custom driver loading
42 jniLibs.useLegacyPackaging = true
43 }
44
45 lint {
46 // This is important as it will run lint but not abort on error
47 // Lint has some overly obnoxious "errors" that should really be warnings
48 abortOnError = false
49
50 //Uncomment disable lines for test builds...
51 //disable 'MissingTranslation'bin
52 //disable 'ExtraTranslation'
53 }
54
55 defaultConfig {
56 // TODO If this is ever modified, change application_id in strings.xml
57 applicationId = "org.yuzu.yuzu_emu"
58 minSdk = 30
59 targetSdk = 33
60 versionName = getGitVersion()
61
62 ndk {
63 @SuppressLint("ChromeOsAbiSupport")
64 abiFilters += listOf("arm64-v8a")
65 }
66
67 buildConfigField("String", "GIT_HASH", "\"${getGitHash()}\"")
68 buildConfigField("String", "BRANCH", "\"${getBranch()}\"")
69 }
70
71 // Define build types, which are orthogonal to product flavors.
72 buildTypes {
73
74 // Signed by release key, allowing for upload to Play Store.
75 release {
76 signingConfig = signingConfigs.getByName("debug")
77 isMinifyEnabled = true
78 isDebuggable = false
79 proguardFiles(
80 getDefaultProguardFile("proguard-android.txt"),
81 "proguard-rules.pro"
82 )
83 }
84
85 register("relWithVersionCode") {
86 signingConfig = signingConfigs.getByName("debug")
87 isMinifyEnabled = true
88 isDebuggable = false
89 proguardFiles(
90 getDefaultProguardFile("proguard-android.txt"),
91 "proguard-rules.pro"
92 )
93 }
94
95 // builds a release build that doesn't need signing
96 // Attaches 'debug' suffix to version and package name, allowing installation alongside the release build.
97 register("relWithDebInfo") {
98 signingConfig = signingConfigs.getByName("debug")
99 isMinifyEnabled = true
100 isDebuggable = true
101 proguardFiles(
102 getDefaultProguardFile("proguard-android.txt"),
103 "proguard-rules.pro"
104 )
105 versionNameSuffix = "-debug"
106 isJniDebuggable = true
107 }
108
109 // Signed by debug key disallowing distribution on Play Store.
110 // Attaches 'debug' suffix to version and package name, allowing installation alongside the release build.
111 debug {
112 isDebuggable = true
113 isJniDebuggable = true
114 versionNameSuffix = "-debug"
115 }
116 }
117
118 flavorDimensions.add("version")
119 productFlavors {
120 create("mainline") {
121 dimension = "version"
122 buildConfigField("Boolean", "PREMIUM", "false")
123 }
124
125 create("ea") {
126 dimension = "version"
127 buildConfigField("Boolean", "PREMIUM", "true")
128 applicationIdSuffix = ".ea"
129 }
130 }
131
132 externalNativeBuild {
133 cmake {
134 version = "3.22.1"
135 path = file("../../../CMakeLists.txt")
136 }
137 }
138
139 defaultConfig {
140 externalNativeBuild {
141 cmake {
142 arguments(
143 "-DENABLE_QT=0", // Don't use QT
144 "-DENABLE_SDL2=0", // Don't use SDL
145 "-DENABLE_WEB_SERVICE=0", // Don't use telemetry
146 "-DBUNDLE_SPEEX=ON",
147 "-DANDROID_ARM_NEON=true", // cryptopp requires Neon to work
148 "-DYUZU_USE_BUNDLED_VCPKG=ON",
149 "-DYUZU_USE_BUNDLED_FFMPEG=ON",
150 "-DYUZU_ENABLE_LTO=ON"
151 )
152
153 abiFilters("arm64-v8a", "x86_64")
154 }
155 }
156 }
157}
158
159dependencies {
160 implementation("androidx.core:core-ktx:1.10.1")
161 implementation("androidx.appcompat:appcompat:1.6.1")
162 implementation("androidx.recyclerview:recyclerview:1.3.0")
163 implementation("androidx.constraintlayout:constraintlayout:2.1.4")
164 implementation("androidx.fragment:fragment-ktx:1.5.7")
165 implementation("androidx.documentfile:documentfile:1.0.1")
166 implementation("com.google.android.material:material:1.9.0")
167 implementation("androidx.preference:preference:1.2.0")
168 implementation("androidx.lifecycle:lifecycle-viewmodel-ktx:2.6.1")
169 implementation("io.coil-kt:coil:2.2.2")
170 implementation("androidx.core:core-splashscreen:1.0.1")
171 implementation("androidx.window:window:1.0.0")
172 implementation("org.ini4j:ini4j:0.5.4")
173 implementation("androidx.constraintlayout:constraintlayout:2.1.4")
174 implementation("androidx.swiperefreshlayout:swiperefreshlayout:1.1.0")
175 implementation("androidx.navigation:navigation-fragment-ktx:2.5.3")
176 implementation("androidx.navigation:navigation-ui-ktx:2.5.3")
177 implementation("info.debatty:java-string-similarity:2.0.0")
178 implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.5.0")
179}
180
181fun getGitVersion(): String {
182 var versionName = "0.0"
183
184 try {
185 versionName = ProcessBuilder("git", "describe", "--always", "--long")
186 .directory(project.rootDir)
187 .redirectOutput(ProcessBuilder.Redirect.PIPE)
188 .redirectError(ProcessBuilder.Redirect.PIPE)
189 .start().inputStream.bufferedReader().use { it.readText() }
190 .trim()
191 .replace(Regex("(-0)?-[^-]+$"), "")
192 } catch (e: Exception) {
193 logger.error("Cannot find git, defaulting to dummy version number")
194 }
195
196 if (System.getenv("GITHUB_ACTIONS") != null) {
197 val gitTag = System.getenv("GIT_TAG_NAME")
198 versionName = gitTag ?: versionName
199 }
200
201 return versionName
202}
203
204fun getGitHash(): String {
205 try {
206 val processBuilder = ProcessBuilder("git", "rev-parse", "--short", "HEAD")
207 processBuilder.directory(project.rootDir)
208 val process = processBuilder.start()
209 val inputStream = process.inputStream
210 val errorStream = process.errorStream
211 process.waitFor()
212
213 return if (process.exitValue() == 0) {
214 inputStream.bufferedReader()
215 .use { it.readText().trim() } // return the value of gitHash
216 } else {
217 val errorMessage = errorStream.bufferedReader().use { it.readText().trim() }
218 logger.error("Error running git command: $errorMessage")
219 "dummy-hash" // return a dummy hash value in case of an error
220 }
221 } catch (e: Exception) {
222 logger.error("$e: Cannot find git, defaulting to dummy build hash")
223 return "dummy-hash" // return a dummy hash value in case of an error
224 }
225}
226
227fun getBranch(): String {
228 try {
229 val processBuilder = ProcessBuilder("git", "rev-parse", "--abbrev-ref", "HEAD")
230 processBuilder.directory(project.rootDir)
231 val process = processBuilder.start()
232 val inputStream = process.inputStream
233 val errorStream = process.errorStream
234 process.waitFor()
235
236 return if (process.exitValue() == 0) {
237 inputStream.bufferedReader()
238 .use { it.readText().trim() } // return the value of gitHash
239 } else {
240 val errorMessage = errorStream.bufferedReader().use { it.readText().trim() }
241 logger.error("Error running git command: $errorMessage")
242 "dummy-hash" // return a dummy hash value in case of an error
243 }
244 } catch (e: Exception) {
245 logger.error("$e: Cannot find git, defaulting to dummy build hash")
246 return "dummy-hash" // return a dummy hash value in case of an error
247 }
248}