-
Notifications
You must be signed in to change notification settings - Fork 178
/
build.gradle
231 lines (206 loc) · 8.5 KB
/
build.gradle
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
import org.apache.tools.ant.filters.FixCrLfFilter
import org.apache.tools.ant.filters.ReplaceTokens
import java.security.MessageDigest
plugins {
id('com.android.application')
id('dev.rikka.tools.refine')
}
apply from: file(rootProject.file('module.gradle'))
android {
namespace "rikka.sui"
compileSdk rootProject.ext.targetSdkVersion
defaultConfig {
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode gitCommitCount
versionName moduleVersion.substring(1)
//ndkVersion rootProject.ext.ndkVersion
}
buildFeatures {
viewBinding true
prefab true
}
externalNativeBuild {
cmake {
path "src/main/cpp/CMakeLists.txt"
version "3.10.2"
}
}
buildTypes {
debug {
defaultConfig.minSdk 24
multiDexEnabled false
}
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
flavorDimensions "version"
productFlavors {
riru {
dimension "version"
externalNativeBuild {
cmake {
arguments "-DRIRU_MODULE_API_VERSION=$moduleRiruApiVersion",
"-DRIRU_MODULE_VERSION=$moduleVersionCode",
"-DRIRU_MODULE_VERSION_NAME:STRING=\"$moduleVersion\"",
"-DFLAVOR=riru",
"-DANDROID_STL=none"
}
}
}
zygisk {
dimension "version"
externalNativeBuild {
cmake {
arguments "-DFLAVOR=zygisk",
"-DZYGISK_MODULE_ID:STRING=\"$zygiskModuleId\"",
"-DANDROID_STL=none"
}
}
}
}
lintOptions {
checkReleaseBuilds false
}
dependenciesInfo {
includeInApk false
}
}
dependencies {
implementation libs.refine.runtime
implementation 'dev.rikka.ndk:riru:26.0.0'
implementation 'dev.rikka.ndk.thirdparty:cxx:1.2.0'
implementation 'dev.rikka.ndk.thirdparty:nativehelper:1.0.1'
implementation 'dev.rikka.rikkax.parcelablelist:parcelablelist:2.0.0'
implementation "androidx.annotation:annotation:1.3.0"
implementation 'androidx.core:core:1.9.0'
implementation project(':aidl')
implementation project(':shared')
implementation project(':api')
implementation project(':rish')
implementation project(':server-shared')
implementation libs.hidden.compat
compileOnly libs.hidden.stub
}
def outDir = file("$rootDir/out")
afterEvaluate {
def isIDE = properties.containsKey('android.injected.invoked.from.ide')
if (isIDE) {
println("Invoked from IDE")
} else {
println("Invoked from command line")
}
android.applicationVariants.all { variant ->
def variantCapped = variant.name.capitalize()
def variantLowered = variant.name.toLowerCase()
def buildTypeCapped = variant.getBuildType().getName().capitalize()
def buildTypeLowered = variant.getBuildType().getName().toLowerCase()
def flavorCapped = variantCapped.replaceFirst(buildTypeCapped, "")
def flavorLowered = variantLowered.replaceFirst(buildTypeLowered, "")
def zipName = "sui-${flavorLowered}-${moduleVersion}-${buildTypeLowered}.zip"
def magiskDir = file("$outDir/${flavorLowered}_${buildTypeLowered}")
tasks.getByName("pre${variantCapped}Build").dependsOn(":ui:assemble${buildTypeCapped}")
task("prepareMagiskFiles${variantCapped}", type: Sync) {
dependsOn("assemble$variantCapped")
def templatePath = "$rootDir/template/magisk_module"
into magiskDir
from(templatePath) {
exclude 'riru.sh', 'customize.sh', 'post-fs-data.sh', 'module.prop'
}
if (flavorLowered == 'riru') {
from(templatePath) {
include 'riru.sh'
filter(ReplaceTokens.class, tokens: [
"RIRU_MODULE_LIB_NAME" : moduleLibraryName,
"RIRU_MODULE_API_VERSION" : moduleRiruApiVersion.toString(),
"RIRU_MODULE_MIN_API_VERSION" : moduleMinRiruApiVersion.toString(),
"RIRU_MODULE_MIN_RIRU_VERSION_NAME": moduleMinRiruVersionName,
])
filter(FixCrLfFilter.class,
eol: FixCrLfFilter.CrLf.newInstance("lf"))
}
}
from(templatePath) {
include 'customize.sh'
filter(ReplaceTokens.class, tokens: [
"FLAVOR": flavorLowered,
])
filter(FixCrLfFilter.class,
eol: FixCrLfFilter.CrLf.newInstance("lf"))
}
from(templatePath) {
include 'post-fs-data.sh'
filter(ReplaceTokens.class, tokens: [
"FLAVOR": flavorLowered,
])
filter(FixCrLfFilter.class,
eol: FixCrLfFilter.CrLf.newInstance("lf"))
}
from(templatePath) {
include 'module.prop'
expand([
id : (flavorLowered == "zygisk") ? zygiskModuleId : riruModuleId,
name : flavorCapped + " - " + moduleName,
version : moduleVersion,
versionCode: moduleVersionCode.toString(),
author : moduleAuthor,
description: moduleDescription + " " + ((flavorLowered == "zygisk") ?
"This module requires Magisk 24.0+ and Zygisk enabled. DO NOT add SystemUI and Settings to DenyList." :
"This module requires Riru $moduleMinRiruVersionName or above."),
updateJson : (flavorLowered == "zygisk") ?
"https://rikkaapps.github.io/release/sui_zygisk.json" :
"https://rikkaapps.github.io/release/sui_riru.json",
])
filter(FixCrLfFilter.class,
eol: FixCrLfFilter.CrLf.newInstance("lf"))
}
from((buildTypeLowered == "release") ?
"$buildDir/intermediates/dex/${variant.name}/minify${variantCapped}WithR8" :
"$buildDir/intermediates/dex/${variant.name}/mergeDex$variantCapped") {
include 'classes.dex'
rename { 'sui.dex' }
}
from("$buildDir/intermediates/stripped_native_libs/${variant.name}/out/lib") {
into 'lib'
}
from("${rootProject.findProject('ui').buildDir}/outputs/apk/$buildTypeLowered") {
exclude 'output-metadata.json'
rename { 'sui.apk' }
}
doLast {
fileTree("$magiskDir").visit { f ->
if (f.directory) return
if (f.file.name == '.gitattributes') return
def md = MessageDigest.getInstance("SHA-256")
f.file.eachByte 4096, { bytes, size ->
md.update(bytes, 0, size)
}
file(f.file.path + ".sha256sum").text = md.digest().encodeHex()
}
}
}
task("zip${variantCapped}", type: Zip) {
dependsOn("prepareMagiskFiles${variantCapped}")
from magiskDir
archiveFileName = zipName
destinationDirectory = outDir
}
task("push${variantCapped}", type: Exec) {
dependsOn("assemble${variantCapped}")
workingDir outDir
commandLine android.adbExecutable, "push", zipName, "/data/local/tmp/"
}
task("flash${variantCapped}", type: Exec) {
dependsOn("push${variantCapped}")
commandLine android.adbExecutable, "shell", "su", "-c",
"magisk --install-module /data/local/tmp/${zipName}"
}
task("flashAndReboot${variantCapped}", type: Exec) {
dependsOn("flash${variantCapped}")
commandLine android.adbExecutable, "shell", "reboot"
}
variant.assembleProvider.get().finalizedBy("zip${variantCapped}")
}
}