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:
@@ -4,30 +4,8 @@ plugins {
|
||||
alias(libs.plugins.agp.lib) apply false
|
||||
}
|
||||
|
||||
fun String.execute(currentWorkingDir: File = file("./")): String {
|
||||
val byteOut = ByteArrayOutputStream()
|
||||
project.exec {
|
||||
workingDir = currentWorkingDir
|
||||
commandLine = split("\\s".toRegex())
|
||||
standardOutput = byteOut
|
||||
}
|
||||
return String(byteOut.toByteArray()).trim()
|
||||
}
|
||||
|
||||
val moduleId by extra("qingyue")
|
||||
val moduleName by extra("Zygisk Qingyue")
|
||||
val verName by extra("v1.0.0")
|
||||
val verCode by extra(100)
|
||||
val abiList by extra(listOf("arm64-v8a"))
|
||||
|
||||
val androidMinSdkVersion by extra(29)
|
||||
val androidTargetSdkVersion by extra(34)
|
||||
val androidCompileSdkVersion by extra(34)
|
||||
val androidBuildToolsVersion by extra("34.0.0")
|
||||
val androidCompileNdkVersion by extra("26.0.10792818")
|
||||
val androidSourceCompatibility by extra(JavaVersion.VERSION_11)
|
||||
val androidTargetCompatibility by extra(JavaVersion.VERSION_11)
|
||||
|
||||
tasks.register("Delete", Delete::class) {
|
||||
delete(rootProject.buildDir)
|
||||
}
|
||||
val abiList by extra(listOf("armeabi-v7a","arm64-v8a","x86","x86_64"))
|
||||
|
||||
@@ -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")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
LOCAL_PATH := $(call my-dir)
|
||||
|
||||
include $(CLEAR_VARS)
|
||||
LOCAL_MODULE := qingyue
|
||||
LOCAL_SRC_FILES := qingyue.cpp
|
||||
LOCAL_MODULE := zygisk
|
||||
LOCAL_SRC_FILES := main.cpp
|
||||
LOCAL_STATIC_LIBRARIES := libcxx
|
||||
LOCAL_LDLIBS := -llog
|
||||
include $(BUILD_SHARED_LIBRARY)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
APP_ABI := arm64-v8a
|
||||
APP_ABI := armeabi-v7a arm64-v8a x86 x86_64
|
||||
APP_CPPFLAGS := -std=c++17 -fno-exceptions -fno-rtti -fvisibility=hidden -fvisibility-inlines-hidden
|
||||
APP_STL := none
|
||||
APP_PLATFORM := android-29
|
||||
|
||||
@@ -23,7 +23,7 @@ using zygisk::Api;
|
||||
using zygisk::AppSpecializeArgs;
|
||||
using zygisk::ServerSpecializeArgs;
|
||||
|
||||
class Qingyue : public zygisk::ModuleBase {
|
||||
class ZygiskModule : public zygisk::ModuleBase {
|
||||
public:
|
||||
void onLoad(Api *api, JNIEnv *env) override {
|
||||
this->api = api;
|
||||
@@ -54,4 +54,4 @@ private:
|
||||
|
||||
};
|
||||
|
||||
REGISTER_ZYGISK_MODULE(Qingyue)
|
||||
REGISTER_ZYGISK_MODULE(ZygiskModule)
|
||||
@@ -1,4 +0,0 @@
|
||||
#!/usr/bin/env sh
|
||||
|
||||
resetprop sys.oem_unlock_allowed 0
|
||||
resetprop init.svc.adbd stopped
|
||||
@@ -1 +0,0 @@
|
||||
samurai for boot-completed
|
||||
@@ -1,31 +0,0 @@
|
||||
SKIPUNZIP=1
|
||||
|
||||
SONAME=@SONAME@
|
||||
|
||||
VERSION=$(grep_prop version "${TMPDIR}/module.prop")
|
||||
ui_print "- Installing $SONAME $VERSION"
|
||||
|
||||
ui_print "- Extracting verify.sh"
|
||||
unzip -o "$ZIPFILE" 'verify.sh' -d "$TMPDIR" >&2
|
||||
if [ ! -f "$TMPDIR/verify.sh" ]; then
|
||||
ui_print "*********************************************************"
|
||||
ui_print "! Unable to extract verify.sh!"
|
||||
ui_print "! This zip may be corrupted, please try downloading again"
|
||||
abort "*********************************************************"
|
||||
fi
|
||||
. "$TMPDIR/verify.sh"
|
||||
extract "$ZIPFILE" 'customize.sh' "$TMPDIR/.vunzip"
|
||||
extract "$ZIPFILE" 'verify.sh' "$TMPDIR/.vunzip"
|
||||
|
||||
ui_print "- Extracting module files"
|
||||
extract "$ZIPFILE" 'module.prop' "$MODPATH"
|
||||
extract "$ZIPFILE" "credits" "$MODPATH"
|
||||
extract "$ZIPFILE" "boot-completed.sh" "$MODPATH"
|
||||
|
||||
chmod -R 755 "$MODPATH/*"
|
||||
|
||||
mkdir "$MODPATH/zygisk"
|
||||
|
||||
ui_print "- Extracting arm64 libraries"
|
||||
extract "$ZIPFILE" "lib/arm64-v8a/lib$SONAME.so" "$MODPATH/zygisk" true
|
||||
mv "$MODPATH/zygisk/lib$SONAME.so" "$MODPATH/zygisk/arm64-v8a.so"
|
||||
@@ -1,51 +0,0 @@
|
||||
TMPDIR_FOR_VERIFY="$TMPDIR/.vunzip"
|
||||
mkdir "$TMPDIR_FOR_VERIFY"
|
||||
|
||||
abort_verify() {
|
||||
ui_print "*********************************************************"
|
||||
ui_print "! $1"
|
||||
ui_print "! This zip may be corrupted, please try downloading again"
|
||||
abort "*********************************************************"
|
||||
}
|
||||
|
||||
# extract <zip> <file> <target dir> <junk paths>
|
||||
extract() {
|
||||
zip=$1
|
||||
file=$2
|
||||
dir=$3
|
||||
junk_paths=$4
|
||||
[ -z "$junk_paths" ] && junk_paths=false
|
||||
opts="-o"
|
||||
[ $junk_paths = true ] && opts="-oj"
|
||||
|
||||
file_path=""
|
||||
hash_path=""
|
||||
if [ $junk_paths = true ]; then
|
||||
file_path="$dir/$(basename "$file")"
|
||||
hash_path="$TMPDIR_FOR_VERIFY/$(basename "$file").sha256"
|
||||
else
|
||||
file_path="$dir/$file"
|
||||
hash_path="$TMPDIR_FOR_VERIFY/$file.sha256"
|
||||
fi
|
||||
|
||||
unzip $opts "$zip" "$file" -d "$dir" >&2
|
||||
[ -f "$file_path" ] || abort_verify "$file not exists"
|
||||
|
||||
unzip $opts "$zip" "$file.sha256" -d "$TMPDIR_FOR_VERIFY" >&2
|
||||
[ -f "$hash_path" ] || abort_verify "$file.sha256 not exists"
|
||||
|
||||
(echo "$(cat "$hash_path") $file_path" | sha256sum -c -s -) || abort_verify "Failed to verify $file"
|
||||
ui_print "- Verified $file" >&1
|
||||
}
|
||||
|
||||
file="META-INF/com/google/android/update-binary"
|
||||
file_path="$TMPDIR_FOR_VERIFY/$file"
|
||||
hash_path="$file_path.sha256"
|
||||
unzip -o "$ZIPFILE" "META-INF/com/google/android/*" -d "$TMPDIR_FOR_VERIFY" >&2
|
||||
[ -f "$file_path" ] || abort_verify "$file not exists"
|
||||
if [ -f "$hash_path" ]; then
|
||||
(echo "$(cat "$hash_path") $file_path" | sha256sum -c -s -) || abort_verify "Failed to verify $file"
|
||||
ui_print "- Verified $file" >&1
|
||||
else
|
||||
ui_print "- Download from Magisk app"
|
||||
fi
|
||||
@@ -14,7 +14,6 @@ dependencyResolutionManagement {
|
||||
}
|
||||
}
|
||||
|
||||
rootProject.name = "qingyue"
|
||||
include(
|
||||
":module"
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user