summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Charles Lombardo2023-04-19 00:53:59 -0400
committerGravatar bunnei2023-06-03 00:05:51 -0700
commitab87f7499831b89ebc8e921f7ed9448fd8e6b49a (patch)
treed1b5fe6ab80370b740480ac641419ec4b04023ec
parentandroid: vulkan: Disable vertex_input_dynamic_state on Qualcomm. (diff)
downloadyuzu-ab87f7499831b89ebc8e921f7ed9448fd8e6b49a.tar.gz
yuzu-ab87f7499831b89ebc8e921f7ed9448fd8e6b49a.tar.xz
yuzu-ab87f7499831b89ebc8e921f7ed9448fd8e6b49a.zip
android: Convert gradle scripts to Kotlin DSL
-rw-r--r--src/android/app/build.gradle190
-rw-r--r--src/android/app/build.gradle.kts227
-rw-r--r--src/android/build.gradle10
-rw-r--r--src/android/build.gradle.kts10
-rw-r--r--src/android/settings.gradle.kts (renamed from src/android/settings.gradle)5
5 files changed, 241 insertions, 201 deletions
diff --git a/src/android/app/build.gradle b/src/android/app/build.gradle
deleted file mode 100644
index 09ca9c26f..000000000
--- a/src/android/app/build.gradle
+++ /dev/null
@@ -1,190 +0,0 @@
1plugins {
2 id 'com.android.application'
3 id 'org.jetbrains.kotlin.android'
4 id 'kotlin-parcelize'
5}
6
7/**
8 * Use the number of seconds/10 since Jan 1 2016 as the versionCode.
9 * This lets us upload a new build at most every 10 seconds for the
10 * next 680 years.
11 */
12def autoVersion = (int) (((new Date().getTime() / 1000) - 1451606400) / 10)
13def buildType
14
15android {
16 namespace 'org.yuzu.yuzu_emu'
17
18 compileSdkVersion 33
19 ndkVersion "25.2.9519653"
20
21 viewBinding.enabled = true
22
23 compileOptions {
24 sourceCompatibility JavaVersion.VERSION_11
25 targetCompatibility JavaVersion.VERSION_11
26 }
27
28 kotlinOptions {
29 jvmTarget = '11'
30 }
31
32 lint {
33 // This is important as it will run lint but not abort on error
34 // Lint has some overly obnoxious "errors" that should really be warnings
35 abortOnError false
36
37 //Uncomment disable lines for test builds...
38 //disable 'MissingTranslation'bin
39 //disable 'ExtraTranslation'
40 }
41
42 defaultConfig {
43 // TODO If this is ever modified, change application_id in strings.xml
44 applicationId "org.yuzu.yuzu_emu"
45 minSdkVersion 28
46 targetSdkVersion 33
47 versionCode autoVersion
48 versionName getVersion()
49 ndk.abiFilters "arm64-v8a", "x86_64"
50
51 buildConfigField "String", "GIT_HASH", "\"${getGitHash()}\""
52 buildConfigField "String", "BRANCH", "\"${getBranch()}\""
53 }
54
55 signingConfigs {
56 //release {
57 // storeFile file('')
58 // storePassword System.getenv('ANDROID_KEYPASS')
59 // keyAlias = 'key0'
60 // keyPassword System.getenv('ANDROID_KEYPASS')
61 //}
62 }
63
64 applicationVariants.all { variant ->
65 buildType = variant.buildType.name // sets the current build type
66 }
67
68 // Define build types, which are orthogonal to product flavors.
69 buildTypes {
70
71 // Signed by release key, allowing for upload to Play Store.
72 release {
73 signingConfig signingConfigs.debug
74 }
75
76 // builds a release build that doesn't need signing
77 // Attaches 'debug' suffix to version and package name, allowing installation alongside the release build.
78 relWithDebInfo {
79 initWith release
80 versionNameSuffix '-debug'
81 signingConfig signingConfigs.debug
82 minifyEnabled false
83 testCoverageEnabled false
84 debuggable true
85 jniDebuggable true
86 }
87
88 // Signed by debug key disallowing distribution on Play Store.
89 // Attaches 'debug' suffix to version and package name, allowing installation alongside the release build.
90 debug {
91 // TODO If this is ever modified, change application_id in debug/strings.xml
92 versionNameSuffix '-debug'
93 debuggable true
94 jniDebuggable true
95 }
96 }
97
98 flavorDimensions "version"
99 productFlavors {
100 mainline {
101 dimension "version"
102 }
103 }
104
105 externalNativeBuild {
106 cmake {
107 version "3.22.1"
108 path "../../../CMakeLists.txt"
109 }
110 }
111
112 defaultConfig {
113 externalNativeBuild {
114 cmake {
115 arguments "-DENABLE_QT=0", // Don't use QT
116 "-DENABLE_SDL2=0", // Don't use SDL
117 "-DENABLE_WEB_SERVICE=0", // Don't use telemetry
118 "-DBUNDLE_SPEEX=ON",
119 "-DANDROID_ARM_NEON=true", // cryptopp requires Neon to work
120 "-DYUZU_USE_BUNDLED_VCPKG=ON",
121 "-DYUZU_USE_BUNDLED_FFMPEG=ON"
122
123 abiFilters "arm64-v8a", "x86_64"
124 }
125 }
126 }
127}
128
129dependencies {
130 implementation 'androidx.core:core-ktx:1.9.0'
131 implementation 'androidx.appcompat:appcompat:1.6.1'
132 implementation 'androidx.exifinterface:exifinterface:1.3.6'
133 implementation 'androidx.cardview:cardview:1.0.0'
134 implementation 'androidx.recyclerview:recyclerview:1.2.1'
135 implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
136 implementation 'androidx.lifecycle:lifecycle-viewmodel:2.5.1'
137 implementation 'androidx.fragment:fragment:1.5.5'
138 implementation "androidx.slidingpanelayout:slidingpanelayout:1.2.0"
139 implementation "androidx.documentfile:documentfile:1.0.1"
140 implementation 'com.google.android.material:material:1.8.0'
141 implementation 'androidx.preference:preference:1.2.0'
142 implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.5.1"
143 implementation "io.coil-kt:coil:2.2.2"
144 implementation 'androidx.core:core-splashscreen:1.0.0'
145 implementation 'androidx.window:window:1.0.0'
146 implementation 'org.ini4j:ini4j:0.5.4'
147 implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
148 implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0'
149}
150
151def getVersion() {
152 def versionName = '0.0'
153
154 try {
155 versionName = 'git describe --always --long'.execute([], project.rootDir).text
156 .trim()
157 .replaceAll(/(-0)?-[^-]+$/, "")
158 } catch (Exception) {
159 logger.error('Cannot find git, defaulting to dummy version number')
160 }
161
162 if (System.getenv("GITHUB_ACTIONS") != null) {
163 def gitTag = System.getenv("GIT_TAG_NAME")
164 versionName = gitTag ?: versionName
165 }
166
167 return versionName
168}
169
170def getGitHash() {
171 try {
172 def gitHash = 'git rev-parse HEAD'.execute([], project.rootDir).text.trim()
173 return gitHash
174 } catch (Exception e) {
175 logger.error(e + ': Cannot find git, defaulting to dummy build hash')
176 }
177
178 return '0'
179}
180
181def getBranch() {
182 try {
183 def branch = 'git rev-parse --abbrev-ref HEAD'.execute([], project.rootDir).text.trim()
184 return branch
185 } catch (Exception e) {
186 logger.error(e + ': Cannot find git, defaulting to dummy branch')
187 }
188
189 return 'main'
190}
diff --git a/src/android/app/build.gradle.kts b/src/android/app/build.gradle.kts
new file mode 100644
index 000000000..e2b53c7bd
--- /dev/null
+++ b/src/android/app/build.gradle.kts
@@ -0,0 +1,227 @@
1plugins {
2 id("com.android.application")
3 id("org.jetbrains.kotlin.android")
4 id("kotlin-parcelize")
5}
6
7/**
8 * Use the number of seconds/10 since Jan 1 2016 as the versionCode.
9 * This lets us upload a new build at most every 10 seconds for the
10 * next 680 years.
11 */
12val autoVersion = (((System.currentTimeMillis() / 1000) - 1451606400) / 10).toInt()
13var buildType = ""
14
15@Suppress("UnstableApiUsage")
16android {
17 namespace = "org.yuzu.yuzu_emu"
18
19 compileSdkVersion = "android-33"
20 ndkVersion = "25.2.9519653"
21
22 buildFeatures {
23 viewBinding = true
24 }
25
26 compileOptions {
27 sourceCompatibility = JavaVersion.VERSION_11
28 targetCompatibility = JavaVersion.VERSION_11
29 }
30
31 kotlinOptions {
32 jvmTarget = "11"
33 }
34
35 lint {
36 // This is important as it will run lint but not abort on error
37 // Lint has some overly obnoxious "errors" that should really be warnings
38 abortOnError = false
39
40 //Uncomment disable lines for test builds...
41 //disable 'MissingTranslation'bin
42 //disable 'ExtraTranslation'
43 }
44
45 defaultConfig {
46 // TODO If this is ever modified, change application_id in strings.xml
47 applicationId = "org.yuzu.yuzu_emu"
48 minSdk = 28
49 targetSdk = 33
50 versionCode = autoVersion
51 versionName = getVersion()
52
53 ndk {
54 abiFilters += listOf("arm64-v8a", "x86_64")
55 }
56
57 buildConfigField("String", "GIT_HASH", "\"${getGitHash()}\"")
58 buildConfigField("String", "BRANCH", "\"${getBranch()}\"")
59 }
60
61 signingConfigs {
62 //release {
63 // storeFile file('')
64 // storePassword System.getenv('ANDROID_KEYPASS')
65 // keyAlias = 'key0'
66 // keyPassword System.getenv('ANDROID_KEYPASS')
67 //}
68 }
69
70 applicationVariants.all { variant ->
71 buildType = variant.buildType.name // sets the current build type
72 true
73 }
74
75 // Define build types, which are orthogonal to product flavors.
76 buildTypes {
77
78 // Signed by release key, allowing for upload to Play Store.
79 release {
80 signingConfig = signingConfigs.getByName("debug")
81 }
82
83 // builds a release build that doesn't need signing
84 // Attaches 'debug' suffix to version and package name, allowing installation alongside the release build.
85 register("relWithDebInfo") {
86 initWith(getByName("release"))
87 versionNameSuffix = "-debug"
88 signingConfig = signingConfigs.getByName("debug")
89 isMinifyEnabled = false
90 enableAndroidTestCoverage = false
91 isDebuggable = true
92 isJniDebuggable = true
93 }
94
95 // Signed by debug key disallowing distribution on Play Store.
96 // Attaches 'debug' suffix to version and package name, allowing installation alongside the release build.
97 debug {
98 // TODO If this is ever modified, change application_id in debug/strings.xml
99 versionNameSuffix = "-debug"
100 isDebuggable = true
101 isJniDebuggable = true
102 }
103 }
104
105 flavorDimensions.add("version")
106 productFlavors {
107 create("mainline") {
108 dimension = "version"
109 }
110 }
111
112 externalNativeBuild {
113 cmake {
114 version = "3.22.1"
115 path = file("../../../CMakeLists.txt")
116 }
117 }
118
119 defaultConfig {
120 externalNativeBuild {
121 cmake {
122 arguments(
123 "-DENABLE_QT=0", // Don't use QT
124 "-DENABLE_SDL2=0", // Don't use SDL
125 "-DENABLE_WEB_SERVICE=0", // Don't use telemetry
126 "-DBUNDLE_SPEEX=ON",
127 "-DANDROID_ARM_NEON=true", // cryptopp requires Neon to work
128 "-DYUZU_USE_BUNDLED_VCPKG=ON",
129 "-DYUZU_USE_BUNDLED_FFMPEG=ON"
130 )
131
132 abiFilters("arm64-v8a", "x86_64")
133 }
134 }
135 }
136}
137
138dependencies {
139 implementation("androidx.core:core-ktx:1.9.0")
140 implementation("androidx.appcompat:appcompat:1.6.1")
141 implementation("androidx.exifinterface:exifinterface:1.3.6")
142 implementation("androidx.cardview:cardview:1.0.0")
143 implementation("androidx.recyclerview:recyclerview:1.2.1")
144 implementation("androidx.constraintlayout:constraintlayout:2.1.4")
145 implementation("androidx.lifecycle:lifecycle-viewmodel:2.5.1")
146 implementation("androidx.fragment:fragment:1.5.5")
147 implementation("androidx.slidingpanelayout:slidingpanelayout:1.2.0")
148 implementation("androidx.documentfile:documentfile:1.0.1")
149 implementation("com.google.android.material:material:1.8.0")
150 implementation("androidx.preference:preference:1.2.0")
151 implementation("androidx.lifecycle:lifecycle-viewmodel-ktx:2.5.1")
152 implementation("io.coil-kt:coil:2.2.2")
153 implementation("androidx.core:core-splashscreen:1.0.0")
154 implementation("androidx.window:window:1.0.0")
155 implementation("org.ini4j:ini4j:0.5.4")
156 implementation("androidx.constraintlayout:constraintlayout:2.1.4")
157 implementation("androidx.swiperefreshlayout:swiperefreshlayout:1.1.0")
158}
159
160fun getVersion(): String {
161 var versionName = "0.0"
162
163 try {
164 versionName = ProcessBuilder("git", "describe", "--always", "--long")
165 .directory(project.rootDir)
166 .redirectOutput(ProcessBuilder.Redirect.PIPE)
167 .redirectError(ProcessBuilder.Redirect.PIPE)
168 .start().inputStream.bufferedReader().use { it.readText() }
169 .trim()
170 .replace(Regex("(-0)?-[^-]+$"), "")
171 } catch (e: Exception) {
172 logger.error("Cannot find git, defaulting to dummy version number")
173 }
174
175 if (System.getenv("GITHUB_ACTIONS") != null) {
176 val gitTag = System.getenv("GIT_TAG_NAME")
177 versionName = gitTag ?: versionName
178 }
179
180 return versionName
181}
182
183fun getGitHash(): String {
184 try {
185 val processBuilder = ProcessBuilder("git", "rev-parse", "HEAD")
186 processBuilder.directory(project.rootDir)
187 val process = processBuilder.start()
188 val inputStream = process.inputStream
189 val errorStream = process.errorStream
190 process.waitFor()
191
192 return if (process.exitValue() == 0) {
193 inputStream.bufferedReader()
194 .use { it.readText().trim() } // return the value of gitHash
195 } else {
196 val errorMessage = errorStream.bufferedReader().use { it.readText().trim() }
197 logger.error("Error running git command: $errorMessage")
198 "dummy-hash" // return a dummy hash value in case of an error
199 }
200 } catch (e: Exception) {
201 logger.error("$e: Cannot find git, defaulting to dummy build hash")
202 return "dummy-hash" // return a dummy hash value in case of an error
203 }
204}
205
206fun getBranch(): String {
207 try {
208 val processBuilder = ProcessBuilder("git", "rev-parse", "--abbrev-ref", "HEAD")
209 processBuilder.directory(project.rootDir)
210 val process = processBuilder.start()
211 val inputStream = process.inputStream
212 val errorStream = process.errorStream
213 process.waitFor()
214
215 return if (process.exitValue() == 0) {
216 inputStream.bufferedReader()
217 .use { it.readText().trim() } // return the value of gitHash
218 } else {
219 val errorMessage = errorStream.bufferedReader().use { it.readText().trim() }
220 logger.error("Error running git command: $errorMessage")
221 "dummy-hash" // return a dummy hash value in case of an error
222 }
223 } catch (e: Exception) {
224 logger.error("$e: Cannot find git, defaulting to dummy build hash")
225 return "dummy-hash" // return a dummy hash value in case of an error
226 }
227}
diff --git a/src/android/build.gradle b/src/android/build.gradle
deleted file mode 100644
index e2c06c58c..000000000
--- a/src/android/build.gradle
+++ /dev/null
@@ -1,10 +0,0 @@
1// Top-level build file where you can add configuration options common to all sub-projects/modules.
2plugins {
3 id 'com.android.application' version '7.4.2' apply false
4 id 'com.android.library' version '7.4.2' apply false
5 id 'org.jetbrains.kotlin.android' version '1.8.10' apply false
6}
7
8task clean(type: Delete) {
9 delete rootProject.buildDir
10}
diff --git a/src/android/build.gradle.kts b/src/android/build.gradle.kts
new file mode 100644
index 000000000..442209666
--- /dev/null
+++ b/src/android/build.gradle.kts
@@ -0,0 +1,10 @@
1// Top-level build file where you can add configuration options common to all sub-projects/modules.
2plugins {
3 id("com.android.application") version "7.4.2" apply false
4 id("com.android.library") version "7.4.2" apply false
5 id("org.jetbrains.kotlin.android") version "1.8.10" apply false
6}
7
8tasks.register("clean").configure {
9 delete(rootProject.buildDir)
10}
diff --git a/src/android/settings.gradle b/src/android/settings.gradle.kts
index 1e7b2cc14..1fb82df41 100644
--- a/src/android/settings.gradle
+++ b/src/android/settings.gradle.kts
@@ -5,6 +5,8 @@ pluginManagement {
5 mavenCentral() 5 mavenCentral()
6 } 6 }
7} 7}
8
9@Suppress("UnstableApiUsage")
8dependencyResolutionManagement { 10dependencyResolutionManagement {
9 repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS) 11 repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
10 repositories { 12 repositories {
@@ -12,4 +14,5 @@ dependencyResolutionManagement {
12 mavenCentral() 14 mavenCentral()
13 } 15 }
14} 16}
15include ':app' 17
18include(":app")