Migrate to cmake
This commit is contained in:
parent
6d1690f379
commit
be6e449fb4
|
|
@ -19,7 +19,6 @@ ext {
|
||||||
whale_authors = "solohsu, asLody & MlgmXyysd"
|
whale_authors = "solohsu, asLody & MlgmXyysd"
|
||||||
|
|
||||||
riruModuleId = "edxp"
|
riruModuleId = "edxp"
|
||||||
libPathRelease = "$buildDir/ndkBuild/release/lib"
|
|
||||||
zipPathMagiskRelease = "$buildDir/tmp/release/magisk"
|
zipPathMagiskRelease = "$buildDir/tmp/release/magisk"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -30,15 +29,37 @@ android {
|
||||||
targetSdkVersion rootProject.ext.targetSdkVersion
|
targetSdkVersion rootProject.ext.targetSdkVersion
|
||||||
|
|
||||||
externalNativeBuild {
|
externalNativeBuild {
|
||||||
ndkBuild {
|
cmake {
|
||||||
abiFilters 'arm64-v8a', 'armeabi-v7a', 'x86', 'x86_64'
|
abiFilters 'arm64-v8a', 'armeabi-v7a', 'x86', 'x86_64'
|
||||||
arguments "NDK_PROJECT_PATH=jni/"
|
cppFlags "-std=c++11 -ffixed-x18 -Qunused-arguments -frtti"
|
||||||
|
cFlags "-std=gnu99 -ffixed-x18 -Qunused-arguments -frtti"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
buildTypes {
|
||||||
|
debug {
|
||||||
|
externalNativeBuild {
|
||||||
|
cmake {
|
||||||
|
cppFlags "-O0"
|
||||||
|
cFlags "-O0"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
release {
|
||||||
|
externalNativeBuild {
|
||||||
|
cmake {
|
||||||
|
cppFlags "-fvisibility=hidden -fvisibility-inlines-hidden -O2 -s"
|
||||||
|
cFlags "-fvisibility=hidden -fvisibility-inlines-hidden -O2 -s"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
minifyEnabled true
|
||||||
|
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
||||||
|
}
|
||||||
|
}
|
||||||
externalNativeBuild {
|
externalNativeBuild {
|
||||||
ndkBuild {
|
cmake {
|
||||||
path 'jni/Android.mk'
|
path "src/main/cpp/CMakeLists.txt"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -75,26 +96,51 @@ task cleanTemplate(type: Delete) {
|
||||||
delete file(templateSystemPath), file(templateSystemx86Path)
|
delete file(templateSystemPath), file(templateSystemx86Path)
|
||||||
}
|
}
|
||||||
|
|
||||||
// riru related tasks
|
afterEvaluate {
|
||||||
|
|
||||||
task buildNativeRelease(type: Exec) {
|
android.libraryVariants.all { variant ->
|
||||||
if (is_windows)
|
|
||||||
commandLine 'cmd', '/c', 'ndk-build.cmd',
|
def variantCapped = variant.name.capitalize()
|
||||||
'-j8',
|
def variantLowered = variant.name.toLowerCase()
|
||||||
"NDK_LIBS_OUT=$libPathRelease",
|
|
||||||
"NDK_OUT=$buildDir/ndkBuild/release/obj".replace("\\", "/")
|
backends.each { backend ->
|
||||||
else
|
|
||||||
commandLine 'ndk-build',
|
def backendLowered = backend.toLowerCase()
|
||||||
'-j8',
|
def backendCapped = backendLowered.capitalize()
|
||||||
"NDK_LIBS_OUT=$libPathRelease",
|
def authorList = property("${backendLowered}" + "_authors")
|
||||||
"NDK_OUT=$buildDir/ndkBuild/release/obj"
|
def magiskModuleId = property("${backendLowered}" + "_module_id")
|
||||||
|
|
||||||
|
def prepareJarsTask = task("prepareJars${backendCapped}${variantCapped}") {
|
||||||
|
dependsOn cleanTemplate, copyDalvikdxJar, copyDexmakerJar
|
||||||
|
dependsOn tasks.getByPath(":edxp-${backendLowered}:makeAndCopy${variantCapped}")
|
||||||
}
|
}
|
||||||
|
|
||||||
task cleanMagiskRelease(type: Delete) {
|
def prepareMagiskFilesTask = task("prepareMagiskFiles${backendCapped}${variantCapped}", type: Delete) {
|
||||||
|
dependsOn prepareJarsTask, "assemble${variantCapped}"
|
||||||
delete file(zipPathMagiskRelease)
|
delete file(zipPathMagiskRelease)
|
||||||
|
doFirst {
|
||||||
|
copy {
|
||||||
|
from "${projectDir}/tpl/edconfig.tpl"
|
||||||
|
into templateFrameworkPath
|
||||||
|
rename "edconfig.tpl", "edconfig.jar"
|
||||||
|
expand(version: "$version", backend: "$backend")
|
||||||
}
|
}
|
||||||
|
copy {
|
||||||
task copyFilesMagiskRelease {
|
from "${projectDir}/tpl/module.prop.tpl"
|
||||||
|
into templateRootPath
|
||||||
|
rename "module.prop.tpl", "module.prop"
|
||||||
|
expand(moduleId: "$magiskModuleId", backend: "$backendCapped",
|
||||||
|
versionName: "$version" + "($backend)",
|
||||||
|
versionCode: "$versionCode", authorList: "$authorList")
|
||||||
|
filter(FixCrLfFilter.class, eol: FixCrLfFilter.CrLf.newInstance("lf"))
|
||||||
|
}
|
||||||
|
copy {
|
||||||
|
from "${templateRootPath}/module.prop"
|
||||||
|
into templateRootPath
|
||||||
|
rename "module.prop", "riru_module.prop"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
def libPathRelease = "${buildDir}/intermediates/cmake/${variantLowered}/obj"
|
||||||
doLast {
|
doLast {
|
||||||
copy {
|
copy {
|
||||||
from "${projectDir}/template_override"
|
from "${projectDir}/template_override"
|
||||||
|
|
@ -126,58 +172,8 @@ task copyFilesMagiskRelease {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
afterEvaluate {
|
|
||||||
|
|
||||||
android.libraryVariants.all { variant ->
|
|
||||||
|
|
||||||
def variantCapped = variant.name.capitalize()
|
|
||||||
def variantLowered = variant.name.toLowerCase()
|
|
||||||
|
|
||||||
backends.each { backend ->
|
|
||||||
|
|
||||||
def backendLowered = backend.toLowerCase()
|
|
||||||
def backendCapped = backendLowered.capitalize()
|
|
||||||
def authorList = property("${backendLowered}" + "_authors")
|
|
||||||
def magiskModuleId = property("${backendLowered}" + "_module_id")
|
|
||||||
|
|
||||||
def prepareJarsTask = task("prepareJars${backendCapped}${variantCapped}") {
|
|
||||||
dependsOn cleanTemplate, copyDalvikdxJar, copyDexmakerJar
|
|
||||||
dependsOn tasks.getByPath(":edxp-${backendLowered}:makeAndCopy${variantCapped}")
|
|
||||||
}
|
|
||||||
|
|
||||||
def preZipTask = task("preZip${backendCapped}${variantCapped}", type: GradleBuild) {
|
|
||||||
dependsOn prepareJarsTask
|
|
||||||
tasks = [
|
|
||||||
'buildNativeRelease',
|
|
||||||
'cleanMagiskRelease',
|
|
||||||
'copyFilesMagiskRelease'
|
|
||||||
]
|
|
||||||
doFirst {
|
|
||||||
copy {
|
|
||||||
from "${projectDir}/tpl/edconfig.tpl"
|
|
||||||
into templateFrameworkPath
|
|
||||||
rename "edconfig.tpl", "edconfig.jar"
|
|
||||||
expand(version: "$version", backend: "$backend")
|
|
||||||
}
|
|
||||||
copy {
|
|
||||||
from "${projectDir}/tpl/module.prop.tpl"
|
|
||||||
into templateRootPath
|
|
||||||
rename "module.prop.tpl", "module.prop"
|
|
||||||
expand(moduleId: "$magiskModuleId", backend: "$backendCapped",
|
|
||||||
versionName: "$version" + "($backend)",
|
|
||||||
versionCode: "$versionCode", authorList: "$authorList")
|
|
||||||
filter(FixCrLfFilter.class, eol: FixCrLfFilter.CrLf.newInstance("lf"))
|
|
||||||
}
|
|
||||||
copy {
|
|
||||||
from "${templateRootPath}/module.prop"
|
|
||||||
into templateRootPath
|
|
||||||
rename "module.prop", "riru_module.prop"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
def zipTask = task("zip${backendCapped}${variantCapped}", type: Zip) {
|
def zipTask = task("zip${backendCapped}${variantCapped}", type: Zip) {
|
||||||
dependsOn preZipTask
|
dependsOn prepareMagiskFilesTask
|
||||||
archiveName "magisk-${module_name}-${backend}-${project.version}-${variantLowered}.zip"
|
archiveName "magisk-${module_name}-${backend}-${project.version}-${variantLowered}.zip"
|
||||||
destinationDir file("$projectDir/release")
|
destinationDir file("$projectDir/release")
|
||||||
from "$zipPathMagiskRelease"
|
from "$zipPathMagiskRelease"
|
||||||
|
|
|
||||||
|
|
@ -1 +0,0 @@
|
||||||
libs/** binary
|
|
||||||
|
|
@ -1,3 +0,0 @@
|
||||||
LOCAL_PATH := $(call my-dir)
|
|
||||||
|
|
||||||
include $(call all-makefiles-under, $(LOCAL_PATH))
|
|
||||||
|
|
@ -1,22 +0,0 @@
|
||||||
APP_ABI := arm64-v8a armeabi-v7a x86 x86_64
|
|
||||||
APP_PLATFORM := android-23
|
|
||||||
APP_CFLAGS := -std=gnu99
|
|
||||||
APP_CPPFLAGS := -std=c++11
|
|
||||||
APP_STL := c++_static
|
|
||||||
APP_SHORT_COMMANDS := true
|
|
||||||
|
|
||||||
ifeq ($(NDK_DEBUG),1)
|
|
||||||
$(info building DEBUG version...)
|
|
||||||
APP_CFLAGS += -O0
|
|
||||||
APP_CPPFLAGS += -O0
|
|
||||||
else
|
|
||||||
$(info building RELEASE version...)
|
|
||||||
APP_CFLAGS += -fvisibility=hidden -fvisibility-inlines-hidden -O2
|
|
||||||
APP_CPPFLAGS += -fvisibility=hidden -fvisibility-inlines-hidden -O2
|
|
||||||
endif
|
|
||||||
|
|
||||||
# do not remove this, or your module will crash apps on Android Q
|
|
||||||
SCS_FLAGS := -ffixed-x18
|
|
||||||
APP_LDFLAGS += $(SCS_FLAGS)
|
|
||||||
APP_CFLAGS += $(SCS_FLAGS)
|
|
||||||
APP_CPPFLAGS += $(SCS_FLAGS)
|
|
||||||
|
|
@ -1,16 +0,0 @@
|
||||||
LOCAL_PATH := $(call my-dir)
|
|
||||||
|
|
||||||
include $(CLEAR_VARS)
|
|
||||||
LOCAL_MODULE := xhook
|
|
||||||
LOCAL_SRC_FILES := xhook/xhook.c \
|
|
||||||
xhook/xh_core.c \
|
|
||||||
xhook/xh_elf.c \
|
|
||||||
xhook/xh_jni.c \
|
|
||||||
xhook/xh_log.c \
|
|
||||||
xhook/xh_util.c \
|
|
||||||
xhook/xh_version.c
|
|
||||||
LOCAL_C_INCLUDES := $(LOCAL_PATH)
|
|
||||||
LOCAL_CFLAGS := -Wall -Wextra -Werror -fvisibility=hidden
|
|
||||||
LOCAL_CONLYFLAGS := -std=c11
|
|
||||||
LOCAL_LDLIBS := -llog
|
|
||||||
include $(BUILD_STATIC_LIBRARY)
|
|
||||||
|
|
@ -1,30 +0,0 @@
|
||||||
LOCAL_PATH := $(call my-dir)
|
|
||||||
include $(CLEAR_VARS)
|
|
||||||
|
|
||||||
LOCAL_MODULE := libriru_edxp
|
|
||||||
LOCAL_C_INCLUDES := \
|
|
||||||
$(LOCAL_PATH) \
|
|
||||||
jni/external/include
|
|
||||||
LOCAL_CPPFLAGS += $(CPPFLAGS)
|
|
||||||
LOCAL_STATIC_LIBRARIES := xhook
|
|
||||||
LOCAL_LDLIBS += -ldl -llog
|
|
||||||
LOCAL_LDFLAGS := -Wl,--hash-style=both
|
|
||||||
|
|
||||||
LOCAL_SRC_FILES:= \
|
|
||||||
main.cpp \
|
|
||||||
native_hook/native_hook.cpp \
|
|
||||||
native_hook/resource_hook.cpp \
|
|
||||||
native_hook/riru_hook.cpp \
|
|
||||||
include/misc.cpp \
|
|
||||||
include/riru.c \
|
|
||||||
yahfa/HookMain.c \
|
|
||||||
yahfa/trampoline.c \
|
|
||||||
java_hook/java_hook.cpp \
|
|
||||||
inject/framework_hook.cpp \
|
|
||||||
inject/config_manager.cpp \
|
|
||||||
Substrate/SubstrateDebug.cpp \
|
|
||||||
Substrate/SubstrateHook.cpp \
|
|
||||||
Substrate/SubstratePosixMemory.cpp \
|
|
||||||
Substrate/hde64.c \
|
|
||||||
|
|
||||||
include $(BUILD_SHARED_LIBRARY)
|
|
||||||
|
|
@ -0,0 +1,6 @@
|
||||||
|
cmake_minimum_required(VERSION 3.4.1)
|
||||||
|
|
||||||
|
link_libraries("-ffixed-x18")
|
||||||
|
|
||||||
|
add_subdirectory(main)
|
||||||
|
add_subdirectory(external)
|
||||||
|
|
@ -0,0 +1,6 @@
|
||||||
|
cmake_minimum_required(VERSION 3.4.1)
|
||||||
|
|
||||||
|
add_subdirectory(xhook)
|
||||||
|
add_subdirectory(riru)
|
||||||
|
add_subdirectory(yahfa)
|
||||||
|
add_subdirectory(substrate)
|
||||||
|
|
@ -0,0 +1,6 @@
|
||||||
|
cmake_minimum_required(VERSION 3.4.1)
|
||||||
|
|
||||||
|
aux_source_directory(src SRC_LIST)
|
||||||
|
add_library(riru STATIC ${SRC_LIST})
|
||||||
|
|
||||||
|
target_include_directories(riru INTERFACE src)
|
||||||
|
|
@ -0,0 +1,6 @@
|
||||||
|
cmake_minimum_required(VERSION 3.4.1)
|
||||||
|
|
||||||
|
aux_source_directory(src SRC_LIST)
|
||||||
|
add_library(substrate STATIC ${SRC_LIST})
|
||||||
|
|
||||||
|
target_include_directories(substrate INTERFACE src)
|
||||||
|
|
@ -0,0 +1,10 @@
|
||||||
|
cmake_minimum_required(VERSION 3.4.1)
|
||||||
|
|
||||||
|
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c11 -Wall -Wextra -Werror -fvisibility=hidden")
|
||||||
|
|
||||||
|
aux_source_directory(src SRC_LIST)
|
||||||
|
add_library(xhook STATIC ${SRC_LIST})
|
||||||
|
|
||||||
|
find_library(log-lib log)
|
||||||
|
target_link_libraries(xhook ${log-lib})
|
||||||
|
target_include_directories(xhook INTERFACE include)
|
||||||
|
|
@ -0,0 +1,10 @@
|
||||||
|
cmake_minimum_required(VERSION 3.4.1)
|
||||||
|
|
||||||
|
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c11 -Wall -Wextra -fvisibility=hidden")
|
||||||
|
|
||||||
|
aux_source_directory(src SRC_LIST)
|
||||||
|
add_library(yahfa STATIC ${SRC_LIST})
|
||||||
|
|
||||||
|
find_library(log-lib log)
|
||||||
|
target_link_libraries(yahfa ${log-lib})
|
||||||
|
target_include_directories(yahfa PUBLIC include)
|
||||||
|
|
@ -0,0 +1,18 @@
|
||||||
|
cmake_minimum_required(VERSION 3.4.1)
|
||||||
|
|
||||||
|
set(CMAKE_ANDROID_STL_TYPE c++_static)
|
||||||
|
|
||||||
|
set(SRC_LIST
|
||||||
|
main.cpp
|
||||||
|
native_hook/native_hook.cpp
|
||||||
|
native_hook/resource_hook.cpp
|
||||||
|
native_hook/riru_hook.cpp
|
||||||
|
java_hook/java_hook.cpp
|
||||||
|
inject/framework_hook.cpp
|
||||||
|
inject/config_manager.cpp
|
||||||
|
)
|
||||||
|
include_directories(include .)
|
||||||
|
add_library(riru_edxp SHARED ${SRC_LIST})
|
||||||
|
|
||||||
|
find_library(log-lib log)
|
||||||
|
target_link_libraries(riru_edxp yahfa riru xhook substrate ${log-lib})
|
||||||
|
|
@ -14,7 +14,7 @@
|
||||||
|
|
||||||
extern "C"
|
extern "C"
|
||||||
{
|
{
|
||||||
#include "../yahfa/HookMain.h"
|
#include "HookMain.h"
|
||||||
}
|
}
|
||||||
|
|
||||||
jobject gInjectDexClassLoader;
|
jobject gInjectDexClassLoader;
|
||||||
|
|
@ -10,8 +10,8 @@
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <inject/framework_hook.h>
|
#include "inject/framework_hook.h"
|
||||||
#include <native_hook/native_hook.h>
|
#include "native_hook/native_hook.h"
|
||||||
|
|
||||||
#include "include/logging.h"
|
#include "include/logging.h"
|
||||||
#include "include/misc.h"
|
#include "include/misc.h"
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <inject/config_manager.h>
|
#include <inject/config_manager.h>
|
||||||
#include <Substrate/SubstrateHook.h>
|
#include <SubstrateHook.h>
|
||||||
|
|
||||||
#include "include/logging.h"
|
#include "include/logging.h"
|
||||||
#include "native_hook.h"
|
#include "native_hook.h"
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
#ifndef HOOK_H
|
#ifndef HOOK_H
|
||||||
#define HOOK_H
|
#define HOOK_H
|
||||||
|
|
||||||
#include <xhook/xhook.h>
|
#include <xhook.h>
|
||||||
|
|
||||||
#if defined(__LP64__)
|
#if defined(__LP64__)
|
||||||
static constexpr const char *kLibArtPath = "/system/lib64/libart.so";
|
static constexpr const char *kLibArtPath = "/system/lib64/libart.so";
|
||||||
|
|
@ -4,8 +4,8 @@
|
||||||
|
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <include/riru.h>
|
#include <riru.h>
|
||||||
#include <xhook/xhook.h>
|
#include <xhook.h>
|
||||||
#include <sys/system_properties.h>
|
#include <sys/system_properties.h>
|
||||||
#include <include/logging.h>
|
#include <include/logging.h>
|
||||||
#include <include/android_build.h>
|
#include <include/android_build.h>
|
||||||
Loading…
Reference in New Issue