You've already forked Zygisk-Assistant
mirror of
https://github.com/snake-4/Zygisk-Assistant.git
synced 2025-09-06 06:37:02 +00:00
Rewrote the build system and module...
+ Added more architectures to compile. - Removed all scripts from the module, now it is compatible with all root implementations. - Removed unused code and variables. - Removed most references to the module name. * Compilation is now parallelized.
This commit is contained in:
@@ -1,7 +1,4 @@
|
||||
import android.databinding.tool.ext.capitalizeUS
|
||||
import org.apache.tools.ant.filters.FixCrLfFilter
|
||||
import org.apache.tools.ant.filters.ReplaceTokens
|
||||
import java.security.MessageDigest
|
||||
|
||||
plugins {
|
||||
alias(libs.plugins.agp.lib)
|
||||
@@ -22,7 +19,7 @@ android {
|
||||
}
|
||||
externalNativeBuild {
|
||||
ndkBuild {
|
||||
arguments("MODULE_NAME=$moduleId")
|
||||
arguments("-j${Runtime.getRuntime().availableProcessors()}")
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -37,25 +34,16 @@ androidComponents.onVariants { variant ->
|
||||
val variantLowered = variant.name.lowercase()
|
||||
val variantCapped = variant.name.capitalizeUS()
|
||||
val buildTypeLowered = variant.buildType?.lowercase()
|
||||
val supportedAbis = abiList.map {
|
||||
when (it) {
|
||||
"arm64-v8a" -> "arm64"
|
||||
else -> error("unsupported abi $it")
|
||||
}
|
||||
}.joinToString(" ")
|
||||
|
||||
val moduleDir = "$buildDir/outputs/module/$variantLowered"
|
||||
val libOutDir = layout.buildDirectory.dir("intermediates/stripped_native_libs/$variantLowered/out/lib").get()
|
||||
val moduleDir = layout.buildDirectory.dir("outputs/module/$variantLowered").get()
|
||||
val zipOutDir = layout.buildDirectory.dir("outputs/release").get()
|
||||
val zipFileName = "$moduleName-$verName-$verCode-$buildTypeLowered.zip".replace(' ', '-')
|
||||
|
||||
val prepareModuleFilesTask = task<Sync>("prepareModuleFiles$variantCapped") {
|
||||
group = "module"
|
||||
dependsOn("assemble$variantCapped")
|
||||
into(moduleDir)
|
||||
from("${rootProject.projectDir}/README.md")
|
||||
from("$projectDir/template") {
|
||||
exclude("module.prop", "customize.sh", "post-fs-data.sh", "service.sh")
|
||||
filter<FixCrLfFilter>("eol" to FixCrLfFilter.CrLf.newInstance("lf"))
|
||||
}
|
||||
from("$projectDir/template") {
|
||||
include("module.prop")
|
||||
expand(
|
||||
@@ -65,77 +53,24 @@ androidComponents.onVariants { variant ->
|
||||
"versionCode" to verCode
|
||||
)
|
||||
}
|
||||
from("$projectDir/template") {
|
||||
include("customize.sh", "post-fs-data.sh", "service.sh")
|
||||
val tokens = mapOf(
|
||||
"DEBUG" to if (buildTypeLowered == "debug") "true" else "false",
|
||||
"SONAME" to moduleId,
|
||||
"SUPPORTED_ABIS" to supportedAbis
|
||||
)
|
||||
filter<ReplaceTokens>("tokens" to tokens)
|
||||
filter<FixCrLfFilter>("eol" to FixCrLfFilter.CrLf.newInstance("lf"))
|
||||
from(libOutDir) {
|
||||
into("zygisk")
|
||||
}
|
||||
from("$buildDir/intermediates/stripped_native_libs/$variantLowered/out/lib") {
|
||||
into("lib")
|
||||
}
|
||||
|
||||
doLast {
|
||||
fileTree(moduleDir).visit {
|
||||
if (isDirectory) return@visit
|
||||
val md = MessageDigest.getInstance("SHA-256")
|
||||
file.forEachBlock(4096) { bytes, size ->
|
||||
md.update(bytes, 0, size)
|
||||
}
|
||||
file(file.path + ".sha256").writeText(org.apache.commons.codec.binary.Hex.encodeHexString(md.digest()))
|
||||
moduleDir.dir("zygisk").asFile.listFiles { f -> f.isDirectory }?.forEach { sourceDir ->
|
||||
val srcFile = file("$sourceDir/libzygisk.so")
|
||||
val dstFile = moduleDir.file("zygisk/${sourceDir.name}.so")
|
||||
srcFile.copyTo(dstFile.asFile, overwrite=true)
|
||||
delete(sourceDir)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
val zipTask = task<Zip>("zip$variantCapped") {
|
||||
task<Zip>("zip$variantCapped") {
|
||||
group = "module"
|
||||
dependsOn(prepareModuleFilesTask)
|
||||
archiveFileName.set(zipFileName)
|
||||
destinationDirectory.set(file("$buildDir/outputs/release"))
|
||||
destinationDirectory.set(zipOutDir)
|
||||
from(moduleDir)
|
||||
}
|
||||
|
||||
val pushTask = task<Exec>("push$variantCapped") {
|
||||
group = "module"
|
||||
dependsOn(zipTask)
|
||||
commandLine("adb", "push", zipTask.outputs.files.singleFile.path, "/data/local/tmp")
|
||||
}
|
||||
|
||||
val installKsuTask = task("installKsu$variantCapped") {
|
||||
group = "module"
|
||||
dependsOn(pushTask)
|
||||
doLast {
|
||||
exec {
|
||||
commandLine(
|
||||
"adb", "shell", "echo",
|
||||
"/data/adb/ksud module install /data/local/tmp/$zipFileName",
|
||||
"> /data/local/tmp/install.sh"
|
||||
)
|
||||
}
|
||||
exec { commandLine("adb", "shell", "chmod", "755", "/data/local/tmp/install.sh") }
|
||||
exec { commandLine("adb", "shell", "su", "-c", "/data/local/tmp/install.sh") }
|
||||
}
|
||||
}
|
||||
|
||||
val installMagiskTask = task<Exec>("installMagisk$variantCapped") {
|
||||
group = "module"
|
||||
dependsOn(pushTask)
|
||||
commandLine("adb", "shell", "su", "-c", "magisk --install-module /data/local/tmp/$zipFileName")
|
||||
}
|
||||
|
||||
task<Exec>("installKsuAndReboot$variantCapped") {
|
||||
group = "module"
|
||||
dependsOn(installKsuTask)
|
||||
commandLine("adb", "reboot")
|
||||
}
|
||||
|
||||
task<Exec>("installMagiskAndReboot$variantCapped") {
|
||||
group = "module"
|
||||
dependsOn(installMagiskTask)
|
||||
commandLine("adb", "reboot")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user